﻿using UnityEngine;
using UnityEditor;

namespace StudyUnity
{
    public class CustomCanvasWindow : EditorWindow
    {
        [MenuItem("Tools/CustomDrawer")]
        public static void OpenEditor()
        {
            var editor = GetWindow<CustomCanvasWindow>();
            editor.minSize = new Vector2(800, 600);
            Texture icon = AssetDatabase.LoadAssetAtPath<Texture>("path");
            editor.titleContent = new GUIContent("Editor", icon);
        }

        //[UnityEditor.Callbacks.OnOpenAsset(1)] 双击资源的时候打开编辑器
        private static bool AutoOpenCanvas(int instanceID, int line)
        {
            if(Selection.activeObject != null /*&& Selection.activeObject is NodeCanvas*/)
            {
	            //string path = AssetDatabase.GetAssetPath(instanceID);
                OpenEditor();
                //LoadNodeCanvas()
                return true;
            }
            return false;
        }
    }
}
