Example #1
0
        internal protected override void UpdateTransform()
        {
            base.UpdateTransform();

            Rect textureRect;

            if (_scrollRect.HasValue)
            {
                var sheetRect = new Rect(
                    _textureScrollRect.x + _frame.textureBounds.x + _frame.textureAnchor.x,
                    _textureScrollRect.y + _frame.textureBounds.y + _frame.textureAnchor.y,
                    _textureScrollRect.width,
                    _textureScrollRect.height);

                textureRect = sheetRect.GetIntersection(_frame.textureBounds);
            }
            else
            {
                textureRect = _frame.textureBounds;
            }

            var anchorPoint = new Vector2(
                anchor.x / _frame.textureScale + _frame.textureAnchor.x,
                anchor.y / _frame.textureScale + _frame.textureAnchor.y);

            var flip = TextureFlip.NONE;

            if (_flipHorizontal)
            {
                flip |= TextureFlip.HORIZONTAL;
            }
            if (_flipVertical)
            {
                flip |= TextureFlip.VERTICAL;
            }

            var texture      = _frame.texture;
            var textureScale = _frame.textureScale;
            var textureSize  = new Vector2(texture.width, texture.height);
            var globalMatrix = MatrixUtil.CreateScale2D(textureScale) * compositeMatrix;

            _quad.UpdateTransform(ref globalMatrix, ref textureRect, ref textureSize, ref anchorPoint, flip);
        }