标签:
你曾想要把某些公有变量在Inspetor面板中隐藏起来吗,这样很简单就能做到.
让我们来看以下代码:
1 using UnityEngine; 2 3 public class HidingScript : MonoBehaviour { 4 5 public int variableThatNeedsToBeHidden = 100; 6 7 public int visibleVariable = 0; 8 }
可以看到这里Public 出的变量都显示出来了,要想让Public修饰的变量不在inspector中显示,需要给不显示的变量加上[HideInInspector].
1 using UnityEngine; 2 3 public class HidingScript : MonoBehaviour { 4 5 [HideInInspector] 6 public int variableThatNeedsToBeHidden = 100; 7 8 public int visibleVariable = 0; 9 }
下面可以看到,加上[HideInInspector]后的public变量在inspector中看不到了:
Tips6:用[HideInInspector]在Inspector中隐藏变量
标签:
原文地址:http://www.cnblogs.com/qiaogaojian/p/5931518.html