Unity编辑器开发分享unity修炼之路Unity基础入门分享

Unity3D研究院编辑器之自定义默认资源的Inspector面

2017-09-25  本文已影响24人  霸俊流年

转自:http://www.xuanyusong.com/archives/3685
比如编辑模式下对场景或者特定文件夹有一些操作可以在这个面板里来完成。。

代码如下。

using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(UnityEditor.DefaultAsset))]
publicclassCustomInspector:Editor{
publicoverride voidOnInspectorGUI()
{
stringpath=AssetDatabase.GetAssetPath(target);
GUI.enabled=true;
if(path.EndsWith(".unity"))
{
GUILayout.Button("我是场景");
}elseif(path.EndsWith("")){;
GUILayout.Button("我是文件夹");
}
}
}

如果你是unity5.3的话, 想在场景面板上面绘制东西需要使用 UnityEditor.SceneAsset

[CustomEditor(typeof(UnityEditor.SceneAsset))]

本文固定链接: http://www.xuanyusong.com/archives/3685
转载请注明: 雨松MOMO2015年10月23日 于 雨松MOMO程序研究院 发表

上一篇 下一篇

猜你喜欢

热点阅读