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); } } } }
public ES2EditorRowCurve(ES2EditorColumn leftColumn, ES2EditorRow leftRow, ES2EditorColumn rightColumn, ES2EditorRow rightRow, Color color) { this.leftColumn = leftColumn; this.rightColumn = rightColumn; this.leftRow = leftRow; this.rightRow = rightRow; this.color = color; }
public ES2EditorRow(ES2EditorColumn column, string label, IES2Selectable obj, int rowNo, GUIStyle iconStyle, GUIStyle selectedIconStyle, int indentLevel = 0) { this.label = label; this.obj = obj; this.rowNo = rowNo; this.indentLevel = indentLevel; this.iconStyle = iconStyle; this.selectedIconStyle = selectedIconStyle; }
/* Gets the Rect of the column relative to the Horizontal layout */ private Rect GetColumnRect(ES2EditorColumn column) { // Add up the widths of all preceeding columns to get the column's left margin. float columnLeftMargin = GetColumnLeftMargin(column); Rect columnRect = column.GetRect(); RectOffset padding = ES2EditorWindow.instance.style.windowContentStyle.padding; return(new Rect(columnLeftMargin + padding.left, padding.top, columnRect.width, columnRect.height)); }
/* Gets the Rect of the row relative to the Horizontal layout */ private Rect GetRowRect(ES2EditorColumn column, ES2EditorRow row) { Rect columnRect = GetColumnRect(column); Rect rowRect = column.GetRowRect(row); return(new Rect(columnRect.xMin + rowRect.x, columnRect.yMin + rowRect.y, rowRect.width, rowRect.height)); }
private float GetColumnLeftMargin(ES2EditorColumn column) { // Sum all of previous column widths to get left margin of column. float leftMargin = 0; foreach (ES2EditorColumn col in columns) { if (col == column) { break; } leftMargin += col.width; } return(leftMargin); }
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); } } }
protected override void GetColumns() { columns = new ES2EditorColumn[0]; curves = new ES2EditorRowCurve[0]; // Get ES2AutoSaves at top of hierarchy. ES2AutoSave[] autoSaves = ES2EditorAutoSaveUtility.globalMgr.prefabArray; foreach (ES2AutoSave autoSavePrefab in autoSaves) { if (autoSavePrefab != null) { GetColumnsForAutoSave(autoSavePrefab, 0); } } if (columns.Length == 0) { GUIStyle centerStyle = new GUIStyle(ES2EditorWindow.instance.style.contentTextStyle); centerStyle.stretchHeight = true; centerStyle.alignment = TextAnchor.MiddleCenter; EditorGUILayout.LabelField("To enable Auto Save for a prefab, right-click it in Project and select \'Easy Save 2 / Enable Auto Save for Prefab\'.", centerStyle); return; } }
/* * 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); }
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)); }