Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 22 additions & 1 deletion com.unity.visualeffectgraph/Editor/GraphView/Views/VFXPaste.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SerializableGraph>(data.ToString());
if (serializableGraph.blocksOnly)
{
var selectedContexts = view.selection.OfType<VFXContextUI>();
var selectedBlocks = view.selection.OfType<VFXBlockUI>();

return selectedBlocks.Any() || selectedContexts.Count() == 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same check that is done when really doing the paste

}

return true;
}
catch
{
return false;
}
}

void DoPaste(VFXViewController viewController, Vector2 center, object data, VFXView view, VFXGroupNodeController groupNode, List<VFXNodeController> nodesInTheSameOrder)
{
SerializableGraph serializableGraph = (SerializableGraph)data;
Expand Down Expand Up @@ -85,7 +106,7 @@ void PasteBlocks(VFXView view, ref SerializableGraph serializableGraph, List<VFX
}
else
{
Debug.LogError(m_BlockPasteError.text);
Debug.LogWarning(m_BlockPasteError.text);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a error, rather an action that is not allowed. But with my changes it should not happen anymore

return;
}

Expand Down
17 changes: 16 additions & 1 deletion com.unity.visualeffectgraph/Editor/GraphView/Views/VFXView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,8 @@ public VFXView()
RegisterCallback<KeyDownEvent>(OnKeyDownEvent);

graphViewChanged = VFXGraphViewChanged;

elementResized = VFXElementResized;
canPasteSerializedData = VFXCanPaste;

viewDataKey = "VFXView";

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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<DropdownMenuAction>().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();
Expand Down