protected override void Start() { CNVCommNetScenario.Instance = this; UnityEngine.Debug.Log("CommNet Scenario loading ..."); //Replace the CommNet user interface CommNetUI ui = FindObjectOfType <CommNetUI>(); // the order of the three lines is important CustomCommNetUI = gameObject.AddComponent <CNVCommNetUI>(); // gameObject.AddComponent<>() is "new" keyword for Monohebaviour class UnityEngine.Object.Destroy(ui); //Replace the TelemetryUpdate TelemetryUpdate tel = TelemetryUpdate.Instance; //only appear in flight CommNetUIModeButton cnmodeUI = FindObjectOfType <CommNetUIModeButton>(); //only appear in tracking station; initialised separately by TelemetryUpdate in flight if (tel != null && HighLogic.LoadedSceneIsFlight) { TelemetryUpdateData tempData = new TelemetryUpdateData(tel); UnityEngine.Object.DestroyImmediate(tel); //seem like UE won't initialise CNCTelemetryUpdate instance in presence of TelemetryUpdate instance CustomCommNetTelemetry = gameObject.AddComponent <CNVTelemetryUpdate>(); CustomCommNetTelemetry.copyOf(tempData); } else if (cnmodeUI != null && HighLogic.LoadedScene == GameScenes.TRACKSTATION) { CustomCommNetModeButton = cnmodeUI.gameObject.AddComponent <CNVCommNetUIModeButton>(); CustomCommNetModeButton.copyOf(cnmodeUI); UnityEngine.Object.DestroyImmediate(cnmodeUI); } UnityEngine.Debug.Log("CommNet Scenario loading done! "); }
public void copyOf(TelemetryUpdateData stockTUData) { //replace the mode button var customModeButton = stockTUData.modeButton.gameObject.AddComponent <CNVCommNetUIModeButton>(); customModeButton.copyOf(stockTUData.modeButton); UnityEngine.Object.DestroyImmediate(stockTUData.modeButton); this.modeButton = customModeButton; this.NOSIG = stockTUData.NOSIG; this.NOEP = stockTUData.NOEP; this.BLK = stockTUData.BLK; this.AUP = stockTUData.AUP; this.ADN = stockTUData.ADN; this.EP0 = stockTUData.EP0; this.EP1 = stockTUData.EP1; this.EP2 = stockTUData.EP2; this.CK1 = stockTUData.CK1; this.CK2 = stockTUData.CK2; this.CK3 = stockTUData.CK3; this.CP1 = stockTUData.CP1; this.CP2 = stockTUData.CP2; this.CP3 = stockTUData.CP3; this.SS0 = stockTUData.SS0; this.SS1 = stockTUData.SS1; this.SS2 = stockTUData.SS2; this.SS3 = stockTUData.SS3; this.SS4 = stockTUData.SS4; this.arrow_icon = stockTUData.arrow_icon; this.firstHop_icon = stockTUData.firstHop_icon; this.lastHop_icon = stockTUData.lastHop_icon; this.control_icon = stockTUData.control_icon; this.signal_icon = stockTUData.signal_icon; this.firstHop_tooltip = stockTUData.firstHop_tooltip; this.arrow_tooltip = stockTUData.arrow_tooltip; this.lastHop_tooltip = stockTUData.lastHop_tooltip; this.control_tooltip = stockTUData.control_tooltip; this.signal_tooltip = stockTUData.signal_tooltip; }