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

比如编辑模式下对场景或者特定文件夹有一些操作可以在这个面板里来完成。。

代码如下。

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))]
原文地址:https://www.cnblogs.com/yangyxd/p/5304811.html