So I looked high and far and maybe the answer just slipped my eyes somewhere.
In the editor I’m able to use a public Object variable and put a scene object/asset into it, run the game in the editor and get the name and the type of it (via a print - the type being a UnityEngine.SceneAsset).
When I decide to try the same on android/ios, I get a null-reference error on the variable.
Is the scene object/asset only available while in the editor? Is there any way I can keep a reference to a scene?
Would it be possible to drop the reference and change it to a string with the name instead on compile and how would I go about doing this?
for what else then loading a scene would you need a reference to it anyway? you can load it by name or by index (displayed in build settings after adding) is this not enough? with unity pro you can also load scenes additive to the current one but afaik there is no way to get the objects of the scene when it is not loaded. maybe describe what you want to do in more detail.
Yes I experienced a similar problem whilst writing a tool for a Racing Game. The reference to the object worked fine within the editor but when I built the app into any player the reference was lost. In the end I had to settle for still allowing the user to drag and drop scene references, but when that happens, behind the scenes it stores the name of the scene that was dragged and dropped as a string for scene load-up at runtime. This does mean that if the user changes the name of the scene you have to have some logic somewhere that catches it and refreshes the string OR say the user my re-drag and drop if making any changes. A bit of a pain but I could live with it.
exiguous:
The reason why somebody might need this is when building a tool or custom inspector for populating an object such as a game manager with a list of scenes. In my case I wanted the user to simply be able to drag the available race scenes into the slots in the game manager and be done with it. That way the user could change the name and/or index of the scene in the build and it wouldn’t matter or break in any way. So the idea was to make it less prone to error and easier to use. LIke I said, it worked great in the editor but not in the standalone player.