public void DrawImage(Image image, Color color, float x, float y, float width, float height, float angle) { if (image == null || width <= 0 || height <= 0) { return; } var unityGdiSprite = image.uTexture as UnityGdiSprite; if (unityGdiSprite != null && unityGdiSprite.sprite != null) { var spriteRect = unityGdiSprite.sprite.rect; var texture = unityGdiSprite.sprite.texture; var sx = spriteRect.x / texture.width; var sy = spriteRect.y / texture.height; var sw = spriteRect.width / texture.width; var sh = spriteRect.height / texture.height; UE.GUI.color = color.ToUnityColor(); UE.GUI.DrawTextureWithTexCoords(new UE.Rect(x, y, width, height), unityGdiSprite.sprite.texture, new UE.Rect(sx, sy, sw, sh)); return; } var textureToDraw = defaultTexture; var imageTexture = image.uTexture as UnityGdiTexture; if (imageTexture != null) { textureToDraw = imageTexture.texture; } if (angle != 0) { UE.Matrix4x4 matrixBackup = UE.GUI.matrix; UE.GUIUtility.RotateAroundPivot(angle, new UE.Vector2(x + width / 2, y + height / 2)); UE.GUI.DrawTexture(new UE.Rect(x, y, width, height), ((UnityGdiTexture)image.uTexture).texture); UE.GUI.matrix = matrixBackup; return; } UE.GUI.color = color.ToUnityColor(); UE.GUI.DrawTexture(new UE.Rect(x, y, width, height), textureToDraw); }
private void uwfDrawTexture(UE.Texture texture, float x, float y, float width, float height, Color color, float angle, PointF pivot) { if (texture == null) { return; } UE.GUI.color = color.ToUnityColor(); if (angle != 0) { UE.Matrix4x4 matrixBackup = UE.GUI.matrix; UE.GUIUtility.RotateAroundPivot(angle, new UE.Vector2(x + pivot.X, y + pivot.Y)); UE.GUI.DrawTexture(new UE.Rect(x, y, width, height), texture); UE.GUI.matrix = matrixBackup; } else { UE.GUI.DrawTexture(new UE.Rect(x, y, width, height), texture); } }