Exemplo n.º 1
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     if (port.IsOutput)
     {
         tempConnection = Instantiate(graph.runtimeConnectionPrefab);
         tempConnection.transform.SetParent(graph.scrollRect.content);
         tempConnection.SetPosition(transform.position, eventData.position);
         startPos  = transform.position;
         startPort = port;
     }
     else
     {
         if (port.IsConnected)
         {
             NodePort output = port.Connection;
             Debug.Log("has " + port.ConnectionCount + " connections");
             Debug.Log(port.GetConnection(0));
             UGUIMathBaseNode otherNode     = graph.GetRuntimeNode(output.node);
             UGUIPort         otherUGUIPort = otherNode.GetPort(output.fieldName);
             Debug.Log("Disconnect");
             output.Disconnect(port);
             tempConnection = Instantiate(graph.runtimeConnectionPrefab);
             tempConnection.transform.SetParent(graph.scrollRect.content);
             tempConnection.SetPosition(otherUGUIPort.transform.position, eventData.position);
             startPos  = otherUGUIPort.transform.position;
             startPort = otherUGUIPort.port;
             graph.GetRuntimeNode(node).UpdateGUI();
         }
     }
 }
        public void SpawnGraph()
        {
            if (nodes != null)
            {
                nodes.Clear();
            }
            else
            {
                nodes = new List <UGUIMathBaseNode>();
            }

            for (int i = 0; i < graph.nodes.Count; i++)
            {
                Node node = graph.nodes[i];

                UGUIMathBaseNode runtimeNode = null;
                if (node is XNode.Examples.MathNodes.MathNode)
                {
                    runtimeNode = Instantiate(runtimeMathNodePrefab);
                }
                else if (node is XNode.Examples.MathNodes.Vector)
                {
                    runtimeNode = Instantiate(runtimeVectorPrefab);
                }
                else if (node is XNode.Examples.MathNodes.DisplayValue)
                {
                    runtimeNode = Instantiate(runtimeDisplayValuePrefab);
                }
                runtimeNode.transform.SetParent(scrollRect.content);
                runtimeNode.node  = node;
                runtimeNode.graph = this;
                nodes.Add(runtimeNode);
            }
        }
Exemplo n.º 3
0
        public void UpdateConnectionTransforms()
        {
            if (port.IsInput)
            {
                return;
            }

            while (connections.Count < port.ConnectionCount)
            {
                AddConnection();
            }
            while (connections.Count > port.ConnectionCount)
            {
                Destroy(connections[0].gameObject);
                connections.RemoveAt(0);
            }

            // Loop through connections
            for (int i = 0; i < port.ConnectionCount; i++)
            {
                NodePort         other     = port.GetConnection(i);
                UGUIMathBaseNode otherNode = graph.GetRuntimeNode(other.node);
                if (!otherNode)
                {
                    Debug.LogWarning(other.node.name + " node not found", this);
                }
                Transform port2 = otherNode.GetPort(other.fieldName).transform;
                if (!port2)
                {
                    Debug.LogWarning(other.fieldName + " not found", this);
                }
                connections[i].SetPosition(transform.position, port2.position);
            }
        }
Exemplo n.º 4
0
 private void Awake()
 {
     node = GetComponentInParent <UGUIMathBaseNode>();
 }