Ejemplo n.º 1
0
    protected override void GetColumns()
    {
        columns = new ES2EditorColumn[0];
        curves  = new ES2EditorRowCurve[0];

        if (ES2EditorAutoSaveUtility.mgr == null)
        {
            GUIStyle style = new GUIStyle(ES2EditorWindow.instance.style.contentButtonStyle);
            // Stretch style to full height.
            style.stretchWidth  = true;
            style.stretchHeight = true;

            if (GUILayout.Button("Click to enable Auto Save for this scene", ES2EditorWindow.instance.style.contentButtonStyle))
            {
                ES2EditorAutoSaveUtility.AddManagerToScene();
            }
            return;
        }

        // Get ES2AutoSaves at top of hierarchy.
        ES2AutoSave[] autoSaves = ES2EditorAutoSaveUtility.mgr.sceneObjects;

        foreach (ES2AutoSave autoSave in autoSaves)
        {
            if (autoSave != null && autoSave.transform != null)
            {
                if (autoSave.transform.parent == null)
                {
                    GetColumnsForAutoSave(autoSave, 0);
                }
            }
        }
    }
Ejemplo n.º 2
0
 public ES2EditorAutoSaveScene() : base()
 {
     if (ES2EditorAutoSaveUtility.AutomaticallyRefreshSceneAutoSaves)
     {
         ES2EditorAutoSaveUtility.RefreshSceneAutoSaves();
     }
 }
Ejemplo n.º 3
0
    public void OnHierarchyChange()
    {
        if (!ES2EditorAutoSaveUtility.AutomaticallyRefreshSceneAutoSaves)
        {
            return;
        }

        if (sceneAutoSavesMightNeedUpdating)
        {
            ES2EditorAutoSaveUtility.RefreshSceneAutoSaves();
            sceneAutoSavesMightNeedUpdating = false;
        }
        else
        {
            sceneAutoSavesMightNeedUpdating = true;
        }
    }
Ejemplo n.º 4
0
    protected void GetColumnsForAutoSave(ES2AutoSave autoSave, int hierarchyDepth)
    {
        ES2EditorColumn column = GetColumn(0);
        ES2EditorRow    row    = column.AddRow(autoSave.gameObject.name, autoSave, ES2EditorWindow.instance.style.saveButtonStyle, ES2EditorWindow.instance.style.saveButtonSelectedStyle, hierarchyDepth);

        if (autoSave.selected)
        {
            if (autoSave.selectionChanged)
            {
                ES2EditorAutoSaveUtility.UpdateAutoSave(autoSave);
            }

            GetComponentsColumnForAutoSave(autoSave, column, row);
        }

        if (autoSave.buttonSelected && autoSave.buttonSelectionChanged)
        {
            // Add support for any Components which are currently unsupported.
            Component[] components = autoSave.GetComponents <Component>();
            foreach (Component c in components)
            {
                // Handle unassigned components.
                if (c == null)
                {
                    continue;
                }
                // If this Component isn't currently supported, add support for it and isn't an ES2AutoSave.
                if (!ES2EditorTypeUtility.TypeIsSupported(c.GetType()) &&
                    !typeof(ES2AutoSave).IsAssignableFrom(c.GetType()) &&
                    !typeof(ES2AutoSaveManager).IsAssignableFrom(c.GetType()))
                {
                    ES2EditorTypeUtility.AddType(c.GetType());
                }
            }
        }

        foreach (Transform t in autoSave.transform)
        {
            ES2AutoSave child = ES2AutoSave.GetAutoSave(t.gameObject);
            if (child != null)
            {
                GetColumnsForAutoSave(child, hierarchyDepth + 1);
            }
        }
    }
