public void PopupNameTagChanger() { if (typingWindow != null) { typingWindow.Close(); } if (HighLogic.LoadedSceneIsEditor) { EditorFacility whichEditor = EditorLogic.fetch.ship.shipFacility; if (!(Career.CanTagInEditor(whichEditor))) { var formattedString = string.Format("The {0} requires an upgrade to assign name tags", whichEditor); ScreenMessages.PostScreenMessage(formattedString, 6, ScreenMessageStyle.UPPER_CENTER); return; } } // Make a new instance of typingWindow, replacing the existing one if there was one: KOSNameTagWindow oldTypingWindow = gameObject.GetComponent <KOSNameTagWindow>(); if (oldTypingWindow != null) { Destroy(oldTypingWindow); } typingWindow = gameObject.AddComponent <KOSNameTagWindow>(); typingWindow.Invoke(this, nameTag); }
public void PopupNameTagChanger() { if (typingWindow != null) { typingWindow.Close(); } if (HighLogic.LoadedSceneIsEditor) { EditorFacility whichEditor = EditorLogic.fetch.ship.shipFacility; if (!(Career.CanTagInEditor(whichEditor))) { var formattedString = string.Format("The {0} requires an upgrade to assign name tags", whichEditor); ScreenMessages.PostScreenMessage(formattedString, 6, ScreenMessageStyle.UPPER_CENTER); return; } } GameObject gObj = new GameObject("nametag", typeof(KOSNameTagWindow)); DontDestroyOnLoad(gObj); typingWindow = (KOSNameTagWindow)gObj.GetComponent(typeof(KOSNameTagWindow)); typingWindow.Invoke(this, nameTag); }