注:资源可在AssetStore下原作者版本。

  1. 点击编辑器窗口的
// DAzBjax (2015), if you have same questions contact me at DAzBjax.Unity@mail.ru using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
using System.Reflection;[ExecuteInEditMode]
public class DAX_MultiObjectsRenamer : EditorWindow
{ const string MenuItemSTR = "Tools/Multi objects rename tool";const string TabCaptionSTR = "MO Rename";Object[] findedObjects;bool[] exportedObjects;bool tOnlyROOT = true;bool tShowResult = true;string ReplaceFrom = "";string ReplaceTo = "";      int lastErrorsCount;    Vector2 scrollVector;//设置编辑器的一个眼睛图标的字节参数byte[] pngBytesEYE = new byte[] {137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 19, 0, 0, 0, 19, 8, 6, 0, 0, 0, 114, 80, 54, 204, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 11, 19, 0, 0, 11, 19, 1, 0, 154, 156, 24, 0, 0, 0, 32, 99, 72, 82, 77, 0, 0, 122, 37, 0, 0, 128, 131, 0, 0, 249, 255, 0, 0, 128, 232, 0, 0, 82, 8, 0, 1, 21, 88, 0, 0, 58, 151, 0, 0, 23, 111, 215, 90, 31, 144, 0, 0, 2, 76, 73, 68, 65, 84, 120, 218, 228, 148, 203, 79, 19, 97, 20, 197, 207, 204, 180, 196, 118, 58, 51, 116, 35, 76, 37, 33, 64, 89, 72, 210, 198, 134, 146, 144, 82, 22, 117, 129, 16, 68, 23, 60, 130, 91, 82, 170, 136, 11, 18, 12, 113, 217, 53, 143, 45, 255, 129, 134, 242, 90, 104, 13, 77, 109, 40, 144, 144, 52, 145, 202, 163, 6, 215, 26, 211, 84, 87, 246, 49, 44, 128, 249, 174, 11, 165, 97, 120, 24, 22, 221, 121, 183, 223, 239, 158, 197, 119, 206, 185, 28, 17, 161, 82, 195, 163, 130, 83, 81, 49, 78, 177, 59, 175, 123, 107, 3, 48, 12, 192, 3, 64, 2, 80, 4, 176, 7, 224, 53, 128, 244, 141, 196, 24, 35, 23, 17, 91, 240, 122, 239, 181, 12, 244, 247, 193, 237, 186, 11, 155, 36, 162, 84, 212, 144, 249, 252, 5, 145, 197, 183, 216, 217, 217, 59, 52, 153, 132, 97, 142, 227, 50, 134, 101, 197, 238, 132, 98, 119, 66, 174, 110, 178, 112, 66, 205, 98, 71, 231, 67, 138, 197, 214, 233, 228, 228, 148, 174, 26, 198, 24, 37, 18, 91, 228, 243, 247, 18, 39, 212, 44, 201, 213, 77, 150, 51, 13, 40, 118, 39, 108, 114, 131, 200, 155, 213, 200, 104, 104, 146, 24, 99, 229, 197, 100, 114, 155, 6, 135, 130, 164, 222, 113, 211, 224, 80, 144, 146, 201, 109, 131, 112, 232, 217, 75, 18, 204, 106, 196, 38, 55, 136, 138, 221, 9, 72, 74, 163, 96, 170, 114, 76, 143, 4, 39, 12, 96, 42, 149, 166, 177, 241, 41, 90, 89, 141, 146, 166, 105, 180, 178, 26, 165, 177, 241, 41, 74, 165, 210, 6, 110, 36, 56, 65, 166, 42, 199, 180, 164, 52, 10, 16, 204, 106, 115, 187, 175, 135, 242, 249, 130, 1, 10, 135, 103, 104, 118, 110, 158, 116, 93, 39, 34, 34, 93, 215, 105, 118, 110, 158, 194, 225, 25, 3, 151, 207, 23, 168, 221, 215, 67, 130, 89, 109, 230, 69, 209, 26, 120, 208, 21, 128, 44, 75, 134, 191, 76, 239, 30, 192, 225, 168, 5, 207, 255, 73, 15, 207, 243, 112, 56, 106, 145, 222, 61, 48, 112, 178, 44, 161, 187, 235, 62, 68, 209, 26, 224, 53, 237, 104, 35, 30, 223, 64, 161, 80, 52, 64, 173, 30, 55, 178, 217, 28, 24, 99, 127, 93, 102, 200, 102, 115, 104, 245, 184, 13, 92, 161, 80, 68, 44, 190, 14, 77, 59, 74, 10, 54, 233, 246, 175, 175, 223, 190, 91, 114, 63, 126, 118, 60, 126, 212, 93, 134, 44, 150, 91, 72, 110, 110, 227, 248, 248, 4, 245, 245, 117, 136, 190, 255, 128, 244, 167, 125, 12, 244, 247, 161, 174, 78, 45, 115, 207, 95, 188, 194, 218, 218, 250, 140, 213, 106, 89, 46, 187, 41, 152, 213, 72, 232, 233, 205, 221, 100, 140, 209, 104, 104, 146, 248, 243, 110, 94, 204, 153, 207, 223, 75, 137, 196, 150, 65, 244, 114, 206, 54, 201, 223, 217, 71, 188, 169, 118, 241, 124, 206, 46, 53, 128, 136, 92, 167, 167, 250, 66, 91, 155, 167, 101, 112, 224, 172, 1, 54, 148, 138, 37, 236, 103, 14, 177, 180, 252, 14, 59, 31, 175, 110, 192, 191, 186, 233, 5, 240, 228, 66, 55, 119, 1, 188, 185, 182, 155, 255, 199, 61, 251, 61, 0, 216, 84, 140, 133, 246, 8, 144, 48, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 };Texture2D eyeTex;[MenuItem(MenuItemSTR)]static void Init () {// Get existing open window or if none, make a new one:DAX_MultiObjectsRenamer window = (DAX_MultiObjectsRenamer)EditorWindow.GetWindow (typeof (DAX_MultiObjectsRenamer));window.title = TabCaptionSTR;window.Show();}
//主要控制这些物体是展示父物体,还是选择物体等等void updateInfo( bool loadSelection = false ){try{findedObjects = new Object[0];if (loadSelection) {findedObjects = Selection.objects;}else{findedObjects = GameObject.FindObjectsOfType (typeof(GameObject));}if ( findedObjects != null ){Object[] tfObj;int maxSize = 0;for (int i = 0; i < findedObjects.Length; i++) {if (!tOnlyROOT){maxSize++;}else if ((findedObjects[i] as GameObject).transform.parent == null){maxSize++;}}tfObj = new Object[maxSize];int curItem = 0;for (int i = 0; i < findedObjects.Length; i++) {if (!tOnlyROOT | ((findedObjects[i] as GameObject).transform.parent == null) ){tfObj[curItem] = findedObjects[i];curItem++;}}findedObjects = tfObj;  exportedObjects = new bool[findedObjects.Length];for(int i = 0; i < findedObjects.Length; i++) {exportedObjects[i] = true;}}}catch{};}
//展示编辑器窗口 通过活动条罗列出要命名的物体名字。void OnGUI () {try {GUILayout.Label ("Base Settings", EditorStyles.boldLabel);EditorGUILayout.BeginVertical ();EditorGUILayout.BeginHorizontal ();EditorGUILayout.LabelField ("Find:", GUILayout.MaxWidth(75.0f));ReplaceFrom = EditorGUILayout.TextField( ReplaceFrom );     EditorGUILayout.EndHorizontal();EditorGUILayout.BeginHorizontal ();EditorGUILayout.LabelField ("Replace to:", GUILayout.MaxWidth(75.0f));ReplaceTo = EditorGUILayout.TextField( ReplaceTo );     EditorGUILayout.EndHorizontal();EditorGUILayout.EndVertical ();EditorGUILayout.Separator();EditorGUILayout.BeginHorizontal ();EditorGUILayout.BeginVertical();#if UNITY_5_0tOnlyROOT = EditorGUILayout.ToggleLeft( "Root Objects", tOnlyROOT, GUILayout.MaxWidth(115.0f) );tShowResult = EditorGUILayout.ToggleLeft( "Show result", tShowResult, GUILayout.MaxWidth(115.0f) );#elsetOnlyROOT = EditorGUILayout.Toggle( "Root Objects", tOnlyROOT );tShowResult = EditorGUILayout.Toggle( "Show result", tShowResult );#endifEditorGUILayout.EndVertical();if(GUILayout.RepeatButton("Load ALL", GUILayout.MaxWidth(70.0f))){updateInfo( false );}if(GUILayout.RepeatButton("Load Selection", GUILayout.MaxWidth(95.0f))){updateInfo( true );}EditorGUILayout.EndHorizontal ();GUILayout.BeginHorizontal(GUI.skin.box, GUILayout.MaxHeight(400.0f));if (eyeTex==null) //no eye lodaded{eyeTex = new Texture2D(2,2);eyeTex.LoadImage( pngBytesEYE ); //load eye}   scrollVector = GUILayout.BeginScrollView(scrollVector);lastErrorsCount = 0;if (findedObjects != null) {for (int i = 0; i < findedObjects.Length; i++) {if (findedObjects [i] != null){       try{           EditorGUILayout.BeginHorizontal (); if (GUILayout.Button( eyeTex, GUI.skin.label, GUILayout.MaxHeight(18.0f), GUILayout.MaxWidth( 20.0f )   )) //draw asterix{EditorGUIUtility.PingObject( findedObjects [i] );}   try {       if ((ReplaceFrom!="") & (tShowResult) & (exportedObjects [i])){exportedObjects [i] = EditorGUILayout.BeginToggleGroup (findedObjects [i].name.Replace( ReplaceFrom, ReplaceTo ), exportedObjects [i]); //checkboxes leftEditorGUILayout.EndToggleGroup ();}else{exportedObjects [i] = EditorGUILayout.BeginToggleGroup (findedObjects [i].name, exportedObjects [i]); //checkboxes leftEditorGUILayout.EndToggleGroup ();}}catch{};EditorGUILayout.EndHorizontal ();}catch{};}       }}GUILayout.EndScrollView();GUILayout.EndHorizontal();EditorGUILayout.BeginHorizontal (GUI.skin.box);if (GUILayout.Button ("Rename Objects")) {if (findedObjects != null) {for (int i = 0; i < findedObjects.Length; i++) {if (findedObjects [i] != null){       try{   if ((ReplaceFrom!="") & (exportedObjects [i])){findedObjects [i].name = findedObjects [i].name.Replace( ReplaceFrom, ReplaceTo );}}   catch{};}}}}GUILayout.FlexibleSpace();if (GUILayout.Button ("Cancel")) {DAX_MultiObjectsRenamer window = (DAX_MultiObjectsRenamer)EditorWindow.GetWindow (typeof (DAX_MultiObjectsRenamer));window.Close();}EditorGUILayout.EndHorizontal ();}catch{};}
}

