Пример #1
0
        static void OnBeforeSceneLoadRuntimeMethod()
        {
            SettingsObject settings = SettingsHandler.Load();

            if (!settings.checkBeforePlay)
            {
                return;
            }

            Session session = new Session();

            session.Refresh();
            for (int i = 0; i < session.fields.Count; i++)
            {
                //Todo: Make this not an abomination.
                Field field     = session.fields[i];
                bool  confirmed = (field.preCheck == Field.Check.ConfirmedValue ||
                                   ((field.allowNull || !settings.warnIfNull) && field.preCheck == Field.Check.ConfirmedNull));
                if (!confirmed)
                {
                    EditorApplication.ExitPlaymode();
                    EditorApplication.playModeStateChanged += Changed;
                    break;
                }
            }
        }
Пример #2
0
        public static SettingsObject Load()
        {
            if (!File.Exists(settingsPath))
            {
                if (!Directory.Exists("UserSettings/"))
                {
                    Directory.CreateDirectory("UserSettings/");
                }

                File.WriteAllText(settingsPath, JsonUtility.ToJson(new SettingsObject()));
            }

            SettingsObject settings = null;

            try
            {
                settings = JsonUtility.FromJson <SettingsObject>(File.ReadAllText(settingsPath));
            }
            catch (Exception ex)
            {
                Debug.LogError($"Weren't able to parse Compoopulate user settings at {settingsPath}.\n{ex}");
            }

            return(settings);
        }
Пример #3
0
        public static void Write(SettingsObject settings)
        {
            if (!File.Exists(settingsPath))
            {
                if (!Directory.Exists("UserSettings/"))
                {
                    Directory.CreateDirectory("UserSettings/");
                }
            }

            File.WriteAllText(settingsPath, JsonUtility.ToJson(settings));
        }
Пример #4
0
        private void OnEnable()
        {
            settings     = SettingsHandler.Load();
            session      = new Session(); //Debug.Log("Created new session");
            titleContent = new GUIContent("Compopulate");

            InitialiseToolbar();
            rootVisualElement.RegisterCallback <KeyDownEvent>(OnKeyDown, TrickleDown.TrickleDown);
            InitiateListView();
            RefreshSession();
            Undo.undoRedoPerformed += OnUndoRedo;

            rootVisualElement.RegisterCallback <MouseUpEvent>(HandleRightClick);
        }