I need to expose a variable on the inspector. But when I change that variable through the inspector, I need other things to happen. So I tried making a setter for that variable. But when I change that exposed variable, it gets changed directly and the inspector bypasses the setter. Is there a way to force the inspector to use the setter? Or is there another way to force things to happen once a variable gets changed in the inspector? Thanks in advance!
asked Aug 02 '12 at 07:40 PM
I would write a custom inspector for this problem. To start off you would write your normal Monobehavior script like the following and attach it to a gameObject where you will be able to see the public property visible. But when you get/set the value the Debug.Logs inside Setter/Getter would not print.
Now you have to create a custom inspector like such to take advantage of your getter/setter.
like I explained in the comment, you could take out the 'button' line in the inspector code (