public GridState(string name, GridState copyFrom) { this.name = name; this.gridlineColor = copyFrom.gridlineColor; this.gridSize = copyFrom.gridSize; this.gridlineCount = copyFrom.gridlineCount; this.gridAlignment = copyFrom.gridAlignment; this.gridPos = copyFrom.gridPos; this.gridShiftAxis1 = copyFrom.gridShiftAxis1; this.gridShiftAxis2 = copyFrom.gridShiftAxis2; }
public void Draw(GridEditorSettings settings) { string tempStr; Color tempClr; float tempFloat; int tempInt; GridEditor.GridAlignment tempEnum; EditorGUI.BeginChangeCheck(); tempStr = EditorGUILayout.TextField("Name", name); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change State Name"); name = tempStr; settings.UpdateStatesPopupList(); } EditorGUI.BeginChangeCheck(); tempClr = EditorGUILayout.ColorField("Gridline Color", gridlineColor); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Gridline Color"); gridlineColor = tempClr; } EditorGUI.BeginChangeCheck(); tempFloat = EditorGUILayout.FloatField("Grid Size", gridSize); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Grid Size"); gridSize = tempFloat; } EditorGUI.BeginChangeCheck(); tempInt = EditorGUILayout.IntField("Gridline Count", gridlineCount); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Gridline Count"); gridlineCount = tempInt; } EditorGUI.BeginChangeCheck(); tempEnum = (GridEditor.GridAlignment)EditorGUILayout.EnumPopup("Grid Alignment", gridAlignment); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Grid Alignment"); gridAlignment = tempEnum; } string posLabel, shiftXLabel, shiftZLabel; if (gridAlignment == GridEditor.GridAlignment.XZ) { posLabel = "Grid Y Pos"; shiftXLabel = "Grid Shift X"; shiftZLabel = "Grid Shift Z"; } else if (gridAlignment == GridEditor.GridAlignment.XY) { posLabel = "Grid Z Pos"; shiftXLabel = "Grid Shift X"; shiftZLabel = "Grid Shift Y"; } else { posLabel = "Grid X Pos"; shiftXLabel = "Grid Shift Y"; shiftZLabel = "Grid Shift Z"; } EditorGUI.BeginChangeCheck(); tempFloat = EditorGUILayout.FloatField(posLabel, gridPos); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Grid Pos"); gridPos = tempFloat; } EditorGUI.BeginChangeCheck(); tempFloat = EditorGUILayout.FloatField(shiftXLabel, gridShiftAxis1); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Grid Shift Axis 1"); gridShiftAxis1 = tempFloat; } EditorGUI.BeginChangeCheck(); tempFloat = EditorGUILayout.FloatField(shiftZLabel, gridShiftAxis2); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Grid Shift Axis 2"); gridShiftAxis2 = tempFloat; } }
public void Draw(GridEditorSettings settings) { EditorGUI.BeginChangeCheck(); string _name = EditorGUILayout.TextField("Name", name); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change State Name"); name = _name; settings.UpdateStatesPopupList(); } EditorGUI.BeginChangeCheck(); Color _gridlineColor = EditorGUILayout.ColorField("Gridline Color", gridlineColor); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Gridline Color"); gridlineColor = _gridlineColor; } EditorGUI.BeginChangeCheck(); float _gridSize = EditorGUILayout.FloatField("Grid Size", gridSize); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Grid Size"); gridSize = _gridSize; } EditorGUI.BeginChangeCheck(); int _gridlineCount = EditorGUILayout.IntField("Gridline Count", gridlineCount); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Gridline Count"); gridlineCount = _gridlineCount; } EditorGUI.BeginChangeCheck(); GridEditor.GridAlignment _gridAlignment = (GridEditor.GridAlignment)EditorGUILayout.EnumPopup("Grid Alignment", gridAlignment); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Grid Alignment"); gridAlignment = _gridAlignment; } string posLabel, shiftXLabel, shiftZLabel; if (gridAlignment == GridEditor.GridAlignment.XZ) { posLabel = "Grid Y Pos"; shiftXLabel = "Grid Shift X"; shiftZLabel = "Grid Shift Z"; } else if (gridAlignment == GridEditor.GridAlignment.XY) { posLabel = "Grid Z Pos"; shiftXLabel = "Grid Shift X"; shiftZLabel = "Grid Shift Y"; } else { posLabel = "Grid X Pos"; shiftXLabel = "Grid Shift Y"; shiftZLabel = "Grid Shift Z"; } EditorGUI.BeginChangeCheck(); float _gridPos = EditorGUILayout.FloatField(posLabel, gridPos); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Grid Pos"); gridPos = _gridPos; } EditorGUI.BeginChangeCheck(); float _gridShiftAxis1 = EditorGUILayout.FloatField(shiftXLabel, gridShiftAxis1); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Grid Shift Axis 1"); gridShiftAxis1 = _gridShiftAxis1; } EditorGUI.BeginChangeCheck(); float _gridShiftAxis2 = EditorGUILayout.FloatField(shiftZLabel, gridShiftAxis2); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(settings, "Change Grid Shift Axis 2"); gridShiftAxis2 = _gridShiftAxis2; } }