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; } }
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; } }
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); } ); } }
protected override void Awake() { base.Awake(); argumentSlot = GetComponentInChildren <ExprSlot>(); IsRune = false; }