Is it possible to script something using a Scene object?
I want to have a "Scene" object that I can have an array of, that serves as a sort of "Level List". I could get the names of the scenes, and call `Application.LoadLevel(MySceneObject);` to load a scene.
If that's not possible, can someone provide a suggestion of how I might go about scripting a dynamic scene loader? Say I have a folder in my Assets called "Scenes", and any scene inside there is a "level", but the user can choose which one they'd like to load from a GUI.
using UnityEngine;
using System.Collections.Generic;
public class LevelManager : MonoBehaviour
{
[SerializeField]
private Object[] levels;
private string[] levelNames;
`public string[] getLevels()
{
if (levelNames == null)
{
if (levels == null) levelNames = new string[0];
else
{
List tempLevels = new List();
foreach(Object o in levels)
{
if (o.GetType() == typeof(Object)) tempLevels.Add(o.name);
}
levelNames = tempLevels.ToArray();
}
}
return levelNames;
}
```
}
`
that'll let you assign scenes to an array, and will filter out anything which isn't only UnityEngine.Object - they you can grab the levels as strings with getLevels
you can then feed those into Application.LoadLevel