void OnEnable()
        {
            if (window == null)
            {
                CreateWindows();
                scenimaticGraph = null;                 // make sure the graph gets re-initialized
            }

            projectPrefsPrefix =
                PlayerSettings.companyName + "." + PlayerSettings.productName + ".";
            lastOpenScriptKey = projectPrefsPrefix + "LastOpenScript";

            if (rectStyle == null)
            {
                if (!CreateStyles())
                {
                    return;                     // couldn't create styles
                }
            }

            // open last edited scene
            if (EditorPrefs.HasKey(lastOpenScriptKey) &&
                !string.IsNullOrEmpty(EditorPrefs.GetString(lastOpenScriptKey)))
            {
                string lastOpenedScript = EditorPrefs.GetString(lastOpenScriptKey);
                if (!string.IsNullOrEmpty(lastOpenedScript) && File.Exists(lastOpenedScript))
                {
                    OpenScript(lastOpenedScript);
                }
            }
        }
        /// <summary>
        /// WARNING: This assumes the path has already been validated to exist.
        /// </summary>
        /// <param name="pathToScript"></param>
        private void OpenScript(string pathToScript)
        {
            StreamReader reader     = new StreamReader(pathToScript);
            string       fileString = reader.ReadToEnd();

            reader.Close();
            if (string.IsNullOrEmpty(fileString))
            {
                EditorPrefs.SetString(lastOpenScriptKey, "");
                Debug.Log("File is empty or invalid: " + pathToScript);
                return;
            }

            try
            {
                ScenimaticScript script = JsonUtility.FromJson <ScenimaticScript>(fileString);

                scenimaticGraph = new ScenimaticScriptGraph();
                if (window == null)
                {
                    CreateWindows();
                }
                window.position = new Rect(script.savedScreenPos, script.savedScreenSize);

                scenimaticGraph.Initialize(script);
            }
            catch (System.Exception e)
            {
                EditorPrefs.SetString(lastOpenScriptKey, "");
                Debug.LogError("Error parsing JSON in " + pathToScript + ":\n" + e.Message);
                return;
            }


            if (zoomer == null)
            {
                zoomer = new ZoomWindow();
            }


            zoomer.Reset(scenimaticGraph.zoomerSettings);

            EditorPrefs.SetString(lastOpenScriptKey, pathToScript);

            sceneFileName = Path.GetFileNameWithoutExtension(pathToScript);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            EditorUtility.SetDirty(this);
        }
        private void NewScene()
        {
            sceneFileName = null;

            var di = Directory.CreateDirectory(
                Directory.GetCurrentDirectory() + "/" + userScenimaticFolder);

            ScenimaticScript script = new ScenimaticScript("New Scene", CreateNewBranch(new Vector2(400, 0)));

            scenimaticGraph = new ScenimaticScriptGraph();
            scenimaticGraph.Initialize(script);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            EditorUtility.SetDirty(this);
        }