Exemple #1
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);
            }
        }
    }
Exemple #2
0
    public static void UpdateVariablesForVariable(ES2AutoSaveVariableInfo variable)
    {
        // Don't display variables of strings, enums, collections or value types.
        if (variable.type == typeof(string) || variable.type.IsEnum || variable.type.IsValueType || ES2EditorTypeUtility.IsCollectionType(variable.type))
        {
            return;
        }

        Type type = variable.type;

        FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance);

        // Add all of the variables to a List so we can see if any need deleting.
        List <ES2AutoSaveVariableInfo> variables = new List <ES2AutoSaveVariableInfo>();

        foreach (FieldInfo field in fields)
        {
            if (!ES2EditorTypeUtility.FieldIsSupportable(field) || typeof(Component).IsAssignableFrom(field.FieldType))
            {
                continue;
            }

            ES2AutoSaveVariableInfo newInfo = variable.GetVariableInfo(field.Name);
            if (newInfo == null)
            {
                newInfo = variable.AddVariableInfo(field.Name, field.FieldType, false);
            }
            variables.Add(newInfo);

            // Update type incase type has changed.
            newInfo.type = field.FieldType;

            if (newInfo.selected)
            {
                UpdateVariablesForVariable(newInfo);
            }
        }

        PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);

        foreach (PropertyInfo property in properties)
        {
            if (!ES2EditorTypeUtility.PropertyIsSupportable(property) || typeof(Component).IsAssignableFrom(property.PropertyType))
            {
                continue;
            }

            ES2AutoSaveVariableInfo newInfo = variable.GetVariableInfo(property.Name);
            if (newInfo == null)
            {
                newInfo = variable.AddVariableInfo(property.Name, property.PropertyType, true);
            }
            variables.Add(newInfo);

            // Update type incase type has changed.
            newInfo.type = property.PropertyType;

            if (newInfo.selected)
            {
                UpdateVariablesForVariable(newInfo);
            }
        }

        // Check if any variables need deleting.
        if (variable.variableIDs.Count != variables.Count)
        {
            List <string> variableIDsToDelete = new List <string>();
            for (int i = 0; i < variable.variableIDs.Count; i++)
            {
                string variableID     = variable.variableIDs[i];
                bool   deleteVariable = true;
                for (int j = 0; j < variables.Count; j++)
                {
                    if (variables[j].id == variableID)
                    {
                        deleteVariable = false;
                        break;
                    }
                }
                if (deleteVariable)
                {
                    variableIDsToDelete.Add(variableID);
                }
            }

            // Now remove the variable IDs we want to delete.
            foreach (string variableIDToDelete in variableIDsToDelete)
            {
                variable.DeleteVariableInfo(variableIDToDelete);
            }
        }
    }
Exemple #3
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);
    }
Exemple #4
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));
    }