简要代码如下:

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. Leetcode 203 Remove Linked List Elements 链表

    去掉链表中相应的元素值 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next ...

  2. Vue.js:轻量高效的前端组件化方案(转载)

    摘要:Vue.js通过简洁的API提供高效的数据绑定和灵活的组件系统.在前端纷繁复杂的生态中,Vue.js有幸受到一定程度的关注,目前在GitHub上已经有5000+的star.本文将从各方面对Vue ...

  3. WebView上实现Java与JavaScript交互

    在安卓开发上,考虑到开发效率和界面更新,有时使用WebView结合web页面技术,可以快速迭代地开发移动应用.WebView加载资源的速度并不慢,但是如果资源多了,就很慢.图片.css.js.html ...

  4. LPC43xx Dual-core or Multi-core configuration and JLink Debug

    Test access port (TAP) JTAG defines a TAP (Test access port). The TAP is a general-purpose port that ...

  5. Revit如何设置尺寸标注的箭头样式

    在尺寸标注类型属性中,有一名称为"记号标记"的属性,该属性控制线性标注的箭头样式,如图所示,可以从下"记号标记"下拉列表中选择需要的样式进行设置,但是有时候该下 ...

  6. android studio 乱码

    1. 设置 file- setting -file encodeing- 设置utf-8 2 .  build.gradle 添加 tasks.withType(JavaCompile) { opti ...

  7. The web application [] appears to have started a thread named [Abandoned connection cleanup thread] com.mysql.jdbc.AbandonedConnectionCleanupThread

    01-Jul-2016 14:25:30.937 WARNING [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoade ...

  8. javascript提升复习

    https://www.baidu.com/s?wd=JavaScript+%E9%A2%84%E8%A7%A3%E6%9E%90 http://www.cnblogs.com/HPNiuYear/a ...

  9. A little tutorial on CodeFluent Entities with ASP.NET MVC4

    /* Author: Jiangong SUN */ CodeFluent Entities is a model-first development tool which creates non-s ...

  10. java.lang.OutOfMemoryError: PermGen space PermGen space & java.lang.OutOfMemoryError: Java heap space Heap siz

    java.lang.OutOfMemoryError: PermGen space PermGen space 由-XX:PermSize  -XX:MaxPermSize 引起 java.lang. ...