Пример #1
0
        public static SettingsProvider CreateAutoDarkModeSettingsProvider()
        {
            var provider = new SettingsProvider(SettingsPath, SettingsScope.User)
            {
                guiHandler = (searchContext) =>
                {
                    AutoDarkModeSettings.DrawSettings();
                },
                keywords = new HashSet <string>(new[] { "Skin", "Auto Dark Mode", "Professional", "Theme", "Scheme" })
            };

            return(provider);
        }
Пример #2
0
        private static void PerformAutoDarkMode()
        {
            ShowWelcomeMessage();

            var settings = AutoDarkModeSettings.Instance;

            if (!settings.EnableAutoDarkMode)
            {
                if (settings.ShowExtraLogs)
                {
                    Debug.Log(
                        $"Skipping Auto Dark Mode check since {nameof(settings.EnableAutoDarkMode)} is set to false!");
                }

                return;
            }

            if (settings.AutoFetch)
            {
                var timeSinceLastFetch = DateTime.UtcNow - settings.LastAutoFetchTime;
                if (timeSinceLastFetch > Constants.AutoFetchInterval)
                {
                    AutoDarkModeSettings.FetchAll(
                        () =>
                    {
                        settings.LastAutoFetchTime = DateTime.UtcNow;
                        EditorUtility.SetDirty(AutoDarkModeSettings.Instance);
                        SetEditorTheme();
                    },
                        () =>
                    {
                        if (settings.ShowExtraLogs)
                        {
                            Debug.Log("Failed to auto-fetch.");
                        }
                    }
                        );
                }
                else if (settings.ShowExtraLogs)
                {
                    Debug.Log(
                        $"Skipping auto fetching sunrise/sunset data since time of last fetch is only {timeSinceLastFetch.ToString()} old.");
                }
            }

            SetEditorTheme();
        }