Пример #1
0
        protected void CompileAndShareReferences(GraphInterlink requester, HashSet <GraphInterlink> commonInterlinks, Dictionary <string, UnityGraphObject> commonVariablesByID)
        {
            if (commonInterlinks.Contains(this))
            {
                return;
            }

            if (!AssociatedLinks.Contains(requester))
            {
                AssociatedLinks.Add(requester);
            }

            commonInterlinks.Add(this);
            interlinks = commonInterlinks;

            for (int i = 0; i < ConnectedUnityObjects.Count; i++)
            {
                UnityGraphObject obj = ConnectedUnityObjects[i];

                if (commonVariablesByID.ContainsKey(obj.ID))
                {
                    Debug.LogWarning("More than one object with ID " + obj.ID + " detected. Only one will be kept.");
                }
                else
                {
                    commonVariablesByID.Add(obj.ID, obj);
                }
            }
            VariablesByID = commonVariablesByID;

            for (int i = 0; i < AssociatedLinks.Count; i++)
            {
                AssociatedLinks[i].CompileAndShareReferences(this, commonInterlinks, commonVariablesByID);
            }
        }
Пример #2
0
 protected void ValidateVariableConnections(GraphInterlink interlink)
 {
     for (int i = interlink.ConnectedUnityObjects.Count - 1; i >= 0; i--)
     {
         UnityGraphObject obj = interlink.ConnectedUnityObjects[i];
         if (!interlink.IsInRange(obj.gameObject))
         {
             Debug.LogWarning("Object not in range of graph " + name + ": " + obj.ID);
             interlink.ConnectedUnityObjects.RemoveAt(i);
             if (VariablesByID != null)
             {
                 VariablesByID.Remove(obj.ID);
             }
         }
     }
 }
Пример #3
0
        public void SelectVariableModeFor(PortInfo portInfo)
        {
            InPortsTitle.gameObject.SetActive(false);
            InPortsContainer.gameObject.SetActive(false);
            OutPortsTitle.gameObject.SetActive(false);
            OutPortsContainer.gameObject.SetActive(false);
            VariableSelectionTitle.gameObject.SetActive(true);
            VariableSelection.SetActive(true);

            foreach (Transform t in VariableSelection.transform)
            {
                Destroy(t.gameObject);
            }

            InPort Port = portInfo.Port as InPort;

            foreach (UnityGraphObject v in Port.Component.Graph.AssociatedInterlink.GetLinkedVariables())
            {
                // Type check
                bool found = false;
                for (int i = 0; i < Port.Types.Length; i++)
                {
                    if (Port.Types[i] == v.GetObjectType())
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    continue;
                }

                GameObject variableSelector = GameObject.Instantiate <GameObject>(VariableTemplate);
                variableSelector.transform.SetParent(VariableSelection.transform);
                variableSelector.GetComponentInChildren <Text>().text = v.GetObjectID() + " (" + v.GetObjectType() + ")";

                UnityGraphObject obj = v;
                variableSelector.GetComponent <Button>().onClick.AddListener(() => {
                    NormalMode();
                    Port.Component.Graph.SetDefaultValue(obj, Port);
                    portInfo.RefreshDefaultValueShown();
                });
            }

            LayoutRebuilder.ForceRebuildLayoutImmediate(VariableSelection.transform as RectTransform);
        }