- Home /
Make variable to select scene?
Is it possible to create a variable to select a scene, so i Don't have to write a different script for each scene?
Such as something similar to below:
var selectscene = Scene;
Thanks
Answer by Jean-Fabre · Mar 21, 2011 at 07:53 AM
Hi,
I think I understand what you actually want. You want the inspector to list all the scenes, like it can list all the transforms or all the gameObjects. Right?
Currently I don't think it's possible or know how to do it. I'll give you the way I currently deal with this:
You can load a level by its ID or by its name, so if you write something like this, you'll be ok.
The problem is that you'll have to know your level names and if you change one, you'll have to go and upadte each script that reference that level.
public var LevelName ="My level name";
public function LoadLevel(){ Application.LoadLevel(LevelName); }
Bye,
Jean
ok, thanks. i didn't knmow if it was possible, and was just trying to reduce my number of scripts.
Answer by Uriel_96 · Mar 21, 2011 at 03:15 AM
you can just use static like this example http://answers.unity3d.com/questions/41676/best-way-to-send-variables-data-to-other-scripts/41701#41701 and using static is like do a variable that is accessible for all the scripts
That's not exactly what i was looking for. I want a single script that i can change the scene it selects in the inspector and use that later in the same script.