Ejemplo n.º 1
0
        /// <summary>
        /// Create a new block view in toolbox
        /// </summary>
        protected BlockView NewBlockView(Block block, Transform parent, int index = -1)
        {
            mWorkspace.RemoveTopBlock(block);

            BlockView view = BlockViewFactory.CreateView(block);

            view.InToolbox = true;
            view.ViewTransform.SetParent(parent, false);

            if (index >= 0)
            {
                view.ViewTransform.SetSiblingIndex(index);
            }

            //add mask
            GameObject maskObj = new GameObject("ToolboxMask");

            maskObj.transform.SetParent(view.ViewTransform, false);
            RectTransform maskTrans = maskObj.AddComponent <RectTransform>();

            maskTrans.sizeDelta = view.Size;
            Image maskImage = maskObj.AddComponent <Image>();

            maskImage.color = new Color(1, 1, 1, 0);
            UIEventListener.Get(maskObj).onBeginDrag = data => PickBlockView(view);
            if (!BlockViewSettings.Get().MaskedInToolbox)
            {
                maskTrans.SetAsFirstSibling();
            }

            view.ActivateCountText(view.InToolbox);
            view.UpdateCount();

            return(view);
        }
Ejemplo n.º 2
0
        private BlockView BuildBlockView(Block block)
        {
            BlockView view = BlockViewFactory.CreateView(block);

            view.InToolbox = false;
            view.ActivateCountText(false);
            view.ViewTransform.SetParent(m_CodingArea, false);
            view.XY = block.XY;

            foreach (Block childBlock in block.ChildBlocks)
            {
                BuildBlockView(childBlock);

                Connection connection = null;
                if (childBlock.PreviousConnection != null)
                {
                    connection = childBlock.PreviousConnection.TargetConnection;
                }
                else if (childBlock.OutputConnection != null)
                {
                    connection = childBlock.OutputConnection.TargetConnection;
                }
                if (connection != null)
                {
                    connection.FireUpdate(Connection.UpdateState.Connected);
                }
            }
            return(view);
        }