コード例 #1
0
        public ActionGraphPresenter(ActionGraphView view)
        {
            View = view;

            OnConnectNodesQueue.Reassign((data =>
            {
                // if (!data.Connection.From.Owner.connectedTo.Any(c => c.Target.Equals(data.Connection.Target)))
                {
                    var asParent = data.Connection.From.Owner as ActionGraphEditorNode;
                    var asChild = data.Connection.Target.Owner as ActionGraphEditorNode;

                    if (asParent != null &&
                        asChild != null &&
                        asChild.ActionNode is ActionGraphNode asActionNode)
                    {
                        Undo.RecordObject(asParent.ActionNode,
                                          $"Connect nodes {asActionNode.name} to {asParent.ActionNode.name}");

                        GraphNode.FinishConnection(data.Connection);
                        return(true);
                    }
                }

                return(false);
            }));
        }
コード例 #2
0
        public ActionGraphPresenter(ActionGraphView view)
        {
            View = view;

            OnConnectNodesQueue.Reassign((data =>
            {
                if (!data.Child || (!data.Parent && data.InputIndex == -1))
                {
                    return(false);
                }

                if (data.InputIndex == -1)
                {
                    if (!data.Parent.Connections.Contains(data.Child))
                    {
                        Undo.RecordObject(data.Parent, $"Connect nodes {data.Child.name} to {data.Parent.name}");
                        data.Parent.Connections.Add(data.Child);
                    }
                }
                else
                {
                    if (!Asset.Inputs[data.InputIndex].Nodes.Contains(data.Child))
                    {
                        Undo.RecordObject(Asset, $"Connect node {data.Child.name} to input {data.InputIndex}");
                        Asset.Inputs[data.InputIndex].Nodes.Add(data.Child);
                    }
                }

                return(true);
            }));
        }