Editor UI

Editor 界面点击调用静态方法

菜单栏静态方法

[MenuItem("Tools/Init")]
static void Init() {}

Hierachy 或 Project 右键静态方法

实际上就是菜单栏的 Assets 中的方法

[MenuItem("Assets/Create/Init")]
static void Init() {}
[CreateAssetMenu("Assets/Create/Init")]
static void Init() {}

EditorWindow

提供 snippet

using UnityEditor;
using UnityEngine;

public class $WindowName$EditorWindow : EditorWindow {
    public $WindowName$EditorWindow() {
        titleContent = new GUIContent("$WindowName$");
    }

    [MenuItem("Tools/$WindowName$")]
    static void Init() {
        var window = GetWindow<$WindowName$EditorWindow>();
        window.Show();
    }

    private void OnGUI() {

        $selected$ $end$
    }
}

EditorInspector

提供 snippet

using UnityEditor;
using UnityEngine;

[CustomEditor(typeof($TargetClass$))]
public class $TargetClass$Editor : Editor {
    public override void OnInspectorGUI() {
        serializedObject.Update();
        $TargetClass$ comp = target as $TargetClass$;

        $selected$ $end$

        serializedObject.ApplyModifiedProperties();
    }
}

界面渲染

查看同层级下的 OnGUI 内容

资料

综合

EditorWindow

  • [Unity拓展编辑器 —— EditorWindow(一)_unity editorwindow 图片-CSDN博客] (https://blog.csdn.net/qq_35030499/article/details/88350521)

最后更新于