/// <summary>If the system isn't already set-up, this will instansiate the MobileInputPrefab and assign the static reference(s).</summary> public static void Initialise() { // If the MobileInputPrefab is already initialised, throw an Exception to tell the user they dun goofed. if (Initialised) { throw new InvalidOperationException("Mobile Input already initialised!"); } // Load the MobileInputPrefab and instantiate it, setting the instance. MobileInput prefabInstance = Resources.Load <MobileInput>("MobileInputPrefab"); instance = Instantiate(prefabInstance); // Change the instantiated object's name and mark it to not be destroyed. instance.gameObject.name = "Mobile Input"; DontDestroyOnLoad(instance.gameObject); }
/// <summary> /// if the system isnt already set up, this will instantiate the mobile input prefab and assign /// the static reference. /// </summary> public static void Initialise() { //if the mobile input is already initilised, throw an Exception to tell the user they done mucked up. if (Initialised) { throw new InvalidOperationException("Mobile Input already initilised"); } // Load the Mobile Input Prefab and instantiate it in MobileInput prefabInstance = Resources.Load <MobileInput>("MobileInputPrefab"); instance = Instantiate(prefabInstance); // Changed the instantiate objects name and mark it not to be destoryed instance.gameObject.name = "Mobile Input"; DontDestroyOnLoad(instance.gameObject); }
/// <summary> /// If system isn't already set up, this will instantiate mobile input prefab and assign the static reference. /// </summary> public static void Initialise() { //If the mobile input is already initialised, throw an Exception to tell the user they dun goofed. if (Initialised) { throw new InvalidOperationException("Joystick Input already initialised!"); } //Load the Mobile Input Prefab and instantiate it, setting the instance MobileInput prefabInstance = Resources.Load <MobileInput>("Mobile Input Prefab"); instance = Instantiate(prefabInstance); //Changed the instaniated object name and mark it to not be destroyed (Remove clone appearing in heirarchy for clarity) instance.gameObject.name = "Mobile Input"; DontDestroyOnLoad(instance.gameObject); }