|
@@ -75,7 +75,6 @@ namespace bs.Editor
|
|
|
private GUIVector3Field soPos;
|
|
private GUIVector3Field soPos;
|
|
|
private GUIVector3Field soRot;
|
|
private GUIVector3Field soRot;
|
|
|
private GUIVector3Field soScale;
|
|
private GUIVector3Field soScale;
|
|
|
- private bool undoRecordNeeded = true;
|
|
|
|
|
|
|
|
|
|
private Quaternion lastRotation;
|
|
private Quaternion lastRotation;
|
|
|
|
|
|
|
@@ -253,8 +252,12 @@ namespace bs.Editor
|
|
|
soNameInput = new GUITextBox(false, GUIOption.FlexibleWidth(180));
|
|
soNameInput = new GUITextBox(false, GUIOption.FlexibleWidth(180));
|
|
|
soNameInput.Text = activeSO.Name;
|
|
soNameInput.Text = activeSO.Name;
|
|
|
soNameInput.OnChanged += OnSceneObjectRename;
|
|
soNameInput.OnChanged += OnSceneObjectRename;
|
|
|
- soNameInput.OnConfirmed += OnModifyConfirm;
|
|
|
|
|
- soNameInput.OnFocusGained += RecordStateForUndoRequested;
|
|
|
|
|
|
|
+ soNameInput.OnConfirmed += () =>
|
|
|
|
|
+ {
|
|
|
|
|
+ OnModifyConfirm();
|
|
|
|
|
+ StartUndo("name");
|
|
|
|
|
+ };
|
|
|
|
|
+ soNameInput.OnFocusGained += () => StartUndo("name");
|
|
|
soNameInput.OnFocusLost += OnModifyConfirm;
|
|
soNameInput.OnFocusLost += OnModifyConfirm;
|
|
|
|
|
|
|
|
nameLayout.AddElement(soActiveToggle);
|
|
nameLayout.AddElement(soActiveToggle);
|
|
@@ -277,25 +280,52 @@ namespace bs.Editor
|
|
|
sceneObjectLayout.AddElement(soPos);
|
|
sceneObjectLayout.AddElement(soPos);
|
|
|
|
|
|
|
|
soPos.OnComponentChanged += OnPositionChanged;
|
|
soPos.OnComponentChanged += OnPositionChanged;
|
|
|
- soPos.OnConfirm += x => OnModifyConfirm();
|
|
|
|
|
- soPos.OnFocusGained += RecordStateForUndoRequested;
|
|
|
|
|
- soPos.OnFocusLost += OnModifyConfirm;
|
|
|
|
|
|
|
+ soPos.OnConfirm += x =>
|
|
|
|
|
+ {
|
|
|
|
|
+ OnModifyConfirm();
|
|
|
|
|
+ StartUndo("position." + x.ToString());
|
|
|
|
|
+ };
|
|
|
|
|
+ soPos.OnComponentFocusChanged += (focus, comp) =>
|
|
|
|
|
+ {
|
|
|
|
|
+ if (focus)
|
|
|
|
|
+ StartUndo("position." + comp.ToString());
|
|
|
|
|
+ else
|
|
|
|
|
+ OnModifyConfirm();
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
soRot = new GUIVector3Field(new LocEdString("Rotation"), 50);
|
|
soRot = new GUIVector3Field(new LocEdString("Rotation"), 50);
|
|
|
sceneObjectLayout.AddElement(soRot);
|
|
sceneObjectLayout.AddElement(soRot);
|
|
|
|
|
|
|
|
soRot.OnComponentChanged += OnRotationChanged;
|
|
soRot.OnComponentChanged += OnRotationChanged;
|
|
|
- soRot.OnConfirm += x => OnModifyConfirm();
|
|
|
|
|
- soRot.OnFocusGained += RecordStateForUndoRequested;
|
|
|
|
|
- soRot.OnFocusLost += OnModifyConfirm;
|
|
|
|
|
|
|
+ soRot.OnConfirm += x =>
|
|
|
|
|
+ {
|
|
|
|
|
+ OnModifyConfirm();
|
|
|
|
|
+ StartUndo("rotation." + x.ToString());
|
|
|
|
|
+ };
|
|
|
|
|
+ soRot.OnComponentFocusChanged += (focus, comp) =>
|
|
|
|
|
+ {
|
|
|
|
|
+ if (focus)
|
|
|
|
|
+ StartUndo("rotation." + comp.ToString());
|
|
|
|
|
+ else
|
|
|
|
|
+ OnModifyConfirm();
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
soScale = new GUIVector3Field(new LocEdString("Scale"), 50);
|
|
soScale = new GUIVector3Field(new LocEdString("Scale"), 50);
|
|
|
sceneObjectLayout.AddElement(soScale);
|
|
sceneObjectLayout.AddElement(soScale);
|
|
|
|
|
|
|
|
soScale.OnComponentChanged += OnScaleChanged;
|
|
soScale.OnComponentChanged += OnScaleChanged;
|
|
|
- soScale.OnConfirm += x => OnModifyConfirm();
|
|
|
|
|
- soScale.OnFocusGained += RecordStateForUndoRequested;
|
|
|
|
|
- soScale.OnFocusLost += OnModifyConfirm;
|
|
|
|
|
|
|
+ soScale.OnConfirm += x =>
|
|
|
|
|
+ {
|
|
|
|
|
+ OnModifyConfirm();
|
|
|
|
|
+ StartUndo("scale." + x.ToString());
|
|
|
|
|
+ };
|
|
|
|
|
+ soScale.OnComponentFocusChanged += (focus, comp) =>
|
|
|
|
|
+ {
|
|
|
|
|
+ if (focus)
|
|
|
|
|
+ StartUndo("scale." + comp.ToString());
|
|
|
|
|
+ else
|
|
|
|
|
+ OnModifyConfirm();
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
sceneObjectLayout.AddFlexibleSpace();
|
|
sceneObjectLayout.AddFlexibleSpace();
|
|
|
|
|
|
|
@@ -686,25 +716,25 @@ namespace bs.Editor
|
|
|
|
|
|
|
|
if (activeSO.UUID == uuid)
|
|
if (activeSO.UUID == uuid)
|
|
|
{
|
|
{
|
|
|
- if(path == "Position.X")
|
|
|
|
|
|
|
+ if(path == "position.X")
|
|
|
soPos.SetInputFocus(VectorComponent.X, true);
|
|
soPos.SetInputFocus(VectorComponent.X, true);
|
|
|
- else if(path == "Position.Y")
|
|
|
|
|
|
|
+ else if(path == "position.Y")
|
|
|
soPos.SetInputFocus(VectorComponent.Y, true);
|
|
soPos.SetInputFocus(VectorComponent.Y, true);
|
|
|
- else if(path == "Position.Z")
|
|
|
|
|
|
|
+ else if(path == "position.Z")
|
|
|
soPos.SetInputFocus(VectorComponent.Z, true);
|
|
soPos.SetInputFocus(VectorComponent.Z, true);
|
|
|
- else if(path == "Rotation.X")
|
|
|
|
|
|
|
+ else if(path == "rotation.X")
|
|
|
soRot.SetInputFocus(VectorComponent.X, true);
|
|
soRot.SetInputFocus(VectorComponent.X, true);
|
|
|
- else if(path == "Rotation.Y")
|
|
|
|
|
|
|
+ else if(path == "rotation.Y")
|
|
|
soRot.SetInputFocus(VectorComponent.Y, true);
|
|
soRot.SetInputFocus(VectorComponent.Y, true);
|
|
|
- else if(path == "Rotation.Z")
|
|
|
|
|
|
|
+ else if(path == "rotation.Z")
|
|
|
soRot.SetInputFocus(VectorComponent.Z, true);
|
|
soRot.SetInputFocus(VectorComponent.Z, true);
|
|
|
- else if(path == "Scale.X")
|
|
|
|
|
|
|
+ else if(path == "scale.X")
|
|
|
soScale.SetInputFocus(VectorComponent.X, true);
|
|
soScale.SetInputFocus(VectorComponent.X, true);
|
|
|
- else if(path == "Scale.Y")
|
|
|
|
|
|
|
+ else if(path == "scale.Y")
|
|
|
soScale.SetInputFocus(VectorComponent.Y, true);
|
|
soScale.SetInputFocus(VectorComponent.Y, true);
|
|
|
- else if(path == "Scale.Z")
|
|
|
|
|
|
|
+ else if(path == "scale.Z")
|
|
|
soScale.SetInputFocus(VectorComponent.Z, true);
|
|
soScale.SetInputFocus(VectorComponent.Z, true);
|
|
|
- else if (path == "Name")
|
|
|
|
|
|
|
+ else if (path == "name")
|
|
|
soNameInput.Focus = true;
|
|
soNameInput.Focus = true;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -735,7 +765,6 @@ namespace bs.Editor
|
|
|
{
|
|
{
|
|
|
if (activeSO != null)
|
|
if (activeSO != null)
|
|
|
{
|
|
{
|
|
|
- RecordSceneObjectHeaderForUndo("Name");
|
|
|
|
|
activeSO.Name = name;
|
|
activeSO.Name = name;
|
|
|
|
|
|
|
|
modifyState |= InspectableState.ModifyInProgress;
|
|
modifyState |= InspectableState.ModifyInProgress;
|
|
@@ -751,8 +780,9 @@ namespace bs.Editor
|
|
|
{
|
|
{
|
|
|
if (activeSO != null)
|
|
if (activeSO != null)
|
|
|
{
|
|
{
|
|
|
- RecordSceneObjectHeaderForUndo("Active");
|
|
|
|
|
|
|
+ StartUndo("active");
|
|
|
activeSO.Active = active;
|
|
activeSO.Active = active;
|
|
|
|
|
+ EndUndo();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -763,6 +793,8 @@ namespace bs.Editor
|
|
|
{
|
|
{
|
|
|
if (modifyState.HasFlag(InspectableState.ModifyInProgress))
|
|
if (modifyState.HasFlag(InspectableState.ModifyInProgress))
|
|
|
modifyState = InspectableState.Modified;
|
|
modifyState = InspectableState.Modified;
|
|
|
|
|
+
|
|
|
|
|
+ EndUndo();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -776,8 +808,6 @@ namespace bs.Editor
|
|
|
if (activeSO == null)
|
|
if (activeSO == null)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- RecordSceneObjectHeaderForUndo("Position." + component);
|
|
|
|
|
-
|
|
|
|
|
if (EditorApplication.ActiveCoordinateMode == HandleCoordinateMode.World)
|
|
if (EditorApplication.ActiveCoordinateMode == HandleCoordinateMode.World)
|
|
|
activeSO.Position = soPos.Value;
|
|
activeSO.Position = soPos.Value;
|
|
|
else
|
|
else
|
|
@@ -798,8 +828,6 @@ namespace bs.Editor
|
|
|
if (activeSO == null)
|
|
if (activeSO == null)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- RecordSceneObjectHeaderForUndo("Rotation." + component);
|
|
|
|
|
-
|
|
|
|
|
Quaternion rotation = Quaternion.FromEuler(soRot.Value);
|
|
Quaternion rotation = Quaternion.FromEuler(soRot.Value);
|
|
|
if (EditorApplication.ActiveCoordinateMode == HandleCoordinateMode.World)
|
|
if (EditorApplication.ActiveCoordinateMode == HandleCoordinateMode.World)
|
|
|
activeSO.Rotation = rotation;
|
|
activeSO.Rotation = rotation;
|
|
@@ -822,8 +850,6 @@ namespace bs.Editor
|
|
|
if (activeSO == null)
|
|
if (activeSO == null)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- RecordSceneObjectHeaderForUndo("Scale." + component);
|
|
|
|
|
-
|
|
|
|
|
activeSO.LocalScale = soScale.Value;
|
|
activeSO.LocalScale = soScale.Value;
|
|
|
|
|
|
|
|
modifyState = InspectableState.ModifyInProgress;
|
|
modifyState = InspectableState.ModifyInProgress;
|
|
@@ -862,25 +888,24 @@ namespace bs.Editor
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// Records the current state of a scene object field for the purposes of undo/redo. Generally this should be
|
|
|
|
|
- /// called just before making changes to the field value.
|
|
|
|
|
|
|
+ /// Notifies the system to start recording a new undo command. Any changes to scene object fields after this is
|
|
|
|
|
+ /// called will be recorded in the command. User must call <see cref="EndUndo"/> after the field is done being
|
|
|
|
|
+ /// changed.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="name">Name of the field being changed.</param>
|
|
/// <param name="name">Name of the field being changed.</param>
|
|
|
- private void RecordSceneObjectHeaderForUndo(string name)
|
|
|
|
|
|
|
+ private void StartUndo(string name)
|
|
|
{
|
|
{
|
|
|
- if (!undoRecordNeeded)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- GameObjectUndo.RecordSceneObjectHeader(activeSO, name);
|
|
|
|
|
- undoRecordNeeded = false;
|
|
|
|
|
|
|
+ if (activeSO != null)
|
|
|
|
|
+ GameObjectUndo.RecordSceneObjectHeader(activeSO, name);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// Notifies the system that the next call to <see cref="RecordSceneObjectHeaderForUndo"/> should record the state.
|
|
|
|
|
|
|
+ /// Finishes recording an undo command started via <see cref="StartUndo(string)"/>. If any changes are detected on
|
|
|
|
|
+ /// the field an undo command is recorded onto the undo-redo stack, otherwise nothing is done.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- private void RecordStateForUndoRequested()
|
|
|
|
|
|
|
+ private void EndUndo()
|
|
|
{
|
|
{
|
|
|
- undoRecordNeeded = true;
|
|
|
|
|
|
|
+ GameObjectUndo.ResolveDiffs();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|