From 84150299c0bd2993e963087b6b18cccedf8d215d Mon Sep 17 00:00:00 2001 From: Marc Templin Date: Fri, 24 Apr 2020 10:50:10 -0700 Subject: [PATCH 1/2] Fixes for 3 cases of undo not working --- com.unity.shadergraph/CHANGELOG.md | 1 + com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs | 3 +++ .../Editor/Drawing/Views/GraphEditorView.cs | 5 ++++- .../Editor/Drawing/Views/MaterialNodeView.cs | 1 + .../Drawing/Views/Slots/MultiFloatSlotControlView.cs | 9 +++++---- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/com.unity.shadergraph/CHANGELOG.md b/com.unity.shadergraph/CHANGELOG.md index 521358424ba..200f20050a3 100644 --- a/com.unity.shadergraph/CHANGELOG.md +++ b/com.unity.shadergraph/CHANGELOG.md @@ -100,6 +100,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an issue where `Keywords` on the Blackboard would not duplicate with the same `Default` value. - Shader Graph now requests preview shader compilation asynchronously. [1209047](https://issuetracker.unity3d.com/issues/shader-graph-unresponsive-editor-when-using-large-graphs) - Fixed an issue where Shader Graph would not compile master previews after an assembly reload. +- Fixed undo not being recorded properly for setting active master node, graph precision, and node defaults. ## [7.1.1] - 2019-09-05 ### Added diff --git a/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs b/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs index de888cad9a7..bd3e6a15250 100644 --- a/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs +++ b/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs @@ -1029,6 +1029,9 @@ public void ReplaceWith(GraphData other) if (other == null) throw new ArgumentException("Can only replace with another AbstractMaterialGraph", "other"); + concretePrecision = other.concretePrecision; + m_ActiveOutputNodeGuid = other.m_ActiveOutputNodeGuid; + using (var removedInputsPooledObject = ListPool.GetDisposable()) { var removedInputGuids = removedInputsPooledObject.value; diff --git a/com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs b/com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs index 363ded1f8ae..4a5fafb6d43 100644 --- a/com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs +++ b/com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs @@ -169,9 +169,12 @@ public GraphEditorView(EditorWindow editorWindow, GraphData graph, MessageManage EditorGUI.BeginChangeCheck(); GUILayout.Label("Precision"); - graph.concretePrecision = (ConcretePrecision)EditorGUILayout.EnumPopup(graph.concretePrecision, GUILayout.Width(100f)); + var precision = (ConcretePrecision)EditorGUILayout.EnumPopup(graph.concretePrecision, GUILayout.Width(100f)); if (EditorGUI.EndChangeCheck()) { + m_Graph.owner.RegisterCompleteObjectUndo("Changed Graph Precision"); + graph.concretePrecision = precision; + var nodeList = m_GraphView.Query().ToList(); m_ColorManager.SetNodesDirty(nodeList); graph.ValidateGraph(); diff --git a/com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs b/com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs index 3aa3f7a51c9..f35ed9020e0 100644 --- a/com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs +++ b/com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs @@ -339,6 +339,7 @@ public override void BuildContextualMenu(ContextualMenuPopulateEvent evt) void SetMasterAsActive(DropdownMenuAction action) { + node.owner.owner.RegisterCompleteObjectUndo("Change Active Master"); node.owner.activeOutputNodeGuid = node.guid; } diff --git a/com.unity.shadergraph/Editor/Drawing/Views/Slots/MultiFloatSlotControlView.cs b/com.unity.shadergraph/Editor/Drawing/Views/Slots/MultiFloatSlotControlView.cs index 323c7538696..9a82903ce18 100644 --- a/com.unity.shadergraph/Editor/Drawing/Views/Slots/MultiFloatSlotControlView.cs +++ b/com.unity.shadergraph/Editor/Drawing/Views/Slots/MultiFloatSlotControlView.cs @@ -70,11 +70,12 @@ void AddField(Vector4 initialValue, int index, string subLabel) m_Node.Dirty(ModificationScope.Node); } }); - // Reset UndoGroup when done editing input field + // Reset UndoGroup when done editing input field & update title field.Q("unity-text-input").RegisterCallback(evt => - { - m_UndoGroup = -1; - }); + { + m_Node.owner.owner.isDirty = true; + m_UndoGroup = -1; + }); Add(field); } } From 5aba9d92c320b7b51055ac8a4b5da902c4ea9b4c Mon Sep 17 00:00:00 2001 From: Alex Lindman Date: Tue, 5 May 2020 10:58:30 -0700 Subject: [PATCH 2/2] resolve merge conflict --- com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs b/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs index 63ce8ca6c52..c022c19ece6 100644 --- a/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs +++ b/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs @@ -974,7 +974,7 @@ public void ReplaceWith(GraphData other) throw new ArgumentException("Can only replace with another AbstractMaterialGraph", "other"); concretePrecision = other.concretePrecision; - m_ActiveOutputNodeGuid = other.m_ActiveOutputNodeGuid; + m_OutputNode = other.m_OutputNode; using (var inputsToRemove = PooledList.Get()) {