- Home /
Function GUI with a Return value
Hi,
Is it possible to make an function that returns the GUI elements inside that function when called from main OnGUI?
Got a script called 'GameItems' which is the base game item class generator, then I have 'sub-scripts' which inherits from 'GameItems'.
I know how to make an virtual function and an override function with strings, but is this possible doing so with GUI elements?
GameItem script:
public virtual GUI Stats() {
return null;
}
sub-scripts:
public override GUI Stats() {
GUI.Label(new Rect(20, 193, 128, 30), "Stat1");
GUI.Label(new Rect(160, 193, 128, 30), "Stat1Value");
return GUI();
}
Thanks.
Answer by ZharaX · Aug 25, 2014 at 04:31 AM
Ok... :)
Found the solution myself. Had off course to type cast and it worked.
So no need for virtual/override after all.
Your answer
Follow this Question
Related Questions
A NullReferenceException even though I'm sure that object was assigned? 1 Answer
Modifying default Inspector GUI creator 3 Answers
How to call child overide function? 1 Answer
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer