diff --git a/com.unity.visualeffectgraph/CHANGELOG.md b/com.unity.visualeffectgraph/CHANGELOG.md index a73aa05888b..04717d21ef3 100644 --- a/com.unity.visualeffectgraph/CHANGELOG.md +++ b/com.unity.visualeffectgraph/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix undetermitism in space with LocalToWorld and WorldToLocal operators [Case 1355820](https://issuetracker.unity3d.com/product/unity/issues/guid/1355820/) - Unexpected compilation error while modifying ShaderGraph exposed properties [Case 1361601](https://issuetracker.unity3d.com/product/unity/issues/guid/1361601/) - Compilation issue while using new SG integration and SampleTexture/SampleMesh [Case 1359391](https://issuetracker.unity3d.com/product/unity/issues/guid/1359391/) +- Added a missing paste option in the context menu for VFX contexts. Also the paste options is now disabled when uneffective - Prevent VFX Graph compilation each time a property's min/max value is changed - Prevent vfx re-compilation in some cases when a value has not changed - Eye dropper in the color fields kept updating after pressing the Esc key diff --git a/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXPaste.cs b/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXPaste.cs index 92bf45f498d..a0d87dff2e6 100644 --- a/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXPaste.cs +++ b/com.unity.visualeffectgraph/Editor/GraphView/Views/VFXPaste.cs @@ -47,6 +47,27 @@ public static void PasteBlocks(VFXViewController viewController, object data, VF s_Instance.PasteBlocks(viewController, (data as SerializableGraph).operators, targetModelContext, targetIndex, blocksInTheSameOrder); } + public static bool CanPaste(VFXView view, object data) + { + try + { + var serializableGraph = JsonUtility.FromJson(data.ToString()); + if (serializableGraph.blocksOnly) + { + var selectedContexts = view.selection.OfType(); + var selectedBlocks = view.selection.OfType(); + + return selectedBlocks.Any() || selectedContexts.Count() == 1; + } + + return true; + } + catch + { + return false; + } + } + void DoPaste(VFXViewController viewController, Vector2 center, object data, VFXView view, VFXGroupNodeController groupNode, List nodesInTheSameOrder) { SerializableGraph serializableGraph = (SerializableGraph)data; @@ -85,7 +106,7 @@ void PasteBlocks(VFXView view, ref SerializableGraph serializableGraph, List(OnKeyDownEvent); graphViewChanged = VFXGraphViewChanged; - elementResized = VFXElementResized; + canPasteSerializedData = VFXCanPaste; viewDataKey = "VFXView"; @@ -2137,6 +2137,11 @@ Vector2 pasteCenter } } + private bool VFXCanPaste(string data) + { + return VFXPaste.CanPaste(this, data); + } + public void UnserializeAndPasteElements(string operationName, string data) { Profiler.BeginSample("VFXPaste.VFXPaste.UnserializeAndPasteElements"); @@ -2403,6 +2408,16 @@ public override void BuildContextualMenu(ContextualMenuPopulateEvent evt) evt.menu.AppendSeparator(); evt.menu.AppendAction("Duplicate %d", OnDuplicateBlackBoardCategory, e => canDeleteSelection ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled); } + + if (evt.target is GraphView || evt.target is Node) + { + var copyMenu = evt.menu.MenuItems().OfType().SingleOrDefault(x => x.name == "Copy"); + if (copyMenu != null) + { + var index = evt.menu.MenuItems().IndexOf(copyMenu); + evt.menu.InsertAction(index + 1, "Paste", (a) => { PasteCallback(); }, (a) => { return canPaste ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled; }); + } + } } static readonly string s_DeleteEventCommandName = GetDeleteEventCommandName();