Exemplo n.º 1
0
        //...
        static void DropInstance(FlowNode targetNode, object dropInstance)
        {
            if (targetNode == null || dropInstance == null)
            {
                return;
            }

            //dont set instance if it's 'Self'
            if (dropInstance is UnityEngine.Object)
            {
                var ownerGO = targetNode.graph.agent != null? targetNode.graph.agent.gameObject : null;
                if (ownerGO != null)
                {
                    var dropGO = dropInstance as GameObject;
                    if (dropGO == ownerGO)
                    {
                        return;
                    }
                    var dropComp = dropInstance as Component;
                    if (dropComp != null && dropComp.gameObject == ownerGO)
                    {
                        return;
                    }
                }
            }

            var instancePort = targetNode.GetFirstInputOfType(dropInstance.GetType()) as ValueInput;

            if (instancePort != null)
            {
                instancePort.serializedValue = dropInstance;
            }
        }
Exemplo n.º 2
0
        //...
        static void FinalizeConnection(Port sourcePort, FlowNode targetNode)
        {
            if (sourcePort == null || targetNode == null)
            {
                return;
            }

            Port source = null;
            Port target = null;

            if (sourcePort is ValueOutput || sourcePort is FlowOutput)
            {
                source = sourcePort;
                target = targetNode.GetFirstInputOfType(sourcePort.type);
            }
            else
            {
                source = targetNode.GetFirstOutputOfType(sourcePort.type);
                target = sourcePort;
            }

            BinderConnection.Create(source, target);
        }