Пример #1
0
        protected override Vector2 CalculateSize()
        {
            int width = m_TextUI.CalculateTextWidth(m_TextUI.text);

            Debug.LogFormat(">>>>> CalculateSize-Label: text: {0}, width: {1}", m_TextUI.text, width);
            return(new Vector2(width, BlockViewSettings.Get().ContentHeight));
        }
Пример #2
0
        protected void Highlight(bool active)
        {
            if (mHighlightObj == null)
            {
                mHighlightObj = GameObject.Instantiate(BlockViewSettings.Get().PrefabConnectHighlight);
                RectTransform highlightTrans = mHighlightObj.GetComponent <RectTransform>();
                highlightTrans.SetParent(ViewTransform, false);

                if (ConnectionType == Define.EConnection.InputValue)
                {
                    highlightTrans.localRotation      = Quaternion.Euler(0, 0, -90);
                    highlightTrans.pivot              = new Vector2(0, 0);
                    highlightTrans.anchorMin          = highlightTrans.anchorMax = new Vector2(0, 1);
                    highlightTrans.anchoredPosition3D = new Vector2(0, -17);
                }
                else if (ConnectionType == Define.EConnection.OutputValue)
                {
                    highlightTrans.localRotation      = Quaternion.Euler(0, 0, -90);
                    highlightTrans.anchoredPosition3D = Vector3.zero;
                }
                else if (ConnectionType == Define.EConnection.NextStatement && Type == ViewType.ConnectionInput)
                {
                    highlightTrans.pivot              = new Vector2(0, 1);
                    highlightTrans.anchorMin          = highlightTrans.anchorMax = new Vector2(0, 1);
                    highlightTrans.anchoredPosition3D = new Vector2(18, 0);
                }
                else
                {
                    highlightTrans.anchoredPosition3D = Vector3.zero;
                }
            }
            mHighlightObj.SetActive(active);
        }
Пример #3
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);
        }
Пример #4
0
        protected override Vector2 CalculateSize()
        {
            int width = mFieldImage.Size.x;

            Debug.LogFormat(">>>>> CalculateSize-Image: width: {0}", width);
            return(new Vector2(width, BlockViewSettings.Get().ContentHeight));
        }
Пример #5
0
        protected void BuildVariableBlocks()
        {
            Transform parent = mRootList[Define.VARIABLE_CATEGORY_NAME].transform;

            //build createVar button
            GameObject obj = GameObject.Instantiate(BlockViewSettings.Get().PrefabBtnCreateVar);

            obj.transform.SetParent(parent, false);
            obj.GetComponentInChildren <Image>().color = mConfig.GetBlockCategory(Define.VARIABLE_CATEGORY_NAME).Color;
            obj.GetComponent <Button>().onClick.AddListener(() =>
            {
                DialogFactory.CreateDialog("variable_name");
            });

            List <VariableModel> allVars = mWorkspace.GetAllVariables();

            if (allVars.Count == 0)
            {
                return;
            }

            CreateVariableHelperViews();

            //list all variable getter views
            foreach (VariableModel variable in mWorkspace.GetAllVariables())
            {
                CreateVariableGetterView(variable.Name);
            }
        }
