用toggle来控制按钮的显示与隐藏
编辑器扩展参考链接
?
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(Test))]
public class Tools:Editor
{
bool show = true;
public override void OnInspectorGUI()
{
Test mc = (Test)target;
base.OnInspectorGUI();
show = EditorGUILayout.Toggle("show",show);
if (show)
{
if (GUILayout.Button("我的按钮", GUILayout.Height(30)))
{
//按钮的功能写这里
//mc.a = 50;
}
}
else if(!show)
{
//不显示按钮
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public int a=10;
public Vector3 pos, rot;
}
|