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.

Ok… :slight_smile:

Found the solution myself.
Had off course to type cast and it worked.

So no need for virtual/override after all.