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);
        }
        public void ReplaceScenePopulator(System.Type scenePopulatorType)
        {
            if (!scenePopulatorType.IsSubclassOf(typeof(SceneHunter)))
            {
                return;
            }

            Undo.SetCurrentGroupName("Scene Populator Change");
            int undoGroup = Undo.GetCurrentGroup();

            Undo.DestroyObjectImmediate(ScenePopulator.targetObject);

            ScenePopulator = new SerializedObject(AssetDatabaseExtensions.
                                                  FindOrCreateSubScriptableObject <SceneHunter>(TargetManager,
                                                                                                scenePopulatorType, "SceneHunter"));

            Undo.RegisterCreatedObjectUndo(ScenePopulator.targetObject, "Scene Populator Creation");

            Undo.CollapseUndoOperations(undoGroup);
            AssetDatabase.ImportAsset(SceneManagerAssetPath);
            SerializedManager.ApplyModifiedProperties();
            SerializedManager.Update();
        }