当前位置:   article > 正文

Unity 编辑器扩展之——Toggle_unity editor toggle

unity editor toggle

用toggle来控制按钮的显示与隐藏

编辑器扩展参考链接

 

  1. using UnityEditor;
  2. using UnityEngine;
  3. [CustomEditor(typeof(Test))]
  4. public class Tools:Editor
  5. {
  6. bool show = true;
  7. public override void OnInspectorGUI()
  8. {
  9. Test mc = (Test)target;
  10. base.OnInspectorGUI();
  11. show = EditorGUILayout.Toggle("show",show);
  12. if (show)
  13. {
  14. if (GUILayout.Button("我的按钮", GUILayout.Height(30)))
  15. {
  16. //按钮的功能写这里
  17. //mc.a = 50;
  18. }
  19. }
  20. else if(!show)
  21. {
  22. //不显示按钮
  23. }
  24. }
  25. }
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Test : MonoBehaviour
  5. {
  6. public int a=10;
  7. public Vector3 pos, rot;
  8. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/92970
推荐阅读
相关标签
  

闽ICP备14008679号