Unity EditorWindow Rename相关推荐

  1. Unity编辑器扩展之EditorWindow

    Unity编辑器扩展之EditorWindow 继承这个类的编辑器脚本可以用来创建一个编辑器窗口,类似Inspector窗口 若要在这个类中添加一些控件,可以使用GUI和GUILayout控件,还可以 ...

  2. Unity中EditorWindow的创建和停靠

    API简介 创建EditorWindow主要使用的方法有两个:GetWindow和CreateWindow 1.GetWindow和CreateWindow的区别: (1)GetWindow试图寻找指 ...

  3. Unity编辑器扩展——EditorWindow

    创建窗口 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEdito ...

  4. Unity UI Toolkit学习笔记-EditorWindow

  5. Unity修改批量修改名字工具

    Unity修改批量修改名字工具 using System.Collections; using System.Collections.Generic; using UnityEngine; using ...

  6. Unity 批量重命名文件工具

    参考 编辑器窗口 GUILayout.Space [Unity]8.3 布局模式(GUILayout) Unity:资源文件批处理名称修改 原理 读取选中的所有资源对象 资源对象统一重命名格式 实现编 ...

  7. Unity Log重新定向

    Unity Log重新定向 使用Unity的Log的时候有时候需要封装一下Debug.Log(message),可以屏蔽Log或者把log内容写到文本中.通过把文本内容传送到服务器中,查找bug出现的 ...

  8. 如何导出android studio程序,Android Studio 如何导出 Jar 给 Unity 使用

    大致步骤如下:1.创建新的 Android Studio 工程2.为此 Android Studio 工程创建 Android Library 类库(也就是一个 Module)(后面就是用它生成 ja ...

  9. 【unity】拓展自定义编辑器窗口(二)

    http://www.xuanyusong.com/archives/2211 Unity支持自行创建窗口,也支持自定义窗口布局.在Project视图中创建一个Editor文件夹,在文件夹中在创建一条 ...

最新文章

  1. matlab2013 a/b 找不到vs2013 c++ 编译器 解决方案
  2. Bootloader
  3. 看完就懂系列—动态规划
  4. Python数据结构——array
  5. c语言see函数,vprintf() - C语言库函数
  6. 重庆最狠的火锅,都是用来泡脚的
  7. build, version详解iOS App SwiftUI
  8. 关于ORA-00257问题的解决(归档程序错误)
  9. MTK 6735/6739/6755/6763 android8.1 user版本打开root权限(adb root权限和 apk root权限)
  10. 白话区块链 之4: 区块链分类与架构
  11. sniffer pro 4.7.5安装教程(附安装系统环境及软件链接)
  12. 词汇学习系列(一):252个基本词根详解
  13. HDU3533Escape(BFS )
  14. spark(1)---概述
  15. 网络安全与计算机信息管理论文,计算机信息管理技术在网络安全的应用论文
  16. python里d是什么意思?
  17. 英语常考知识点汇总笔记
  18. 微信小程序使用图片标签出现白底
  19. GET日志服务如何使用让你获得建立DT时代海量日志处理能力
  20. Robosense速腾激光雷达如何在线连接雷达并发送点云数据到ROS

热门文章

  1. python基础程序设计与面向对象程序设计_python基础——面向对象的程序设计
  2. [转] Photoshop教程8000例
  3. 制作Android程序的应用图标并应用
  4. Notepad++插件: HexEditor
  5. 解救MacBook Pro老电脑显卡
  6. pyspark steaming 连接kafka数据实时处理(也可以对接flume+kafka+spark)
  7. 软件测试-柠檬班python全栈自动化50期测试学习笔记分享
  8. 决策引擎服务平台blaze_是Blaze数据服务还是LiveCycle数据服务?
  9. 解决Safari12.0不能自动打开EasyConnect(或者如何降级Safari)的问题
  10. Multisim基础 电容遇到交流+直流电路时,容抗与隔直通交的特性