Question by
Aravind_Shankar · Jun 27, 2016 at 09:52 PM ·
inspectorpublic variablebinding
How do I bind the value of a public variable from the inspector to some other variable/constant?
Say I have a public integer variable for some script (or even some built-in component). The Unity inspector allows me to give any value I want, but that is essentially hard-coding the value.
So if I can define that value in a Constants class elsewhere and reference it as I need, I can assign the variable to the constant value in code, but how do I do that from the inspector? Like, instead of typing in just "2", I want to select "Constants.ABC" when I assign the value for that variable, from the inspector. And I should be able to go back to typing "2" if I need to. Is this possible, preferably without a custom editor script?
And by extension, can I do that sort of binding with another variable instead of a constant? If so, how?
Comment