|
Post by baroquedub on Jul 27, 2017 21:36:39 GMT
I'm modifying your NGUI World Variable Listener script to target a slider value instead of a text component. All works great except that I can't seem to get the variable's startingValue, or intMaxValue/floatManValue in order to normalise I'd want to do something along the lines of: InGameWorldVariable _variable = WorldVariableTracker.GetWorldVariable(variableName);
int _maxValueInt = _variable.startingValue;
_slider.value = newValue / _maxValueInt;
but only the WorldVariable class seems to be able to access the startingValue property. Is there a way of getting it without hard-coding it in the listener? Also, does the listener have a reference to the variable itself? (i.e. is the first line of my pseudocode really necessary? or to put it another way why does your WorldVariableListner example class need: public string variableName = ""; If it's hooked up to receive new values, why does it not know the variable that this value belongs to? Thanks
|
|
|
Post by DarkTonic Dev on Jul 28, 2017 1:33:07 GMT
No the Listener doesn't have a reference to the WV. It's the other way around. The WV has a reference to the Listener only. The Listener will give you its starting value the first time it calls Update. Sounds like you need more functionality in a Listener, and WorldVariableTracker will pass it on to the Listener, right?
Or, you could directly reference the WorldVariable class itself (from the Hierarchy) and pull that stuff from there directly. Try that.
|
|