- Home /
Making a minor change to Default inspector?
Hi, I have a multi-purpose class [handles all health and death related stuff] that has a bunch of variables that are only required should a bool be true,
e.g. if its not marked as an Exploder I don't need the Explosion Radius or Explosion Damage properties
Is there any way to make a minor change [like toggling visibility] to the default inspector instead of having to write a complete inspector[which would require updating should the base class have variables added]
I'm thinking something like
override public void OnInspectorGUI()
{
KillableObject me = target as KillableObject;
DrawDefaultInspector();
if (!me.Exploder)
{
DefaultInspector.Hide("ExplosionRange");
DefaultInspector.Hide("ExplosionDamage");
}
}
Thanks for any help
Answer by Veehmot · Oct 18, 2011 at 01:04 PM
Well, you have the HideInInspector attribute, but that can't be set on runtime. As far as I know you can't do that without recurring to an Editor class. That's what they are for, though.
Base class to derive custom Editors from. Use this to create your own custom inspectors and editors for your objects.
The OnInspectorGUI function of that class is called automatically when needed. For disabling things, maybe you will be interested in the Foldout widget.
Your answer
Follow this Question
Related Questions
calculate things... and display in inspector 3 Answers
Error while using SerializeField and HideInInspector tags 0 Answers
Custom inspector resets values when refreshing 1 Answer
Unity Editor - Class variable value contrain 4 Answers
Why do Public Variables overwrite a Scripts Default Value 2 Answers