public static SurfaceNode GetNode(object tag)
 {
     if (tag is NodeInfo nodeInfo)
     {
         VisualScriptWindow vsWindow = null;
         foreach (var window in Editor.Instance.Windows.Windows)
         {
             if (window is VisualScriptWindow w && w.Asset == nodeInfo.Script)
             {
                 vsWindow = (VisualScriptWindow)window;
                 break;
             }
         }
         if (vsWindow == null)
         {
             var item = Editor.Instance.ContentDatabase.FindAsset(nodeInfo.Script.ID);
             if (item != null)
             {
                 vsWindow = Editor.Instance.ContentEditing.Open(item) as VisualScriptWindow;
             }
         }
         return(vsWindow?.Surface.FindNode(nodeInfo.NodeId));
     }
     return(null);
 }
            private void OnBreakpointHangBegin()
            {
                var state = VisualScriptWindow.GetLocals();

                if (state.Locals != null)
                {
                    for (int i = 0; i < state.Locals.Length; i++)
                    {
                        ref var local = ref state.Locals[i];
                        var     node  = state.Window.Surface.FindNode(local.NodeId);
                        var     box   = node?.GetBox(local.BoxId);
                        if (box != null)
                        {
                            var name  = string.IsNullOrEmpty(box.Text) ? node.Title : node.Title + " : " + box.Text;
                            var value = local.Value ?? string.Empty;
                            var type  = TypeUtils.GetType(local.ValueTypeName);
                            node.Surface.Style.GetConnectionColor(type, node.Archetype.ConnectionsHints, out var typeColor);
                            var icon = node.Surface.Style.Icons.BoxClose;
                            new Node(state.Window.Asset, local.NodeId, icon, icon)
                            {
                                Text        = name + " = " + value,
                                Parent      = _rootNode,
                                IconColor   = typeColor,
                                TooltipText = type.TypeName,
                            };
                        }
                    }
                }
 protected override void OnTreeNodeRightClick(ContextMenu menu)
 {
     menu.AddSeparator();
     menu.AddButton("Copy value", button =>
     {
         var node       = (SurfaceNode)button.ParentContextMenu.Tag;
         var state      = VisualScriptWindow.GetLocals();
         var local      = state.Locals.First(x => x.NodeId == node.ID);
         Clipboard.Text = local.Value ?? string.Empty;
     });
 }
            private void OnBreakpointHangBegin()
            {
                var state = VisualScriptWindow.GetStackFrames();

                if (state.StackFrames != null)
                {
                    for (int i = 0; i < state.StackFrames.Length; i++)
                    {
                        ref var            stackFrame = ref state.StackFrames[i];
                        VisualScriptWindow vsWindow   = null;
                        foreach (var window in Editor.Instance.Windows.Windows)
                        {
                            if (window is VisualScriptWindow w && w.Asset == stackFrame.Script)
                            {
                                vsWindow = (VisualScriptWindow)window;
                                break;
                            }
                        }
                        var    node = vsWindow?.Surface.FindNode(stackFrame.NodeId);
                        string text;
                        if (node != null)
                        {
                            text = $"{Path.GetFileNameWithoutExtension(stackFrame.Script.Path)} in node {node.Title}";
                        }
                        else
                        {
                            text = $"{Path.GetFileNameWithoutExtension(stackFrame.Script.Path)} in nodeId {stackFrame.NodeId}";
                        }
                        var icon = Editor.Instance.Icons.ArrowRight12;
                        new Node(stackFrame.Script, stackFrame.NodeId, icon, icon)
                        {
                            Text      = text,
                            Parent    = _rootNode,
                            IconColor = i == 0 ? Color.Yellow : Color.Transparent,
                        };
                    }
                }