using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class EditorTest : MonoBehaviour {

    // Use this for initialization
    void Start() {

    }

    // Update is called once per frame
    void Update() {

    }
    [ContextMenu("cnm")]//扩展inspector面板  通过邮件即可出现菜单  cnm
    void fucking()
    {

    }
    public void m_function()
    {

    }
}
[CustomEditor(typeof(EditorTest))]//typeof 括号里面就是我们要扩充的组件的名字,比如我们的脚本是EditorTest,那么我们是需要在这个脚本组件上面添加一个按钮,那么就括号里面填这个脚本名
public class configure:Editor
    {
    public override void OnInspectorGUI()
    {
      //  base.OnInspectorGUI();
        if (GUILayout.Button("配置"))
        {
           EditorTest test =  target as EditorTest;//通过target 获取脚本
            test.m_function();//进行调用
            Debug.Log("我点击了");
        }
    }
}

Unity扩展Inspector面板

Unity扩展Inspector面板

相关文章:

  • 2021-05-01
  • 2021-09-28
  • 2021-08-23
  • 2021-06-25
  • 2021-09-22
  • 2022-01-10
  • 2021-06-20
猜你喜欢
  • 2021-06-22
  • 2021-05-06
  • 2021-11-07
  • 2021-12-26
  • 2021-08-11
  • 2021-06-19
  • 2021-07-07
相关资源
相似解决方案