Fix text texture rendering resolution

This commit is contained in:
excitedneon 2017-05-12 20:34:34 +03:00
parent b460793d87
commit d266155e08
2 changed files with 10 additions and 5 deletions

View File

@ -2260,7 +2260,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1706692498}
m_LocalRotation: {x: -0.000000014901159, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -1, y: 1, z: 0.5}
m_LocalPosition: {x: 0, y: 0, z: 0.5}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1610252930}

View File

@ -31,17 +31,22 @@ namespace Cyber.Util {
}
private Texture2D RenderText(TextTextureProperties text) {
float Scale = 1.0f / text.Width;
float Scale = 2.0f / text.Width;
Text.text = text.Text.Replace("\\n", "\n");
Text.fontSize = text.FontSize;
Text.characterSize = text.FontSize * Scale * 0.5f;
Text.characterSize = text.FontSize * Scale * 0.25f;
RenderTexture TextTexture = RenderTexture.GetTemporary(text.Width, text.Height);
RenderTexture OldRT = Camera.targetTexture;
float OffsetX = -text.Width / 2f;
float OffsetY = -text.Height / 2f;
Camera.orthographicSize = 1.0f * text.Height / text.Width;
Camera.targetTexture = TextTexture;
Camera.backgroundColor = text.Background;
Camera.transform.localPosition = new Vector3(-text.OffsetX * Scale,
text.OffsetY * Scale);
Camera.transform.localPosition = new Vector3(
-(text.OffsetX + OffsetX) * Scale,
(text.OffsetY + OffsetY) * Scale);
Camera.Render();
Camera.targetTexture = OldRT;