private static void HandleEditorUpdate(Action openWindow, string getUpdatesUrl, AdditionalOnWindowOpened additionalOnWindowOpen = null) { if (!EditorApplication.isPlayingOrWillChangePlaymode) { var defaultShowAtStartupPreferenceDefinition = ProductPreferenceBase.CreateDefaultShowOptionPreferenceDefinition(); ProductPreferenceBase.StartupShowMode showWindowOnStartupMode = ProductPreferenceBase.StartupShowMode.Never; if (!EditorPrefs.HasKey(defaultShowAtStartupPreferenceDefinition.PreferenceKey)) //first run / import { showWindowOnStartupMode = (ProductPreferenceBase.StartupShowMode)defaultShowAtStartupPreferenceDefinition.DefaultValue; defaultShowAtStartupPreferenceDefinition.SetEditorPersistedValue(showWindowOnStartupMode); OpenWindow(openWindow, additionalOnWindowOpen, true); if (showWindowOnStartupMode != ProductPreferenceBase.StartupShowMode.Never) { GetUpdates(openWindow, getUpdatesUrl); } } else { if (Time.realtimeSinceStartup < 10) //static ctor will also be executed on script changes / domain reload, make sure editor is just turned on { showWindowOnStartupMode = (ProductPreferenceBase.StartupShowMode)defaultShowAtStartupPreferenceDefinition.GetEditorPersistedValueOrDefault(); if (showWindowOnStartupMode == ProductPreferenceBase.StartupShowMode.Always) { OpenWindow(openWindow, additionalOnWindowOpen, false); } if (showWindowOnStartupMode != ProductPreferenceBase.StartupShowMode.Never) { GetUpdates(openWindow, getUpdatesUrl); } } } } }
private static void OpenWindow(Action openWindow, AdditionalOnWindowOpened additionalOnWindowOpen, bool isFirstRun) { openWindow(); additionalOnWindowOpen?.Invoke(isFirstRun); }
protected static void HandleUnityStartup(Action openWindow, string getUpdatesUrl, AdditionalOnWindowOpened additionalOnWindowOpen = null) { EditorApplication.CallbackFunction handleEditorUpdate = null; handleEditorUpdate = () => { HandleEditorUpdate(openWindow, getUpdatesUrl, additionalOnWindowOpen); EditorApplication.update -= handleEditorUpdate; }; EditorApplication.update += handleEditorUpdate; }