|
UnityEditor扩展
Unity可以在Hierarchy、Project、东西栏(别名:Context)等(右键)列表中新增功能。
注意:
- 函数必需静态才能调用。
- 这类方式需要放在Editor文件下,否则打不出包。
Hierarchy
- using UnityEditor;
- using UnityEngine;
- namespace Nory
- {
- public static class HierarchyMenuInspector
- {
- [MenuItem(”GameObject/扩展/重定名/挨次父节点名”, priority = 0)]
- static void OrderName()
- {
- Transform parent = Selection.activeTransform;
- string name = parent.name;
- for (int i = 0; i < parent.childCount; i++)
- {
- Transform t = parent.GetChild(i);
- Undo.RegisterFullObjectHierarchyUndo(t, t.name);
- t.name = name + i;
- }
- }
- }
复制代码 <hr/>Project
- using UnityEditor;
- using UnityEngine;
- namespace Nory
- {
- public static class ProjectMenuInspector
- {
- [MenuItem(”Assets/Copy Resource Path”, false, 2)]
- public static void CopyResourcePath()
- {
- string[] strs = Selection.assetGUIDs;
- string path = AssetDatabase.GUIDToAssetPath(strs[0]);
- string pre_path = path.Substring(17);
- string last_path = pre_path.Split('.')[0];
- GUIUtility.systemCopyBuffer = last_path;
- }
- }
- }
复制代码 <hr/>Context
- using System.Text;
- using System;
- using System.IO;
- using UnityEngine;
- using UnityEditor;
- namespace Nory
- {
- public static class ContextMenuInspector
- {
- [MenuItem(”Tools/输出预制体名”)]
- public static void OutName()
- {
- string path = ”Assets/Art/Perfab”;//Assets/Scenes
- string outpath = @”Assets/Art/outmes.txt”;
- if (Directory.Exists(path))
- {
- DirectoryInfo directoryInfo = new DirectoryInfo(path);
- FileInfo[] fileInfos = directoryInfo.GetFiles(”*”, SearchOption.AllDirectories);
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < fileInfos.Length; i++)
- {
- if (fileInfos[i].Name.EndsWith(”.prefab”))
- {
- builder.Append(Path.GetFileNameWithoutExtension(fileInfos[i].Name) + Environment.NewLine);
- }
- }
- File.WriteAllText(outpath, builder.ToString());
- Debug.Log(”Done”);
- }
- }
- }
- }
复制代码 <hr/>Game
即时模式 GUI (IMGUI) - Unity 手册
- 创建游戏内调试显示和东西。
- 为脚本组件创建自定义检视面板。
- 创建新的编纂器窗口和东西以扩展 Unity 本身。
<hr/>Inspector
- 自定义编纂器 - Unity 手册
- Unity3D研究院之Inspector面板枚举的别号与排序(八十九) | 雨松MOMO法式研究院(中文枚举)
- Unity中实现字段/枚举编纂器中显示中文(中文枚举、中文标签)
- Unity3d Editor 编纂器扩展功能详解(1) 目录索引 - 李恒的文章 - 知乎
<hr/>ProjectSetting
UnityEditor.SettingsProvider - Unity 脚本 API |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|