Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #91 from Henry00IS/Fix87
Browse files Browse the repository at this point in the history
2DSE extruding brush can be undone properly. Fixes #87.
  • Loading branch information
Henry00IS authored Apr 10, 2018
2 parents c6b2bb9 + 05019dd commit b17db4c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Scripts/Brushes/CompoundBrushes/ShapeEditor/ShapeEditorBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,18 @@ public override void Invalidate(bool polygonsChanged)
UpdateGeneratedHierarchyName();
}

/// <summary>
/// Called when undo or redo is performed in the editor.
/// </summary>
public override void OnUndoRedoPerformed()
{
// reset our cached polygon data.
isDirty = true;
m_LastBuiltPolygons = null;
// the base method will invalidate this compound brush.
base.OnUndoRedoPerformed();
}

/// <summary>
/// Gets the next segment.
/// </summary>
Expand Down Expand Up @@ -683,6 +695,9 @@ public Project GetEmbeddedProject()
/// <param name="project">The project to be copied into the brush.</param>
public void CreatePolygon(Project project)
{
#if UNITY_EDITOR
UnityEditor.Undo.RecordObject(this, "Create Polygon");
#endif
// store a project copy inside of this brush.
this.project = project.Clone();
// store the extrude mode inside of this brush.
Expand All @@ -700,6 +715,9 @@ public void CreatePolygon(Project project)
/// <param name="project">The project to be copied into the brush.</param>
public void RevolveShape(Project project)
{
#if UNITY_EDITOR
UnityEditor.Undo.RecordObject(this, "Revolve Shape");
#endif
// store a project copy inside of this brush.
this.project = project.Clone();
// store the extrude mode inside of this brush.
Expand All @@ -717,6 +735,9 @@ public void RevolveShape(Project project)
/// <param name="project">The project to be copied into the brush.</param>
public void ExtrudeShape(Project project)
{
#if UNITY_EDITOR
UnityEditor.Undo.RecordObject(this, "Extrude Shape");
#endif
// store a project copy inside of this brush.
this.project = project.Clone();
// store the extrude mode inside of this brush.
Expand All @@ -734,6 +755,9 @@ public void ExtrudeShape(Project project)
/// <param name="project">The project to be copied into the brush.</param>
public void ExtrudePoint(Project project)
{
#if UNITY_EDITOR
UnityEditor.Undo.RecordObject(this, "Extrude Point");
#endif
// store a project copy inside of this brush.
this.project = project.Clone();
// store the extrude mode inside of this brush.
Expand All @@ -752,6 +776,9 @@ public void ExtrudePoint(Project project)
/// <param name="project">The project to be copied into the brush.</param>
public void ExtrudeBevel(Project project)
{
#if UNITY_EDITOR
UnityEditor.Undo.RecordObject(this, "Extrude Bevel");
#endif
// if the depth and clip depth are identical, extrude a point instead.
if (project.extrudeDepth.EqualsWithEpsilon(project.extrudeClipDepth))
{
Expand Down

0 comments on commit b17db4c

Please sign in to comment.