public void InsertIntoInputContent(UICodeblock item, InputContent content)
        {
            item.transform.SetParent(content.DropArea);
            item.PositionController.TargetLocalPosition = new Vector3(0, 0);

            RectTransform rt = item.GetComponent <RectTransform>();

            rt.anchorMin = Vector2.zero;
            rt.anchorMax = Vector2.one;
            rt.sizeDelta = Vector2.zero;

            content.UpdateEvaluateableProperty();
        }
Exemple #2
0
        private GameObject ResolveProperty(PropertyInfo property)
        {
            //Debug.Log("Resolving property: " + property.PropertyType);

            GameObject prefab      = Resources.Load <GameObject>("Codeblock_Content_Input");
            GameObject inputObject = GameObject.Instantiate(prefab);

            InputContent content = inputObject.GetComponent <InputContent>();

            content.Property        = property;
            content.ReferenceObject = _item;

            return(inputObject);
        }
        public virtual void OnPointerUp(PointerEventData eventData)
        {
            if (eventData.button == PointerEventData.InputButton.Left)
            {
                if (Type != UIBlockType.Entry)
                {
                    if (Type == UIBlockType.Executable)
                    {
                        UICodeblock[] blocksInDropArea     = CodeblockInspectionStructure.Instance.GetBlocksInDropArea(_transform.GetWorldRect());
                        UICodeblock   validPreviousSibling = blocksInDropArea.FirstOrDefault(b => b.Type == UIBlockType.Executable || b.Type == UIBlockType.Entry || b.Type == UIBlockType.ControlFlow);

                        if (validPreviousSibling != null)
                        {
                            if (validPreviousSibling != this)
                            {
                                CodeblockInspectionStructure.Instance.InsertItem(this, validPreviousSibling);
                            }
                        }
                        else
                        {
                            CodeblockInspectionStructure.Instance.DetachItem(this);
                        }
                    }
                    if (Type == UIBlockType.Evaluateable)
                    {
                        InputContent[] contentsInDropArea = CodeblockInspectionStructure.Instance.GetContentsInDropArea(_transform.GetWorldRect());
                        InputContent   leftmostInput      = contentsInDropArea.OrderBy(c => c.transform.position.x).FirstOrDefault();

                        if (leftmostInput != null)
                        {
                            CodeblockInspectionStructure.Instance.InsertIntoInputContent(this, leftmostInput);
                        }
                    }
                }
            }
        }