void OnDestroy() //called after OnApplicationQuit for some insane reason. { if (instance == this) { //Log("Unlinked SenseGlove Connections from " + this.name); debugElement = null; debugUIElement = null; instance = null; //clear my refernce to the instance, so another can take its place. } }
/// <summary> Create a new instance of SG_Connection in the Scene, if we don't have on e yet. </summary> public static void SetupConnections() { //Log("Ensuring we have some form of connections available to us!"); if (instance == null) { GameObject connectionObj = new GameObject("[SG Connections]"); //Log("Created a new instance!"); instance = connectionObj.AddComponent <SG_Connections>(); } }
//---------------------------------------------------------------------------------------------------- // Monobehaviour void Awake() { if (instance == null) //when created and in the scene, be sure to add one of these. { //Log("Linked SenseGlove Connections to " + this.name); instance = this; debugElement = this.debugText; debugUIElement = this.debugUIText; Initialize(); //initialized me! } }