예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 internal protected override void UpdateColor()
 {
     base.UpdateColor();
     _quad.UpdateColor(ref compositeColor);
 }