/// <summary> /// Returns bounds of this object in the parent container /// </summary> public virtual Rect GetLocalBounds() { Rect result; Matrix4x4 localMatrix; var bounds = GetInternalBounds(); MatrixUtil.Create2D(ref _scale, _rotation, ref _position, out localMatrix); GeomUtil.GetBounds(ref bounds, ref localMatrix, out result); return(result); }
internal protected virtual void UpdateTransform() { if (parent == null) { MatrixUtil.Create2D(ref _scale, _rotation, ref _position, out compositeMatrix); } else { Matrix4x4 localMatrix; MatrixUtil.Create2D(ref _scale, _rotation, ref _position, out localMatrix); MatrixUtil.Multiply(ref localMatrix, ref _parent.compositeMatrix, out compositeMatrix); } }
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); }