Ejemplo n.º 1
0
 public void FollowMouse(GameObject from)
 {
     followMouse      = true;
     this.from        = from;
     to               = null;
     inputDestination = null;
 }
Ejemplo n.º 2
0
        private void OnDragEnd(BaseEventData arg0)
        {
            PointerEventData ev = arg0 as PointerEventData;

            if (ev == null)
            {
                return;
            }

            if (status == LINKING && EventSystem.current.IsPointerOverGameObject())
            {
                List <RaycastResult> results = new List <RaycastResult>();
                EventSystem.current.RaycastAll(ev, results);
                bool good = false;
                for (int i = 0; i < results.Count; i++)
                {
                    InputVisual r = results[i].gameObject.GetComponent <InputVisual>();
                    if (r != null && linkInitiator.host != r.host)
                    {
                        r.Disconnect();
                        CompleteLink(r);
                        good = true;
                        break;
                    }
                }
                if (!good && !(UnityEngine.Input.GetKey(KeyCode.LeftShift) || UnityEngine.Input.GetKey(KeyCode.RightShift)))
                {
                    CancelLink();
                }
            }
        }
Ejemplo n.º 3
0
 public void Set(GameObject from, GameObject to)
 {
     if (tmpLink != null)
     {
         Destroy(tmpLink);
     }
     this.from        = from;
     this.to          = to;
     inputDestination = to.GetComponent <InputVisual>();
 }
Ejemplo n.º 4
0
        InputVisual CreateInputVisual(BackEnd.Input input, string label)
        {
            GameObject go = new GameObject();

            go.AddComponent <RectTransform>();
            go.transform.SetParent(rectTransform, false);
            InputVisual inp = go.AddComponent <InputVisual>();

            inp.inputAttachedTo = input;
            inp.host            = this;
            inp.SetLabel(label);
            return(inp);
        }
Ejemplo n.º 5
0
        void InputsCountChanged()
        {
            //go though each input, if the old input existed update it if not create one
            //an then delete all the inputs in surplus
            List <InputVisual>  nInputVisuals  = new List <InputVisual>();
            List <List <Type> > noldInputTypes = new List <List <Type> >();

            for (int i = 0; i < node.inputs.Count; i++)
            {
                if (inputsVisuals.Length > i)
                {
                    //if there is and old input here
                    //update it
                    UpdateInput(i);
                    nInputVisuals.Add(inputsVisuals[i]);
                    noldInputTypes.Add(GetDataTypeOrAllowed(node.inputs[i]));
                }
                else
                {
                    //if there is not and old input here
                    //create input
                    InputVisual inp = CreateInputVisual(node.inputs[i], GetInputLabel(i));
                    inp.name = "input_" + i;

                    List <Type> dataType = GetDataTypeOrAllowed(node.inputs[i]);
                    inp.UpdateType();

                    PlaceInput(inp, i);
                    nInputVisuals.Add(inp);
                    noldInputTypes.Add(dataType);
                }
            }
            if (inputsVisuals.Length > node.inputs.Count)
            {
                //there is some input in surplus
                //delete them (the surplus)
                for (int i = node.inputs.Count; i < inputsVisuals.Length; i++)
                {
                    inputsVisuals[i].Disconnect();
                    Destroy(inputsVisuals[i].gameObject);
                }
            }
            //resize oldInputTypes and inputVisuals
            inputsVisuals = nInputVisuals.ToArray();
            oldInputTypes = noldInputTypes.ToArray();
        }
Ejemplo n.º 6
0
        void BuildInputs()
        {
            //Debug.Log("Building inputs for " + GetType());

            inputsVisuals = new InputVisual[node.inputs.Count];
            oldInputTypes = new List <Type> [inputsVisuals.Length];

            for (int i = 0; i < node.inputs.Count; i++)//inputs
            {
                InputVisual inp = CreateInputVisual(node.inputs[i], GetInputLabel(i));
                inp.name         = "input_" + i;
                inputsVisuals[i] = inp;

                List <Type> dataTypes = GetDataTypeOrAllowed(node.inputs[i]);
                inp.UpdateType();
                oldInputTypes[i] = dataTypes;
            }
            PlaceInputs();
        }
Ejemplo n.º 7
0
        public static void CompleteLink(InputVisual linkEnd)
        {
            if (linkInitiator.outputAttachedTo.ConnectTo(linkEnd.inputAttachedTo))
            {
                linkInitiator.pendingLink.FinishFollowingMouse(linkEnd.gameObject);
                linkInitiator.links.Add(linkInitiator.pendingLink);

                linkEnd.outputConnectedTo = linkInitiator;


                linkInitiator.pendingLink = null;
                linkInitiator             = null;
                status = IDLE;
            }
            else
            {
                Debug.Log("linking refused");
                CancelLink();
            }
        }
Ejemplo n.º 8
0
 public static Color GetColorForType(Type t)
 {
     return(InputVisual.GetColorForType(t));
 }
Ejemplo n.º 9
0
 void PlaceInput(InputVisual inp, int i)
 {
     inp.rectTransform.anchoredPosition = new Vector2(-GetWidth() / 2f, (GetHeight() / 2f) - (25f * i) - 20f);
 }