private void OpenMainWindow() { // fade in if already open if (m_MainWindow != null) { m_MainWindow.MoveToBackground(config.IsInBackground); if (m_MainWindow.IsFadingOut) { m_MainWindow.FadeIn(); } if (config.ModulesChanged) { mainWindow.UpdateMainWindow(m_MainWindow); } return; } if (m_WindowPrefab == null || m_MainWindowObject != null) { return; } // create object Vector3 pos = new Vector3(config.MainWindowPos.x, config.MainWindowPos.y, MainCanvasUtil.MainCanvasRect.position.z); m_MainWindowObject = Instantiate(m_WindowPrefab); if (m_MainWindowObject == null) { return; } m_MainWindow = m_MainWindowObject.GetComponent <UI.DraggableWindow> (); if (m_MainWindow != null) { m_MainWindow.SetTitle(Localizer.Format("precisemaneuver_caption")); m_MainWindow.SetMainCanvasTransform(MainCanvasUtil.MainCanvasRect); mainWindow.ClearMainWindow(); mainWindow.UpdateMainWindow(m_MainWindow); // should be done before moving to background GUIComponentManager.ReplaceLabelsWithTMPro(m_MainWindowObject); m_MainWindow.MoveToBackground(config.IsInBackground); m_MainWindow.setWindowInputLock = SetWindow1InputLock; m_MainWindow.resetWindowInputLock = ResetWindow1InputLock; } GUIComponentManager.ProcessStyle(m_MainWindowObject); // set object as a child of the main canvas m_MainWindowObject.transform.SetParent(MainCanvasUtil.MainCanvas.transform); m_MainWindowObject.transform.position = pos; // do the scaling after the parent has been set ScaleMainWindow(); config.ListenToScaleChange(ScaleMainWindow); }
private void OpenKeybindingsWindow() { // fade in if already open if (m_KeybindingsWindow != null) { if (m_KeybindingsWindow.IsFadingOut) { m_KeybindingsWindow.FadeIn(); } return; } if (m_WindowPrefab == null || m_KeybindingsWindowObject != null) { return; } // create window object Vector3 pos = new Vector3(config.KeymapperWindowPos.x, config.KeymapperWindowPos.y, MainCanvasUtil.MainCanvasRect.position.z); m_KeybindingsWindowObject = Instantiate(m_WindowPrefab); if (m_KeybindingsWindowObject == null) { return; } // populate window m_KeybindingsWindow = m_KeybindingsWindowObject.GetComponent <UI.DraggableWindow> (); if (m_KeybindingsWindow != null) { m_KeybindingsWindow.SetTitle(Localizer.Format("precisemaneuver_keybindings_caption")); m_KeybindingsWindow.SetMainCanvasTransform(MainCanvasUtil.MainCanvasRect); hotkeys.FillKeymapperWindow(m_KeybindingsWindow); m_KeybindingsWindow.setWindowInputLock = SetWindow2InputLock; m_KeybindingsWindow.resetWindowInputLock = ResetWindow2InputLock; } GUIComponentManager.ProcessStyle(m_KeybindingsWindowObject); GUIComponentManager.ProcessLocalization(m_KeybindingsWindowObject); GUIComponentManager.ReplaceLabelsWithTMPro(m_KeybindingsWindowObject); // set object as a child of the main canvas m_KeybindingsWindowObject.transform.SetParent(MainCanvasUtil.MainCanvas.transform); m_KeybindingsWindowObject.transform.position = pos; }