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); }
public static void DrawRect(DisplayObject target, Rect rect, Color color) { if (_debugTexture == null) { _debugTexture = new Texture2D(1, 1); _debugTexture.SetPixel(0, 0, Color.white); } var textureSize = new Vector2(1, 1); var matrix = MatrixUtil.Create2D(new Vector2(rect.width, rect.height), 0, new Vector2(rect.x, rect.y)); MatrixUtil.Multiply(ref matrix, ref target.compositeMatrix, out matrix); var quad = new SpriteQuad(); quad.UpdateColor(ref color); quad.UpdateTransform(ref matrix, ref textureSize); quad.SetZOrder(-10); target.stage.debugBatch.DrawQuad(_debugTexture, ref quad); }
protected void AddQuad(QuadCollection quads, SheetFrame frame, ref Vector2 charPos, ref Vector2 anchor, ref ColorTransform colorMult) { var texture = frame.texture; var textureBounds = frame.textureBounds; Matrix4x4 localMatrix, globalMatrix; var letterScale = fontScale * frame.textureScale; var letterScaleVec = new Vector2(letterScale, letterScale); MatrixUtil.Create2D(ref letterScaleVec, 0, ref charPos, out localMatrix); MatrixUtil.Multiply(ref localMatrix, ref compositeMatrix, out globalMatrix); var textureSize = new Vector2(texture.width, texture.height); var spriteQuad = new SpriteQuad(); spriteQuad.UpdateTransform(ref globalMatrix, ref textureBounds, ref textureSize, ref anchor); spriteQuad.UpdateColor(ref colorMult); quads.Add(spriteQuad); }