Unity3D研究院编辑器之自定义默认资源的Inspector面
2017-08-22 本文已影响11人
循环渐进123456
转载:http://www.xuanyusong.com/archives/3685
比如编辑模式下对场景或者特定文件夹有一些操作可以在这个面板里来完成。。

代码如下。
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(UnityEditor.DefaultAsset))]
public class CustomInspector : Editor {
public override void OnInspectorGUI ()
{
string path = AssetDatabase.GetAssetPath(target);
GUI.enabled = true;
if(path.EndsWith(".unity"))
{
GUILayout.Button("我是场景");
}else if(path.EndsWith("")){;
GUILayout.Button("我是文件夹");
}
}
}
如果你是unity5.3的话, 想在场景面板上面绘制东西需要使用 UnityEditor.SceneAsset
[CustomEditor(typeof(UnityEditor.SceneAsset))]