UnityEditor 打开对应类
来源:互联网 发布:淘宝中国制造怎么申请 编辑:程序博客网 时间:2024/06/08 03:59
编辑器查找类,并打开:
public class EventGraphAction { private static Dictionary<string, string> ClassFiles = null; public static bool OpenInEditor(string className) { if (ClassFiles == null) { ClassFiles = new Dictionary<string, string>(); DirSearch("Assets/"); } foreach (KeyValuePair<string, string> entry in ClassFiles) { if (entry.Key.Equals(className)) { OpenClass(entry.Value); return true; } } return false; } public static void OpenClass(string classPath) {#if UNITY_EDITOR string AssetPath = classPath.Substring(Application.dataPath.Length, classPath.Length - Application.dataPath.Length); AssetPath = "Assets" + AssetPath; string guid = AssetDatabase.AssetPathToGUID(AssetPath); // AssetDatabase.OpenAsset() // Check is Script Inspector 2 installed first... // Should be in the same assembly as your CodeArchitectureHelper class (or any other C# Editor class) var si2WindowType = System.Type.GetType("FGCodeWindow"); if (si2WindowType != null) { var openAssetInTab = si2WindowType.GetMethod("OpenAssetInTab", new System.Type[] { typeof(string), typeof(int) }); if (openAssetInTab != null) { openAssetInTab.Invoke(null, new object[] { guid, -1 }); return; } } UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(classPath, 0);#endif } private static void DirSearch(string sDir) { try { DirectoryInfo dir = new DirectoryInfo(sDir); foreach (DirectoryInfo d in dir.GetDirectories()) { foreach (FileInfo f in d.GetFiles()) { if (f.Extension == ".cs") { string name = f.Name.Substring(0, f.Name.Length - 3); ClassFiles.Add(name, f.FullName); } } DirSearch(d.FullName); } } catch (System.Exception excpt) { Debug.LogWarning(excpt.Message); } }}
1 0
- UnityEditor 打开对应类
- UnityEditor的Selection类
- UnityEditor 热键
- 初涉UnityEditor
- UnityEditor(1)
- 快速打开控制面板的对应程序
- JList 点击打开对应的视频
- ProcessStartInfo 打开电脑里面的对应内容
- android点击链接打开应用对应界面
- 使用UnityEditor做工具
- UnityEditor常用函数
- UnityEditor.Callbacks中的OnOpenAssetAttribute
- UnityEditor 反射事件2
- UnityEditor 事件(1)
- Unityeditor 事件(2)
- UnityEditor Windows Event(3)
- UnityEditor Window Event
- 解决 UnityEditor.AsyncHTTPClient:Done
- EasyUI Tabs选项卡自适应浏览器宽度和高度
- 雅思专家告知大家如何正确看待美国大学最新排名
- Comparable与Comparator的区别
- ajax json 前台传数据到后台,后台接收并返回json 数据
- 并查集理解
- UnityEditor 打开对应类
- C++第1次实验-标准体重
- privacy polic
- php的默认配置文件在 /usr/local/apache2/conf/php.ini,通过为了使你的web更安全,我们需要对php.ini进行一些设置!
- python调用videocapture出错的问题
- Simple Tutorial on SVM and Parameter Tuning in Python and R
- aop和注解将权限和操作日志与业务解耦
- 在framework中添加字符串资源
- 爬虫-漫画喵的100行逆袭