简要代码如下:

using UnityEditor;
using UnityEngine;
using System.IO;
using System.Collections;
using System.Collections.Generic; public class RenameEffect
{
[MenuItem("XiYouEditor/Effect/RenameEffect-AddPrefix")]
static void Execute()
{
foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets))
{
if (!(o is Object))
continue;
AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(o), "P-" + o.name);
}
}
}

其处理拷贝动作文件:

using UnityEditor;
using UnityEngine;
using System.IO;
using System.Collections;
using System.Collections.Generic; public class AnimationBatch
{
[MenuItem("XiYouEditor/Animation/Copy Batch")]
static void Execute()
{
List<string> lstAnimName = new List<string>(); foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets))
{
if (!(o is GameObject))
continue;
if (!o.name.Contains("@"))
continue; GameObject charFbx = (GameObject)o; string strClipName = charFbx.name;
int nIndex = strClipName.LastIndexOf('@');
strClipName = strClipName.Substring(nIndex + , strClipName.Length - nIndex - ); AnimationClip newClip = new AnimationClip();
EditorUtility.CopySerialized(charFbx.animation.GetClip(strClipName), newClip); string strNewAnim = AssetDatabase.GetAssetPath(charFbx);
strNewAnim = strNewAnim.Substring(, strNewAnim.LastIndexOf('/') + );
strNewAnim += strClipName;
strNewAnim += ".anim"; if(!File.Exists(strNewAnim))
AssetDatabase.CreateAsset(newClip, strNewAnim); lstAnimName.Add(strClipName);
} foreach (Object o in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets))
{
if (!(o is GameObject))
continue;
if (o.name.Contains("@"))
continue; GameObject charFbx = (GameObject)o; string CharDirPath = AssetDatabase.GetAssetPath(charFbx);
CharDirPath = CharDirPath.Substring(, CharDirPath.LastIndexOf('/') + ); // 清空默认动作
charFbx.animation.clip = null; foreach (string name in lstAnimName)
{
AnimationClip DestClip = (AnimationClip)AssetDatabase.LoadAssetAtPath(CharDirPath + name + ".anim", typeof(AnimationClip));
charFbx.animation.RemoveClip(name);
charFbx.animation.AddClip(DestClip, name);
} // 重设默认动作
AnimationClip defaultClip = charFbx.animation.GetClip("Idle1");
if (defaultClip != null)
charFbx.animation.clip = defaultClip; charFbx.animation.cullingType = AnimationCullingType.AlwaysAnimate; EditorUtility.SetDirty(o);
}
}
}

具体代码根据项目需求进行定制~

  

批量修改Project视图中Prefab的名字的更多相关文章

  1. [SQL]批量修改存储过程视图

    存储过程与视图适用 ); )='w_sp_Sms_ExpeOrKeepEmpl'; DECLARE C_TABLES CURSOR FAST_FORWARD FOR SELECT NAME FROM ...

  2. Unity查找Editor下Project视图中特定的资源

    [MenuItem("Tools/Check Text Count")] public static void CheckText () { //查找指定路径下指定类型的所有资源, ...

  3. Unity3D Editor模式下批量修改prefab

    最经遇到一个需要批量修改已经做好的prefab的问题,查了一些资料最终实现了但是还是不够完美,通过学习也发现unity的编辑器功能还是非常强大的.废话不多说直接上代码: [ExecuteInEditM ...

  4. 如何在Protel99se中批量修改元件的封装

    有时候需要批量修改元件的封装,可在原理图和PCB中批量修改.本文以批量修改电阻AXIAL0.3 的封装为AXIAL0.4 为例. 1. 在原理图中批量修改1.1. 方法1双击需要修改封装的其中一个元件 ...

  5. Unity3D中Prefab

    Prefab概念: Prefab是一种资源类型--存储在项目视图中的一种可反复使用的游戏对象.因而当游戏中须要非常多反复使用的对象.资源等时,Prefab就有了用武之地.它拥有下面特点: 能够放到多个 ...

  6. 3D Slicer Hide 3D Cube and Axis Labels Programmatically 使用代码隐藏三维视图中的方框和坐标轴标签

    在3D Slicer中,我们如果想在自己写的插件中来修改三维视图中的默认设置的话,那么首先就需要获得三维视图的结点,其类型为vtkMRMLViewNode,获得了这个结点后,我们就可以用代码来修改一系 ...

  7. [Unity工具]批量修改Texture

    BatchModifyTexture.cs using UnityEngine; using System.Collections; using UnityEditor; using System.I ...

  8. rename 批量修改文件名

    1.rename的用法 rename与mv的区别就是mv只能对单个文件重命名,而rename可以批量修改文件名 linux中的rename有两种版本,一种是C语言版的,一种是Perl版的.早期的Lin ...

  9. bat批量修改图片的名字实现(两种方法)

    问题描述: 业务中遇到需要批量修改大量图片的名字. 如下图,需要修改为图片名字“u=”之后和“,”之前的那一串 解决思路1: bat批处理,网上查找相关代码如下: @echo off SetLocal ...

随机推荐

  1. inotify-tools使用方法介绍

    原文 inotify-tools 是为linux下inotify文件监控工具提供的一套c的开发接口库函数,同时还提供了一系列的命令行工具,这些工具可以用来监控文件系统的事件. inotify-tool ...

  2. android: 使用 IntentService

    9.5.2 使用 IntentService 话说回来,在本章一开始的时候我们就已经知道,服务中的代码都是默认运行在主线程 当中的,如果直接在服务里去处理一些耗时的逻辑,就很容易出现 ANR(Appl ...

  3. LPC43xx SGPIO DMA and Interrupts

    The SGPIO output pins SGPIO14 and SGPIO15 can trigger a GPDMA request SGPIO pins SGPIO14 and SGPIO15 ...

  4. Python:将utf-8格式的文件转换成gbk格式的文件

    需求:将utf-8格式的文件转换成gbk格式的文件 实现代码如下: def ReadFile(filePath,encoding="utf-8"): with codecs.ope ...

  5. 什么是automatic variable?

    看代码符号$?搞不清楚是什么?   看代码. $share = Get-WmiObject -Class Win32_Share -ComputerName $Server.name -Credent ...

  6. Spark随机深林扩展—OOB错误评估和变量权重

    本文目的 当前spark(1.3版)随机森林实现,没有包括OOB错误评估和变量权重计算.而这两个功能在实际工作中比较常用.OOB错误评估可以代替交叉检验,评估模型整体结果,避免交叉检验带来的计算开销. ...

  7. JS 获取自定义标签

    <abc-aaa xwe='sdf'>AAAAAAAAAAAAAAAAAAAAAA</abc-aaa> alert($("abc-aaa").attr(&q ...

  8. HTTP 错误 500.21 - Internal Server Error 处理程序“ExtensionlessUrlHandler-Integrated-4.0”在其模块列表中有一个错误模块“ManagedPipelineHandler”

    导致这个错误出现的原因是因为.net Framework4.0没有注册 解决方法:打开运行命令行,运行下面的命令: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30 ...

  9. Codeforces Beta Round #17 C. Balance DP

    C. Balance 题目链接 http://codeforces.com/contest/17/problem/C 题面 Nick likes strings very much, he likes ...

  10. ubuntu 13.10 Ralink RT3290 无线与蓝牙4.0的驱动安装

    我的本是hp envy15, 蓝牙与无线的型号是Ralink RT3290, 装了Ubuntu 13.10 64bit后,蓝牙无法使用,无线几秒钟就会断开,查知,是因为驱动问题. ## 准备工作 首先 ...