Ejemplo n.º 5
0
    public void Draw()
    {
        ES2EditorWindowStyle style = ES2EditorWindow.instance.style;

        // Don't allow Auto Save to be modified when playing.
        if (Application.isPlaying)
        {
            EditorGUILayout.BeginHorizontal(style.windowContentStyle);
            GUIStyle centerStyle = new GUIStyle(style.contentTextStyle);
            centerStyle.stretchHeight = true;
            centerStyle.alignment     = TextAnchor.MiddleCenter;
            EditorGUILayout.LabelField("Auto Save can not be modified in Play mode.", centerStyle);
            EditorGUILayout.EndHorizontal();
            return;
        }

        // If a manager hasn't been added to the scene, require that it is added.
        ES2AutoSaveManager mgr = ES2EditorAutoSaveUtility.mgr;

        if (mgr == null)
        {
            EditorGUILayout.BeginVertical(style.windowContentStyle);
            if (ES2EditorUtility.Button("Click to enable Auto Save for this scene"))
            {
                ES2EditorAutoSaveUtility.AddManagerToScene();
            }
            EditorGUILayout.EndVertical();
            return;
        }

        Undo.RecordObject(mgr, "Auto Save Settings");

        EditorGUILayout.BeginVertical(style.windowContentStyle);

        EditorGUILayout.BeginHorizontal(style.sectionStyle);
        mgr.loadEvent = (ES2AutoSaveManager.LoadEvent)ES2EditorUtility.EnumField("When to Load", mgr.loadEvent);
        mgr.saveEvent = (ES2AutoSaveManager.SaveEvent)ES2EditorUtility.EnumField("When to Save", mgr.saveEvent);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal(style.sectionStyle);
        mgr.filePath = ES2EditorUtility.TextField("Filename/Path", mgr.filePath);
        mgr.tag      = ES2EditorUtility.TextField("Tag", mgr.tag);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginVertical(style.sectionStyle);

        mgr.encrypt = ES2EditorUtility.Toggle("Use Encryption", mgr.encrypt);


        if (mgr.encrypt)
        {
            EditorGUILayout.BeginHorizontal(style.indentStyle);
            mgr.encryptionPassword = ES2EditorUtility.TextField("Encryption Password", mgr.encryptionPassword);
            mgr.encryptionType     = (ES2Settings.EncryptionType)ES2EditorUtility.EnumField("Encryption Type", mgr.encryptionType);
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginHorizontal(style.sectionStyle);

        mgr.deletePrefabsOnLoad = ES2EditorUtility.Toggle("Delete Instantiated Prefabs on Load", mgr.deletePrefabsOnLoad);
        mgr.convertPrefabsToSceneObjectsOnImport = ES2EditorUtility.Toggle("Convert Prefabs To Scene Objects Upon Dragging Into Scene", mgr.convertPrefabsToSceneObjectsOnImport);

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal(style.sectionStyle);

        bool autoSaveComponentsAreHidden = ES2EditorAutoSaveUtility.AutoSaveComponentsAreHidden();

        if (ES2EditorUtility.Toggle("Hide Auto Save Components in Editor", autoSaveComponentsAreHidden) != autoSaveComponentsAreHidden)
        {
            ES2EditorAutoSaveUtility.ToggleHideAutoSaveComponents();
        }

        ES2EditorAutoSaveUtility.AutomaticallyRefreshSceneAutoSaves = ES2EditorUtility.Toggle("Automatically refresh Auto Saves when window is open", ES2EditorAutoSaveUtility.AutomaticallyRefreshSceneAutoSaves);

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal(style.sectionStyle);
        if (ES2EditorUtility.Button("Refresh Auto Saves in Scene"))
        {
            ES2EditorAutoSaveUtility.RefreshSceneAutoSaves();
        }

        if (ES2EditorUtility.Button("Refresh Auto Saves in Prefabs"))
        {
            ES2EditorAutoSaveUtility.RefreshPrefabAutoSaves();
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();

        if (ES2EditorUtility.Button("Remove Auto Save from Scene"))
        {
            ES2EditorAutoSaveUtility.RemoveAutoSaveFromScene();
        }
        if (ES2EditorUtility.Button("Remove Auto Save from all Prefabs"))
        {
            ES2EditorAutoSaveUtility.RemoveAutoSaveFromAllPrefabs();
        }
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.EndVertical();
    }
Ejemplo n.º 6
0
 public ES2EditorAutoSaveHierarchy()
 {
     SceneView.onSceneGUIDelegate += GetEvent;
     ES2EditorAutoSaveUtility.RefreshSceneAutoSaves();
 }
Ejemplo n.º 7
0
    /*
     *  Displays all Properties for the given VariableInfo (which can also be a ComponentInfo.
     *  Finish GetVariablesColumn Method
     */
    private ES2EditorColumn GetVariablesColumnForVariable(ES2AutoSaveVariableInfo info, ES2EditorColumn previousColumn, ES2EditorRow previousRow, int columnIndex)
    {
        ES2EditorColumn column = GetColumn(columnIndex);

        ES2EditorRow firstRow = null;

        foreach (string variableID in info.variableIDs)
        {
            ES2AutoSaveVariableInfo variable = info.autoSave.GetCachedVariableInfo(variableID);
            ES2EditorRow            row      = column.AddRow(variable.name, variable, ES2EditorWindow.instance.style.saveButtonStyle, ES2EditorWindow.instance.style.saveButtonSelectedStyle);
            if (firstRow == null)
            {
                firstRow = row;
            }

            SetTooltips(variable, row);

            // If this variable was just selected ...
            if (variable.buttonSelectionChanged && variable.buttonSelected)
            {
                // ... select all of it's ancestors.
                SelectParentButtons(variable);

                // If this type isn't currently supported, add support for it.
                if (!ES2EditorTypeUtility.TypeIsSupported(variable.type))
                {
                    ES2EditorTypeUtility.AddType(variable.type);
                }
            }

            // If the button for the Auto Save of this Component was deselected, deselect this one too.
            if (info.buttonSelectionChanged && !info.buttonSelected)
            {
                row.obj.buttonSelected = false;
            }

            if (variable.selected)
            {
                // If we just selected this variable, update it.
                if (variable.selectionChanged && variable.selected)
                {
                    ES2EditorAutoSaveUtility.UpdateVariablesForVariable(variable);
                }

                GetVariablesColumnForVariable(variable, column, row, columnIndex + 1);
            }
        }

        if (info.variableIDs.Count == 0)
        {
            //firstRow = column.AddRow("No supportable types", null, null, null);
            return(null);
        }

        // Add seperator row.
        column.AddRow("", null, null, null);

        ArrayUtility.Add(ref curves, new ES2EditorRowCurve(previousColumn, previousRow, column, firstRow, info.autoSave.color));

        return(column);
    }
Ejemplo n.º 8
0
    protected void GetComponentsColumnForAutoSave(ES2AutoSave autoSave, ES2EditorColumn previousColumn, ES2EditorRow previousRow)
    {
        ES2EditorColumn column = GetColumn(1);

        ES2EditorRow firstRow = null;

        // GameObject instance variables. These have to be handled seperately.
        ES2AutoSaveVariableInfo[] instanceVariables = new ES2AutoSaveVariableInfo[] { autoSave.activeSelfVariable, autoSave.parentVariable, autoSave.nameVariable, autoSave.tagVariable, autoSave.layerVariable };
        for (int i = 0; i < instanceVariables.Length; i++)
        {
            ES2AutoSaveVariableInfo variable = instanceVariables[i];

            ES2EditorRow newRow = column.AddRow(variable.name, variable, ES2EditorWindow.instance.style.saveButtonStyle, ES2EditorWindow.instance.style.saveButtonSelectedStyle, 0);
            if (firstRow == null)
            {
                firstRow = newRow;
            }

            SetTooltips(variable, newRow);

            // If this component was selected, also select it's Auto Save.
            if (variable.buttonSelectionChanged && variable.buttonSelected)
            {
                autoSave.buttonSelected = true;
            }

            // If the button for the Auto Save of this Component was deselected, deselect this one too.
            if (autoSave.buttonSelectionChanged && !autoSave.buttonSelected)
            {
                newRow.obj.buttonSelected = false;
            }

            // Get variables column if this Component is selected.
            if (variable.selected)
            {
                // Update this component if we've only just selected this Component.
                if (variable.selectionChanged)
                {
                    ES2EditorAutoSaveUtility.UpdateVariablesForVariable(variable);
                }

                GetVariablesColumnForVariable(variable, column, newRow, 2);
            }
        }

        // Create rows for Component's attached to this GameObject.
        for (int i = 0; i < autoSave.components.Count; i++)
        {
            ES2AutoSaveComponentInfo componentInfo = autoSave.components[i];
            ES2EditorRow             newRow        = column.AddRow(componentInfo.name, componentInfo, ES2EditorWindow.instance.style.saveButtonStyle, ES2EditorWindow.instance.style.saveButtonSelectedStyle, 0);
            if (firstRow == null)
            {
                firstRow = newRow;
            }

            SetTooltips(componentInfo, newRow);

            // If this component was selected ...
            if (componentInfo.buttonSelectionChanged && componentInfo.buttonSelected)
            {
                // ... also select it's Auto Save.
                autoSave.buttonSelected = true;
                // If this Component isn't currently supported, add support for it.
                if (!ES2EditorTypeUtility.TypeIsSupported(componentInfo.type))
                {
                    ES2EditorTypeUtility.AddType(componentInfo.type);
                }
            }

            // If the button for the Auto Save of this Component was deselected, deselect this one too.
            if (autoSave.buttonSelectionChanged && !autoSave.buttonSelected)
            {
                newRow.obj.buttonSelected = false;
            }

            // Get variables column if this Component is selected.
            if (componentInfo.selected)
            {
                // Update this component if we've only just selected this Component.
                if (componentInfo.selectionChanged)
                {
                    ES2EditorAutoSaveUtility.UpdateVariablesForVariable(componentInfo);
                }

                GetVariablesColumnForVariable(componentInfo, column, newRow, 2);
            }
        }

        if (autoSave.components.Count == 0)
        {
            firstRow = column.AddRow("No supportable Components", null, null, null, 0);
        }

        // Add seperator row.
        column.AddRow("", null, null, null);
        // Add curve line between columns.
        ArrayUtility.Add(ref curves, new ES2EditorRowCurve(previousColumn, previousRow, column, firstRow, autoSave.color));
    }
Ejemplo n.º 9
0
 public ES2EditorAutoSavePrefabs() : base()
 {
     ES2EditorAutoSaveUtility.RefreshPrefabAutoSaves();
 }