Esempio n. 1
0
        public void OnBeginDrag(PointerEventData eventData)
        {
            if (!IsMovable)
            {
                return;
            }

            CodeUIElement.Instance.DraggedBlock = this;

            placeHolder = new GameObject();
            var placeHolderTransform = placeHolder.AddComponent <RectTransform>();

            placeHolderTransform.SetParent(transform.parent);
            placeHolderTransform.SetSiblingIndex(transform.GetSiblingIndex());
            placeHolderTransform.anchorMin = new Vector2(0, 1);
            placeHolderTransform.anchorMax = new Vector2(0, 1);
            LayoutElement layoutElement = placeHolder.AddComponent <LayoutElement>();

            layoutElement.minWidth  = OriginalWidth;
            layoutElement.minHeight = OriginalHeight;

            OriginalPosition     = transform.position;
            OriginalParent       = transform.parent;
            OriginalSiblingIndex = transform.GetSiblingIndex();

            IsInSlot = false;

            transform.SetParent(CodeUIElement.Instance.transform);
            canvasGroup.blocksRaycasts = false;

            if (ContainedSlot != null)
            {
                ContainedSlot.Filled = false;
                ContainedSlot        = null;
            }
            if (ContainedScopedBlock != null)
            {
                ContainedScopedBlock.UpdateBlocks();
                ContainedScopedBlock = null;
            }
        }
Esempio n. 2
0
        public void FindWhereYouBelong()
        {
            Transform parent = transform.parent;

            while (parent != null)
            {
                ScopedBlock scopedBlock = parent.GetComponent <ScopedBlock>();
                if (scopedBlock != null)
                {
                    ContainedScopedBlock = scopedBlock;
                    break;
                }
                ExprSlot exprSlot = parent.GetComponent <ExprSlot>();
                if (exprSlot != null)
                {
                    ContainedSlot = exprSlot;
                    break;
                }
                parent = parent.parent;
            }
        }
Esempio n. 3
0
        protected override void Awake()
        {
            base.Awake();
            IsRune        = false;
            conditionSlot = GetComponentInChildren <ExprSlot>();
            DynamicHeight = true;
            if (toggleable)
            {
                Toggle    toggle     = transform.GetChild(0).GetChild(0).GetComponent <Toggle>();
                Transform background = toggle.transform.Find("Background");
                falseText = background.Find("false").gameObject;
                trueText  = background.Find("true").gameObject;

                toggle.onValueChanged.AddListener((bool boolean) =>
                {
                    not = boolean;
                    falseText.SetActive(not);
                    trueText.SetActive(!not);
                }
                                                  );
            }
        }
Esempio n. 4
0
 protected override void Awake()
 {
     base.Awake();
     argumentSlot = GetComponentInChildren <ExprSlot>();
     IsRune       = false;
 }