Fix text texture rendering resolution
This commit is contained in:
parent
b460793d87
commit
d266155e08
@ -2260,7 +2260,7 @@ Transform:
|
|||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1706692498}
|
m_GameObject: {fileID: 1706692498}
|
||||||
m_LocalRotation: {x: -0.000000014901159, y: -0, z: -0, w: 1}
|
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_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1610252930}
|
m_Father: {fileID: 1610252930}
|
||||||
|
@ -31,17 +31,22 @@ namespace Cyber.Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Texture2D RenderText(TextTextureProperties text) {
|
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.text = text.Text.Replace("\\n", "\n");
|
||||||
Text.fontSize = text.FontSize;
|
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 TextTexture = RenderTexture.GetTemporary(text.Width, text.Height);
|
||||||
RenderTexture OldRT = Camera.targetTexture;
|
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.targetTexture = TextTexture;
|
||||||
Camera.backgroundColor = text.Background;
|
Camera.backgroundColor = text.Background;
|
||||||
Camera.transform.localPosition = new Vector3(-text.OffsetX * Scale,
|
Camera.transform.localPosition = new Vector3(
|
||||||
text.OffsetY * Scale);
|
-(text.OffsetX + OffsetX) * Scale,
|
||||||
|
(text.OffsetY + OffsetY) * Scale);
|
||||||
Camera.Render();
|
Camera.Render();
|
||||||
Camera.targetTexture = OldRT;
|
Camera.targetTexture = OldRT;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user