- Home /
Customizing Inspector variables.
I have a script that is attached to different types of objects in my game and one of the exposed variables in the script is a bool "EnableProximity". The intention is to make the object active when the player comes within a predefined distance of the object, so I have also exposed a public variable "ProximityDistance" so both can be configured in the Inspector.
Is there anyway to hide or disable the "ProximityDistance" field when "EnableProximity" is not checked?
Answer by Xtro · Aug 26, 2013 at 01:58 PM
You must write a custom editor script for your own script. So, you can do what ever you want. Without a custom editor, it's impossible.
You have two choices with custom editors: a property drawer or a custom inspector. If you have a variable that requires similar special attention in a multiple scripts, you should go with property drawers. A custom inspector is simpler, but restricted to a specific type (class).
Yeah, I was aware of custom editor, but didn't really want to go that route. I was hoping there would be a PropertyAttribute I could use to set it up.
Can you please mark the correct answer if you fixed that problem?