Ejemplo n.º 1
0
        void UpdatePortInput(NodePort port)
        {
            var inputView = m_PortInputContainer.OfType <PortInputView>().First(x => Equals(x.slot, port.slot));

            var currentRect = new Rect(inputView.style.positionLeft, inputView.style.positionTop, inputView.style.width, inputView.style.height);
            var targetRect  = new Rect(0.0f, 0.0f, port.layout.width, port.layout.height);

            targetRect = port.ChangeCoordinatesTo(inputView.shadow.parent, targetRect);
            var centerY = targetRect.center.y;
            var centerX = targetRect.xMax - currentRect.width;

            currentRect.center = new Vector2(centerX, centerY);

            inputView.style.positionTop = currentRect.yMin;
            var newHeight = inputView.parent.layout.height;

            foreach (var element in inputView.parent.Children())
            {
                newHeight = Mathf.Max(newHeight, element.style.positionTop + element.layout.height);
            }
            if (Math.Abs(inputView.parent.style.height - newHeight) > 1e-3)
            {
                inputView.parent.style.height = newHeight;
            }
        }