private void InitializeDefaults()
        {
            SceneManagerAssetPath = AssetDatabase.GetAssetPath(SerializedManager.targetObject);

            bool wasCreated = false;

            AssetFilter assetFilter = AssetDatabaseExtensions.
                                      FindOrCreateSubScriptableObject <AssetFilter>(SceneManagerAssetPath, "SceneFilter", out wasCreated);

            if (wasCreated)
            {
                assetFilter.IncludeIfNoMatch = true;
            }

            SerializedSceneFilter = new SerializedObject(assetFilter);

            SceneHunter sceneHunter = AssetDatabaseExtensions.
                                      GetFirstSubAssetOf <SceneHunter>(SceneManagerAssetPath);

            if (sceneHunter == null)
            {
                sceneHunter = AssetDatabaseExtensions.
                              CreateSubScriptableObject <UnitySceneHunter>(SceneManagerAssetPath, "SceneHunter");
            }

            ScenePopulator = new SerializedObject(sceneHunter);

            SceneNodes = AssetDatabaseExtensions.
                         FindOrCreateSubScriptableObject <SceneNodeCollection>(SceneManagerAssetPath, "SceneNodes", out wasCreated);

            if (wasCreated)
            {
                SceneNodes.SceneManager = TargetManager;
            }

            SceneNodes.PopulateSceneInfos();

            SceneNodesObject = new SerializedObject(SceneNodes);
            SceneNodesProp   = SceneNodesObject.FindProperty("sceneNodes");

            if (AssetDatabaseExtensions.GetSubAssetsOfType <SceneVariableContainer>(TargetManager).Count() == 0)
            {
                TargetManager.SceneVariables.name = "ManagerVariables";
                AssetDatabase.AddObjectToAsset(TargetManager.SceneVariables, TargetManager);
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(TargetManager));
            }
            SerializedManager.ApplyModifiedProperties();

            ScenesProp       = SerializedManager.FindProperty("scenes");
            EntrySceneIdProp = SerializedManager.FindProperty("entrySceneId");
            AnyScenesProp    = SerializedManager.FindProperty("anyScene");

            UseOnPlayProp = SerializedManager.FindProperty("useOnPlay");
            GoToOnPlay    = SerializedManager.FindProperty("goToOnPlay");

            SerializedVariables = new SerializedSceneVariableCollection(TargetManager.SceneVariables);
        }
        private void VariableCollectionEditor_OnVariableNameChanged(object sender,
                                                                    ValueChangedEventArgs <string> e)
        {
            IEnumerable <ScriptableObject> subAssets = AssetDatabaseExtensions.
                                                       GetSubAssetsOfType <ScriptableObject>(sceneManager);

            ScriptableObject foundSubAsset = subAssets.Where(
                (x) => x.name == e.OldValue).FirstOrDefault();

            if (foundSubAsset == null)
            {
                Debug.Log("Failed to rename variable");
                return;
            }

            foundSubAsset.name = e.NewValue;
            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(sceneManager));
        }