Created
October 7, 2014 06:50
-
-
Save zaki/6105d35fd4f64b5fd95c to your computer and use it in GitHub Desktop.
Unity helper - Jump to title scene on start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class Startup : MonoBehaviour | |
{ | |
private GameObject game = null; | |
[SerializeField] | |
private string startScene = "Title"; | |
public void Awake() | |
{ | |
game = GameObject.Find("Game"); | |
if (game == null) | |
{ | |
if (Application.loadedLevelName == startScene) | |
{ | |
game = new GameObject("Game"); | |
GameObject.DontDestroyOnLoad(game); | |
} | |
else | |
{ | |
Application.LoadLevel(startScene); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment