void RegisterWindow() { if (m_WindowRegistered) { return; } EditorWindow window = editorWindowModel.window; if (m_LiveReloadVisualTreeAssetTracker == null) { m_LiveReloadVisualTreeAssetTracker = new EditorWindowVisualTreeAssetTracker(this); m_Panel.m_LiveReloadStyleSheetAssetTracker = new LiveReloadStyleSheetAssetTracker(); // Live Reload is off by default for all Editor Windows, except for the Game View m_LiveReloadPreferenceKey = GetWindowLiveReloadPreferenceKey(editorWindowModel.window.GetType()); m_Panel.enableAssetReload = EditorPrefs.GetBool(m_LiveReloadPreferenceKey, editorWindowModel.window is GameView); } var root = window.rootVisualElement; root.visualTreeAssetTracker = m_LiveReloadVisualTreeAssetTracker; if (root.hierarchy.parent != m_Panel.visualTree) { AddRootElement(root); } m_Panel.getViewDataDictionary = window.GetViewDataDictionary; m_Panel.saveViewData = window.SaveViewData; m_Panel.name = window.GetType().Name; m_NotificationContainer.onGUIHandler = window.DrawNotification; UpdateStyleMargins(); m_WindowRegistered = true; SendInitializeIfNecessary(); }
public override void OnCreate(IWindowModel model) { try { base.OnCreate(model); m_LiveReloadVisualTreeAssetTracker = new EditorWindowVisualTreeAssetTracker(this); m_PlayModeDarkenColor = UIElementsUtility.editorPlayModeTintColor = EditorApplication.isPlayingOrWillChangePlaymode ? editorWindowModel.playModeTintColor : Color.white; EditorApplication.playModeStateChanged += PlayModeStateChangedCallback; AnimationMode.onAnimationRecordingStart += RefreshStylesAfterExternalEvent; AnimationMode.onAnimationRecordingStop += RefreshStylesAfterExternalEvent; m_NotificationContainer = new IMGUIContainer(); m_NotificationContainer.StretchToParentSize(); m_NotificationContainer.pickingMode = PickingMode.Ignore; m_OverlayContainer = new IMGUIContainer(); m_OverlayContainer.StretchToParentSize(); m_OverlayContainer.pickingMode = PickingMode.Ignore; RegisterImguiContainerGUICallbacks(); // Window is non-null when set by deserialization; it's usually null when OnCreate is called. if (editorWindowModel.window != null) { RegisterWindow(true); } } catch (Exception e) { // Log error to easily diagnose issues with panel initialization and then rethrow it. Debug.LogException(e); throw; } }