unity 编辑器扩展 扩展assert编辑器

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;


/// <summary>
/// 用来在监视器下面生成一个按钮,可以扩展编辑器
/// 这个文件必须放在Editor文件夹下面
/// </summary>
[CustomEditor(typeof(UnityEditor.DefaultAsset))]
public class CustomInspector : Editor {

    public override void OnInspectorGUI()
    {
        //返回assert文件路径
        string path = AssetDatabase.GetAssetPath(target);

        GUI.enabled = true;

        if (path.EndsWith(".unity"))
        {
            GUILayout.Button("我是场景");
        }
        else if(path.EndsWith(""))
        {
            GUILayout.Button("我是文件件");
        }
    }
}

原文地址:https://www.cnblogs.com/yufenghou/p/7344345.html