你曾想要把某些公有变量在Inspetor面板中隐藏起来吗,这样很简单就能做到.
让我们来看以下代码:
using UnityEngine; public class HidingScript : MonoBehaviour { public int variableThatNeedsToBeHidden = ; public int visibleVariable = ;
}
可以看到这里Public 出的变量都显示出来了,要想让Public修饰的变量不在inspector中显示,需要给不显示的变量加上[HideInInspector].
using UnityEngine; public class HidingScript : MonoBehaviour { [HideInInspector]
public int variableThatNeedsToBeHidden = ; public int visibleVariable = ;
}
下面可以看到,加上[HideInInspector]后的public变量在inspector中看不到了: