轉(zhuǎn)載:http://www.xuanyusong.com/archives/3685
比如編輯模式下對(duì)場景或者特定文件夾有一些操作可以在這個(gè)面板里來完成难礼。银受。
代碼如下岛马。
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))]