-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using UnityEngine; | ||
using System; | ||
using Unity.VisualScripting.Community; | ||
|
||
namespace Unity.VisualScripting.Community | ||
{ | ||
[GraphContextExtension(typeof(FlowGraphContext))] | ||
public class CommunityGraphContextExtensions : GraphContextExtension<FlowGraphContext> | ||
{ | ||
public CommunityGraphContextExtensions(FlowGraphContext context) : base(context) | ||
{ | ||
} | ||
|
||
public override IEnumerable<GraphContextMenuItem> contextMenuItems | ||
{ | ||
get | ||
{ | ||
if (selection.Count >= 2) | ||
{ | ||
yield return new GraphContextMenuItem(ConvertToEmbed, "To Embed Subgraph"); | ||
yield return new GraphContextMenuItem(ConvertToMacro, "To Macro Subgraph"); | ||
} | ||
|
||
if (selection.Count == 0) | ||
{ | ||
yield return new GraphContextMenuItem(OpenCSharpPreview, "Open Utility Window"); | ||
} | ||
|
||
foreach (var item in base.contextMenuItems) | ||
{ | ||
yield return item; | ||
} | ||
} | ||
} | ||
|
||
private void ConvertToEmbed(Vector2 pos) | ||
{ | ||
NodeSelection.Convert(GraphSource.Embed); | ||
} | ||
|
||
private void ConvertToMacro(Vector2 pos) | ||
{ | ||
NodeSelection.Convert(GraphSource.Macro); | ||
} | ||
|
||
private void OpenCSharpPreview(Vector2 pos) | ||
{ | ||
UtilityWindow.Open(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.