Esempio n. 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;
                }
            }
        }
Esempio n. 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);
        }
Esempio n. 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));
        }
Esempio n. 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);
        }