Ejemplo n.º 1
0
        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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private static void OpenWindow(Action openWindow, AdditionalOnWindowOpened additionalOnWindowOpen, bool isFirstRun)
 {
     openWindow();
     additionalOnWindowOpen?.Invoke(isFirstRun);
 }
Ejemplo n.º 3
0
        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;
        }