Пример #6
0
        /// <summary>
        /// update all child inputviews to align right
        /// </summary>
        /// <param name="width"></param>
        public void UpdateAlignRight(float width)
        {
            if (Mathf.Approximately(this.Width, width))
            {
                return;
            }
            this.Width = width;

            ConnectionInputView conView = ((InputView)LastChild).GetConnectionView();

            if (conView != null && conView.ConnectionInputViewType == ConnectionInputViewType.Statement)
            {
                conView.Width = width - (LastChild.XY.x + conView.XY.x);
            }
            else
            {
                float startX = this.XY.x + width;
                for (int i = Childs.Count - 1; i >= 0; i--)
                {
                    InputView inputView = Childs[i] as InputView;
                    if (i < Childs.Count - 1)
                    {
                        startX -= BlockViewSettings.Get().ContentSpace.x;
                    }
                    startX      -= inputView.Width;
                    inputView.XY = new Vector2(startX, inputView.XY.y);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// todo: call in OnDestroy()
        /// </summary>
        public void Dispose()
        {
            UnBindModel();

            BlockViewSettings.Dispose();
            Resources.UnloadUnusedAssets();
        }
Пример #8
0
        /// <summary>
        /// update layout of this view and all views effected
        /// </summary>
        public void UpdateLayout(Vector2 startPos)
        {
            XY   = startPos;
            Size = CalculateSize();

            switch (Type)
            {
            case ViewType.Field:
            case ViewType.Input:
            case ViewType.ConnectionInput:
            case ViewType.LineGroup:
            {
                if (m_Next == null /*|| (!changePos && !changeSize)*/)
                {
                    //reach the last child, or no change in current hierarchy, update it's parent view
                    m_Parent.UpdateLayout(m_Parent.SiblingIndex == 0 ? m_Parent.HeaderXY : m_Parent.XY);
                }
                else
                {
                    //update next
                    if (Type != ViewType.LineGroup)
                    {
                        // same line
                        startPos.x += Size.x + BlockViewSettings.Get().ContentSpace.x;
                    }
                    else
                    {
                        // start a new line
                        startPos.y -= Size.y + BlockViewSettings.Get().ContentSpace.y;
                    }

                    BaseView topmostChild = m_Next.GetTopmostChild();
                    if (topmostChild != m_Next)
                    {
                        //need to update from its topmost child
                        m_Next.XY = startPos;
                        topmostChild.UpdateLayout(topmostChild.HeaderXY);
                    }
                    else
                    {
                        m_Next.UpdateLayout(startPos);
                    }
                }
                break;
            }

            case ViewType.Connection:
            case ViewType.Block:
            {
                //no need to update its m_Next, as it is handled by Unity's Transform autolayout
                //update its parent directly
                if (m_Parent != null)
                {
                    m_Parent.UpdateLayout(m_Parent.SiblingIndex == 0 ? m_Parent.HeaderXY : m_Parent.XY);
                }
                break;
            }
            }
        }
Пример #9
0
        protected override Vector2 CalculateSize()
        {
            float width = m_Label.CalculateTextWidth(m_Label.text);

            width += mHorizontalMargin;

            Debug.LogFormat(">>>>> CalculateSize-Variable: text: {0}, width: {1}", m_Label.text, width);
            return(new Vector2(width, BlockViewSettings.Get().ContentHeight));
        }
Пример #10
0
        protected override Vector2 CalculateSize()
        {
            float width = m_InputField.textComponent.CalculateTextWidth(m_InputField.text);

            width += mHorizontalMargin + 2.0f; // extra offset

            Debug.LogFormat(">>>>> CalculateSize-TextInput: text: {0}, width: {1}", m_InputField.text, width);
            return(new Vector2(width, BlockViewSettings.Get().ContentHeight));
        }
Пример #11
0
 private void OnEnable()
 {
     if (mStatusObj == null)
     {
         mStatusObj = GameObject.Instantiate(BlockViewSettings.Get().PrefabStatusLight, BlocklyUI.WorkspaceView.CodingArea, false);
         RectTransform statusRect = mStatusObj.GetComponent <RectTransform>();
         statusRect.anchorMin = statusRect.anchorMax = new Vector2(0, 1);
         statusRect.pivot     = 0.5f * Vector2.one;
     }
     mStatusObj.SetActive(true);
 }
Пример #12
0
        protected void OnConnectStateUpdated(Connection.UpdateState updateState)
        {
            switch (updateState)
            {
            case Connection.UpdateState.Connected:
            {
                if (!mConnection.IsSuperior)
                {
                    throw new Exception("ConnectionView- OnConnectStateUpdated: Only Superior can accept the \"Connected\" message.");
                }

                // this superior connection is connected to a child connection
                OnAttached();
                break;
            }

            case Connection.UpdateState.Disconnected:
            {
                if (!mConnection.IsSuperior)
                {
                    throw new Exception("ConnectionView- OnConnectStateUpdated: Only Superior can accept the \"Disconnected\" message.");
                }

                // this superior connection is disconnected to a child connection
                OnDetached();
                break;
            }

            case Connection.UpdateState.BumpedAway:
            {
                if (mConnection.IsSuperior)
                {
                    throw new Exception("ConnectionView- OnConnectStateUpdated: Only Inferior can accept the \"BumpedAway\" message.");
                }

                // this inferior connection is bumped away after disconnecting
                mSourceBlockView.XY += BlockViewSettings.Get().BumpAwayOffset;
                break;
            }

            case Connection.UpdateState.Highlight:
            {
                Highlight(true);
                break;
            }

            case Connection.UpdateState.UnHighlight:
            {
                Highlight(false);
                break;
            }
            }
        }
Пример #13
0
        public static BlockViewSettings Get()
        {
            if (mInstance == null)
            {
                mInstance = Resources.Load <BlockViewSettings>("BlockViewSettings");
            }
            if (mInstance == null)
            {
                throw new Exception("There is no \"BlockViewSettings\" ScriptObject under Resources folder");
            }

            return(mInstance);
        }
Пример #14
0
        protected override Vector2 CalculateSize()
        {
            bool alignRight = false;

            //accumulate all child lineGroups' size
            Vector2 size = Vector2.zero;

            for (int i = 0; i < Childs.Count; i++)
            {
                LineGroupView groupView = Childs[i] as LineGroupView;
                if (groupView != null)
                {
                    size.x  = Mathf.Max(size.x, groupView.Size.x);
                    size.y += groupView.Size.y;
                    if (i < Childs.Count - 1)
                    {
                        size.y += BlockViewSettings.Get().ContentSpace.y;
                    }

                    if (((InputView)groupView.LastChild).AlignRight)
                    {
                        alignRight = true;
                    }
                }
            }

            //collect all child lineGroups' vertices for custom drawing
            List <Vector4> dimensions = new List <Vector4>();

            for (int i = 0; i < Childs.Count; i++)
            {
                LineGroupView groupView = Childs[i] as LineGroupView;
                if (groupView != null)
                {
                    if (alignRight)
                    {
                        groupView.UpdateAlignRight(size.x);
                    }

                    //linegroup's anchor and pivot both are top-left
                    Vector2 drawSize = groupView.GetDrawSize();
                    dimensions.Add(new Vector4(groupView.XY.x, groupView.XY.y - drawSize.y, groupView.XY.x + drawSize.x, groupView.XY.y));
                }
            }

            //update image mesh
            ((CustomMeshImage)m_BgImages[0]).SetDrawDimensions(dimensions.ToArray());
            return(size);
        }
Пример #15
0
        protected override Vector2 CalculateSize()
        {
            float width;

            if (!mField.IsImage)
            {
                width = m_Label.CalculateTextWidth(m_Label.text);
            }
            else
            {
                width = m_Image.mainTexture.width;
            }
            width += mHorizontalMargin;
            Debug.LogFormat(">>>>> CalculateSize-Button: text: {0}, width: {1}", m_Label.text, width);
            return(new Vector2(width, BlockViewSettings.Get().ContentHeight));
        }
Пример #16
0
        public static FieldView BuildFieldView(Field field)
        {
            FieldView  fieldView = null;
            GameObject fieldObj  = null;

            Type fieldType = field.GetType();

            if (fieldType == typeof(FieldLabel))
            {
                fieldObj  = GameObject.Instantiate(BlockViewSettings.Get().PrefabFieldLabel);
                fieldView = AddViewComponent <FieldLabelView>(fieldObj);
            }
            else if (fieldType == typeof(FieldTextInput))
            {
                fieldObj  = GameObject.Instantiate(BlockViewSettings.Get().PrefabFieldInput);
                fieldView = AddViewComponent <FieldInputView>(fieldObj);
            }
            else if (fieldType == typeof(FieldVariable))
            {
                fieldObj  = GameObject.Instantiate(BlockViewSettings.Get().PrefabFieldVariable);
                fieldView = AddViewComponent <FieldVariableView>(fieldObj);
            }
            else if (fieldType == typeof(FieldColour))
            {
                fieldObj  = GameObject.Instantiate(BlockViewSettings.Get().PrefabFieldButton);
                fieldView = AddViewComponent <FieldColorView>(fieldObj);
            }
            else if (fieldType == typeof(FieldImage))
            {
                fieldObj  = GameObject.Instantiate(BlockViewSettings.Get().PrefabFieldImage);
                fieldView = AddViewComponent <FieldImageView>(fieldObj);
            }
            else if (fieldType == typeof(FieldCheckbox))
            {
                fieldObj  = GameObject.Instantiate(BlockViewSettings.Get().PrefabFieldCheckbox);
                fieldView = AddViewComponent <FieldCheckboxView>(fieldObj);
            }
            else
            {
                fieldObj  = GameObject.Instantiate(BlockViewSettings.Get().PrefabFieldButton);
                fieldView = AddViewComponent <FieldButtonView>(fieldObj);
            }

            fieldObj.name = !string.IsNullOrEmpty(field.Name) ? "Field_" + field.Name : fieldObj.name.Substring(0, fieldObj.name.IndexOf("(Clone)"));
            return(fieldView);
        }
Пример #17
0
        public void OnDrag(PointerEventData eventData)
        {
            if (InToolbox)
            {
                return;
            }
            Vector2 localPos;

            RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)ViewTransform.parent, UnityEngine.Input.mousePosition,
                                                                    BlocklyUI.UICanvas.worldCamera, out localPos);
            XY = localPos + mTouchOffset;

            // find the closest connection
            var oldClosest = mClosestConnection;

            mClosestConnection   = null;
            mAttachingConnection = null;
            int minRadius = BlockViewSettings.Get().ConnectSearchRange;

            for (int i = 0; i < Childs.Count; i++)
            {
                if (Childs[i].Type != ViewType.Connection)
                {
                    break;
                }
                if (((ConnectionView)Childs[i]).SearchClosest(minRadius, ref mClosestConnection, ref minRadius))
                {
                    mAttachingConnection = ((ConnectionView)Childs[i]).Connection;
                }
            }

            if (oldClosest != mClosestConnection && oldClosest != null)
            {
                oldClosest.FireUpdate(Connection.UpdateState.UnHighlight);
            }

            if (oldClosest != mClosestConnection && mClosestConnection != null)
            {
                mClosestConnection.FireUpdate(Connection.UpdateState.Highlight);
            }

            // check over bin
            BlocklyUI.WorkspaceView.Toolbox.CheckBin(this);
        }
Пример #18
0
        protected override Vector2 CalculateSize()
        {
            switch (m_ConnectionInputViewType)
            {
            case ConnectionInputViewType.Value:
            {
                //width is not concerned
                Vector2 size = new Vector2(BlockViewSettings.Get().ValueConnectPointRect.width, 0);
                if (mTargetBlockView == null)
                {
                    size.y = BlockViewSettings.Get().ContentHeight;
                }
                else
                {
                    size.y = mTargetBlockView.Height;
                }
                return(size);
            }

            case ConnectionInputViewType.ValueSlot:
            {
                if (mTargetBlockView == null)
                {
                    return(new Vector2(BlockViewSettings.Get().MinUnitWidth, BlockViewSettings.Get().ContentHeight));
                }
                Vector2 size = new Vector2(BlockViewSettings.Get().ValueConnectPointRect.width + mTargetBlockView.Width, mTargetBlockView.Height);
                return(size);
            }

            case ConnectionInputViewType.Statement:
            {
                if (mTargetBlockView == null)
                {
                    return(new Vector2(70, BlockViewSettings.Get().ContentHeight + BlockViewSettings.Get().ContentMargin.bottom));
                }

                // calculate the height by adding all child statement blocks' height
                Vector2 size = new Vector2(70, 0);

                bool      addConnectPointSpace = true;
                BlockView nextView             = mTargetBlockView;
                while (nextView != null)
                {
                    size.y += nextView.Height;

                    ConnectionView nextCon = nextView.GetConnectionView(Define.EConnection.NextStatement);
                    if (nextCon == null)
                    {
                        addConnectPointSpace = false;
                        break;
                    }

                    nextView = nextCon.TargetBlockView;
                }
                if (addConnectPointSpace)
                {
                    size.y += BlockViewSettings.Get().StatementConnectPointRect.height;
                }

                size.y += BlockViewSettings.Get().ContentMargin.bottom;
                return(size);
            }
            }
            return(Vector2.zero);
        }
Пример #19
0
 public static void Dispose()
 {
     mInstance = null;
 }
Пример #20
0
        public static GameObject BuildBlockView(Block block)
        {
            GameObject blockPrefab = BlockViewSettings.Get().PrefabRoot;

            if (block.OutputConnection != null)
            {
                blockPrefab = BlockViewSettings.Get().PrefabRootOutput;
            }
            else if (block.PreviousConnection != null && block.NextConnection != null)
            {
                blockPrefab = BlockViewSettings.Get().PrefabRootPrevNext;
            }
            else if (block.PreviousConnection != null)
            {
                blockPrefab = BlockViewSettings.Get().PrefabRootPrev;
            }

            GameObject blockObj = GameObject.Instantiate(blockPrefab);

            blockObj.name = "Block_" + block.Type;
            RectTransform blockTrans = blockObj.GetComponent <RectTransform>();

            UniformRectTransform(blockTrans);

            //blockview script
            BlockView blockView = AddViewComponent <BlockView>(blockObj);

            //block view's background image
            blockView.AddBgImage(blockObj.GetComponent <Image>());

            //block view's childs: connection, lineGroup
            Transform mutatorEntry = null;

            foreach (Transform child in blockTrans)
            {
                string childName = child.name.ToLower();
                if (childName.StartsWith("connection"))
                {
                    //connection node views
                    ConnectionView conView = AddViewComponent <ConnectionView>(child.gameObject);
                    blockView.AddChild(conView, 0);

                    if (childName.EndsWith("output"))
                    {
                        conView.ConnectionType = Define.EConnection.OutputValue;
                    }
                    else if (childName.EndsWith("prev"))
                    {
                        conView.ConnectionType = Define.EConnection.PrevStatement;
                    }
                    else if (childName.EndsWith("next"))
                    {
                        conView.ConnectionType = Define.EConnection.NextStatement;
                    }

                    //connection node view background color
                    Image image = child.GetComponent <Image>();
                    if (image != null)
                    {
                        blockView.AddBgImage(image);
                    }
                }
                else if (childName.Equals("linegroup"))
                {
                    UniformRectTransform(child as RectTransform);
                    //lineGroup view
                    LineGroupView groupView = AddViewComponent <LineGroupView>(child.gameObject);
                    blockView.AddChild(groupView);
                }
                else if (childName.Equals("mutator_entry"))
                {
                    mutatorEntry = child;
                }
                else if (childName.StartsWith("block_count"))
                {
                    blockView.SetCountText(child.GetComponentInChildren <Text>());
                }
            }

            //check if has mutator entry
            if (mutatorEntry == null)
            {
                throw new Exception("There should be a mutator_entry image under block view prefab");
            }
            if (block.Mutator == null || !block.Mutator.NeedEditor)
            {
                GameObject.DestroyImmediate(mutatorEntry.gameObject);
            }
            else
            {
                blockView.GetLineGroup(0).ReservedStartX = ((RectTransform)mutatorEntry).rect.width + BlockViewSettings.Get().ContentSpace.x;
            }

            //block view's input views, including field's views
            BuildInputViews(block, blockView);

            //block view's layout, build from the very first field
            blockView.BuildLayout();

            //default background color
            blockView.ChangeBgColor(Color.blue);

            return(blockObj);
        }
Пример #21
0
        public static InputView BuildInputView(Input input, LineGroupView groupView, BlockView blockView)
        {
            GameObject inputPrefab;
            ConnectionInputViewType viewType;

            if (input.Type == Define.EConnection.NextStatement)
            {
                inputPrefab = BlockViewSettings.Get().PrefabInputStatement;
                viewType    = ConnectionInputViewType.Statement;
            }
            else if (input.SourceBlock.InputList.Count > 1 && input.SourceBlock.GetInputsInline())
            {
                inputPrefab = BlockViewSettings.Get().PrefabInputValueSlot;
                viewType    = ConnectionInputViewType.ValueSlot;
            }
            else
            {
                inputPrefab = BlockViewSettings.Get().PrefabInputValue;
                viewType    = ConnectionInputViewType.Value;
            }

            GameObject inputObj = GameObject.Instantiate(inputPrefab);

            inputObj.name = "Input_" + (!string.IsNullOrEmpty(input.Name) ? input.Name : "");
            RectTransform inputTrans = inputObj.GetComponent <RectTransform>();

            inputTrans.SetParent(groupView.transform, false);
            UniformRectTransform(inputTrans);

            Transform conInputTrans = inputTrans.GetChild(0);

            InputView inputView = AddViewComponent <InputView>(inputObj);

            inputView.AlignRight = input.Align == Define.EAlign.Right;

            // build child field views of this input view
            List <Field> fields = input.FieldRow;

            foreach (Field field in fields)
            {
                FieldView fieldView = BuildFieldView(field);
                inputView.AddChild(fieldView);
                RectTransform fieldTrans = fieldView.GetComponent <RectTransform>();
                UniformRectTransform(fieldTrans);
            }

            if (input.Type == Define.EConnection.DummyInput)
            {
                //dummy input doesn't need to have a connection point
                GameObject.DestroyImmediate(conInputTrans.gameObject);
            }
            else
            {
                ConnectionInputView conInputView = AddViewComponent <ConnectionInputView>(conInputTrans.gameObject);
                conInputView.ConnectionType          = input.Type;
                conInputView.ConnectionInputViewType = viewType;
                inputView.AddChild(conInputView);

                conInputView.BgImage.raycastTarget = false;
                if (viewType != ConnectionInputViewType.ValueSlot)
                {
                    blockView.AddBgImage(conInputView.BgImage);
                }
            }

            return(inputView);
        }
Пример #22
0
        public void OnPointerClick(PointerEventData eventData)
        {
            //todo: background outline
            if (eventData.button == PointerEventData.InputButton.Right && !eventData.dragging && !InToolbox && CanBeCloned(null))
            {
                BlockView newBlock = BlocklyUI.WorkspaceView.CloneBlockView(this, XY + BlockViewSettings.Get().BumpAwayOffset);
                newBlock.InitIDs();
                TrackerAsset.Instance.setVar("block_type", Block.Type);
                TrackerAsset.Instance.setVar("action", "duplicate");
                TrackerAsset.Instance.setVar("new_block_id", GameManager.Instance.GetBlockId(newBlock.Block));
                TrackerAsset.Instance.GameObject.Interacted(GameManager.Instance.GetBlockId(Block));

                TrackerAsset.Instance.setVar("block_type", Block.Type);
                TrackerAsset.Instance.setVar("action", "create_clone");

                XmlNode dom  = Xml.BlockToDomWithXY(newBlock.Block, false);
                string  text = UBlockly.Xml.DomToText(dom);
                text = GameManager.Instance.ChangeCodeIDs(text);

                TrackerAsset.Instance.setVar("code", "\r\n" + text);
                TrackerAsset.Instance.GameObject.Interacted(GameManager.Instance.GetBlockId(newBlock.Block));
            }
        }
Пример #23
0
        /// <summary>
        /// update layout of this view and all views effected
        /// </summary>
        public void UpdateLayout(Vector2 startPos)
        {
            Vector2 newSize    = CalculateSize();
            bool    changePos  = XY != startPos;
            bool    changeSize = Size != newSize;

            if (changePos)
            {
                XY = startPos;
            }
            if (changeSize)
            {
                Size = newSize;
            }

            switch (Type)
            {
            case ViewType.Field:
            case ViewType.Input:
            case ViewType.ConnectionInput:
            case ViewType.LineGroup:
            {
                if (m_Next == null /*|| (!changePos && !changeSize)*/)
                {
                    //reach the last child, or no change in current hierarchy, update it's parent view
                    m_Parent.UpdateLayout(m_Parent.SiblingIndex == 0 ? m_Parent.HeaderXY : m_Parent.XY);
                }
                else
                {
                    //update next
                    if (Type != ViewType.LineGroup)
                    {
                        // same line
                        startPos.x += Size.x + BlockViewSettings.Get().ContentSpace.x;
                    }
                    else
                    {
                        // start a new line
                        startPos.y -= Size.y + BlockViewSettings.Get().ContentSpace.y;
                    }

                    BaseView topmostChild = m_Next.GetTopmostChild();
                    if (topmostChild != m_Next)
                    {
                        //need to update from its topmost child
                        m_Next.XY = startPos;
                        topmostChild.UpdateLayout(topmostChild.HeaderXY);
                    }
                    else
                    {
                        m_Next.UpdateLayout(startPos);
                    }
                }
                // update connection location in ConnectionDB
                if (Type == ViewType.ConnectionInput)
                {
                    ConnectionView connectionView = (ConnectionView)this;
                    if (connectionView != null)
                    {
                        connectionView.OnXYUpdated();
                    }
                }

                break;
            }

            case ViewType.Connection:
            case ViewType.Block:
            {
                //no need to update its m_Next, as it is handled by Unity's Transform autolayout
                //update its parent directly
                if (m_Parent != null)
                {
                    m_Parent.UpdateLayout(m_Parent.SiblingIndex == 0 ? m_Parent.HeaderXY : m_Parent.XY);
                }

                // update connection location in ConnectionDB
                if (Type == ViewType.Block)
                {
                    BlockView blockView = (BlockView)this;
                    if (blockView != null)
                    {
                        foreach (var view in blockView.Childs)
                        {
                            if (view.Type == ViewType.Connection)
                            {
                                view.OnXYUpdated();
                            }
                        }
                    }
                }

                break;
            }
            }
        }
Пример #24
0
 protected override Vector2 CalculateSize()
 {
     return(new Vector2(uiWidth, BlockViewSettings.Get().ContentHeight));
 }
Пример #25
0
 protected override Vector2 CalculateSize()
 {
     //size is unchanged
     return(new Vector2(BlockViewSettings.Get().ColorFieldWidth, BlockViewSettings.Get().ContentHeight));
 }