Hi there,
Sorry if this is a naff question, but I was making a level changing script that I can reuse for different scenes and I’m wondering if it is possible to make a scene into a variable like you might a GameObject?
Thanks
Pete
Wouldn’t make sense as you can’t load the scene file through the file reference. You can only load scenes present in the build screen (or an asset bundle). if present in the app itself then through its level index or alternatively its name.
Okay cool, yeah that makes sense.
Thanks.
In my latest title I have a series of “WANTED” posters. Once a level is completed, the same screen opens up but with a grayed out version of the first image and instead of the word “Wanted” sliding into view, the word “Busted” slides into view.
At first I thought I should just make an array of Texture2D and in code decide which image to load. But being a project for the iphone, forcing people to wait while ALL the posters for ALL the levels are loaded into the scene before the 2 second animation begins (after 2 seconds of text animation they get a button to continue)… this simply wasn’t an option…
So I figured I would make it contain only the Busted of the previous and the Wanted for the next… But that would require me to place all posters in a Resources folder and I want to stay away from the Resources folders as much as possible…
Then I hit upon the idea, just make it show an image and a message and when the user hits the continue button, load another scene with different images assigned to it or load the next lever or high scores screen or whatever the user chose. Since the entire level has only 1 object and that object only has 2 images assigned to it it loads fast as hell (and serves to reset all variables also so bonus!). So simply create 20 scenes, each being either a Wanted or Busted scene for a specific level. Each one is created by hitting Apple-D in the inspector and then just dragging the new images over. Simple, easy and fast to build/ load.
The only problem is: “How do I tell each scene which scene to load next?”
Solution: Simply expose a String in the script and use the name of the scene file as the value and hit save. Now, as long as you include the scene in the build settings, you now have a psuedo-link to any level in your build settings