public static void RecordState(this IProBuilderTool tool, IMeshEditor meshEditor, MeshEditorState oldState, MeshEditorState newState, bool oldStateChanged = true, bool newStateChanged = true) { UndoRedoCallback redo = record => { if (newState != null) { meshEditor.SetState(newState); return(newStateChanged); } return(false); }; UndoRedoCallback undo = record => { if (oldState != null) { meshEditor.SetState(oldState); return(oldStateChanged); } return(false); }; IOC.Resolve <IRTE>().Undo.CreateRecord(redo, undo); }
public void RecordState(MeshEditorState oldState, MeshEditorState newState, bool oldStateChanged = true, bool newStateChanged = true) { UndoRedoCallback redo = record => { if (newState != null) { m_polyShape.SetState(newState); return(newStateChanged); } return(false); }; UndoRedoCallback undo = record => { if (oldState != null) { m_polyShape.SetState(oldState); return(oldStateChanged); } return(false); }; IOC.Resolve <IRTE>().Undo.CreateRecord(redo, undo); }
private void RecordStateAndSelection(IMeshEditor meshEditor, MeshSelection selection, MeshEditorState oldState, MeshEditorState newState) { UndoRedoCallback redo = record => { if (newState != null) { meshEditor.ClearSelection(); meshEditor.SetState(newState); meshEditor.ApplySelection(selection); m_pivot.position = meshEditor.Position; m_pivot.rotation = GetPivotRotation(meshEditor);// Quaternion.LookRotation(meshEditor.Normal); OnSelectionChanged(); return(true); } return(false); }; UndoRedoCallback undo = record => { if (oldState != null) { meshEditor.ClearSelection(); meshEditor.SetState(oldState); meshEditor.RollbackSelection(selection); m_pivot.position = meshEditor.Position; m_pivot.rotation = GetPivotRotation(meshEditor);// Quaternion.LookRotation(meshEditor.Normal); OnSelectionChanged(); return(true); } return(false); }; m_rte.Undo.CreateRecord(redo, undo); OnSelectionChanged(); }
public static void RecordStateWithAction(this IProBuilderTool tool, IMeshEditor meshEditor, MeshEditorState oldState, Action <Record> newState, bool changed = true) { UndoRedoCallback redo = record => { newState(record); return(changed); }; UndoRedoCallback undo = record => { meshEditor.SetState(oldState); return(true); }; IOC.Resolve <IRTE>().Undo.CreateRecord(redo, undo); }
private void RecordIsEditing(PBPolyShape polyShape, bool value) { UndoRedoCallback redo = record => { m_polyShape = polyShape; m_polyShape.IsEditing = value; return(true); }; UndoRedoCallback undo = record => { m_polyShape = polyShape; m_polyShape.IsEditing = !value; return(true); }; m_rte.Undo.CreateRecord(redo, undo); }
private void RecordSelection(PBPolyShape polyShape, int oldSelectedIndex) { int selectedIndex = polyShape.SelectedIndex; UndoRedoCallback redo = record => { m_polyShape = polyShape; m_polyShape.SelectedIndex = selectedIndex; PolyShapeUpdatePivot(); return(true); }; UndoRedoCallback undo = record => { m_polyShape = polyShape; m_polyShape.SelectedIndex = oldSelectedIndex; PolyShapeUpdatePivot(); return(true); }; m_rte.Undo.CreateRecord(redo, undo); }
public void RecordState( MeshEditorState oldState, Vector3[] oldPositions, MeshEditorState newState, Vector3[] newPositions, bool oldStateChanged = true, bool newStateChanged = true) { PBPolyShape polyShape = PolyShape; UndoRedoCallback redo = record => { if (newState != null) { m_tool.Mode = ProBuilderToolMode.Object; polyShape.SetState(newState); if (newPositions != null) { polyShape.Positions = newPositions.ToList(); PolyShapeUpdatePivot(polyShape); } return(newStateChanged); } return(false); }; UndoRedoCallback undo = record => { if (oldState != null) { m_tool.Mode = ProBuilderToolMode.Object; polyShape.SetState(oldState); if (oldPositions != null) { polyShape.Positions = oldPositions.ToList(); PolyShapeUpdatePivot(polyShape); } return(oldStateChanged); } return(false); }; IOC.Resolve <IRTE>().Undo.CreateRecord(redo, undo); }
private void RecordSelection(IMeshEditor meshEditor, MeshSelection selection) { UndoRedoCallback redo = record => { meshEditor.ApplySelection(selection); m_pivot.position = meshEditor.Position; m_pivot.rotation = GetPivotRotation(meshEditor);// Quaternion.LookRotation(meshEditor.Normal); OnSelectionChanged(); return(true); }; UndoRedoCallback undo = record => { meshEditor.RollbackSelection(selection); m_pivot.position = meshEditor.Position; m_pivot.rotation = GetPivotRotation(meshEditor);// Quaternion.LookRotation(meshEditor.Normal); OnSelectionChanged(); return(true); }; m_rte.Undo.CreateRecord(redo, undo); OnSelectionChanged(); }
private void OnCurrentModeChanged(ProBuilderToolMode oldMode) { IMeshEditor disabledEditor = m_meshEditors[(int)oldMode]; IMeshEditor enabledEditor = m_meshEditors[(int)m_mode]; GameObject target = null; if (disabledEditor != null) { target = disabledEditor.Target; MeshSelection disabledSelection = disabledEditor.ClearSelection(); MeshSelection selection = null; if (disabledSelection != null) { selection = new MeshSelection(disabledSelection); } if (selection != null) { if (oldMode == ProBuilderToolMode.Face) { if (m_mode == ProBuilderToolMode.Vertex) { selection.FacesToVertices(true); enabledEditor.ApplySelection(selection); } else if (m_mode == ProBuilderToolMode.Edge) { selection.FacesToEdges(true); enabledEditor.ApplySelection(selection); } } else if (oldMode == ProBuilderToolMode.Edge) { if (m_mode == ProBuilderToolMode.Vertex) { selection.EdgesToVertices(true); enabledEditor.ApplySelection(selection); } else if (m_mode == ProBuilderToolMode.Face) { selection.EdgesToFaces(true); enabledEditor.ApplySelection(selection); if (!selection.HasFaces) { m_rte.Selection.activeObject = target; } } } else if (oldMode == ProBuilderToolMode.Vertex) { if (m_mode == ProBuilderToolMode.Face) { selection.VerticesToFaces(true); enabledEditor.ApplySelection(selection); if (!selection.HasFaces) { m_rte.Selection.activeObject = target; } } else if (m_mode == ProBuilderToolMode.Edge) { selection.VerticesToEdges(true); enabledEditor.ApplySelection(selection); if (!selection.HasEdges) { m_rte.Selection.activeObject = target; } } } if (enabledEditor != null && m_rte.Selection.activeObject != m_pivot) { GameObject[] gameObjects = m_rte.Selection.gameObjects; if (gameObjects != null) { enabledEditor.ApplySelection(new MeshSelection(gameObjects)); } } } else { m_rte.Selection.activeObject = target; } if (selection != null) { UndoRedoCallback redo = record => { if (enabledEditor != null) { enabledEditor.ApplySelection(selection); m_pivot.position = enabledEditor.Position; m_pivot.rotation = GetPivotRotation(enabledEditor); OnSelectionChanged(); } return(true); }; UndoRedoCallback undo = record => { if (disabledEditor != null) { disabledEditor.RollbackSelection(disabledSelection); m_pivot.position = disabledEditor.Position; m_pivot.rotation = GetPivotRotation(disabledEditor); OnSelectionChanged(); } return(true); }; m_rte.Undo.CreateRecord(redo, undo); } } else { if (enabledEditor != null) { GameObject[] gameObjects = m_rte.Selection.gameObjects; if (gameObjects != null) { enabledEditor.ApplySelection(new MeshSelection(gameObjects)); OnSelectionChanged(); } } } if (oldMode == ProBuilderToolMode.Object) { SetCanSelect(false); if (disabledEditor != null) { if (disabledEditor.HasSelection) { m_rte.Selection.activeObject = m_pivot.gameObject; } disabledEditor.CenterMode = m_rte.Tools.PivotMode == RuntimePivotMode.Center; } } else if (Mode == ProBuilderToolMode.Object) { SetCanSelect(true); if (m_rte.Selection.activeGameObject == m_pivot.gameObject) { if (disabledEditor != null) { m_rte.Selection.activeObject = target; } else { m_rte.Selection.activeObject = null; } } } if (enabledEditor != null) { m_pivot.position = enabledEditor.Position; m_pivot.rotation = GetPivotRotation(enabledEditor); } }