Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/b64d759ca25b0c9821c0 to your computer and use it in GitHub Desktop.
Save tsubaki/b64d759ca25b0c9821c0 to your computer and use it in GitHub Desktop.
フォントの大きさを変更しても画面辺りのフォントサイズを変更しない(改良版)
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class FontScalable : MonoBehaviour {
[Range(1, 6)]
public float fontScale = 1;
TextMesh tetxMesh;
void Start () {
tetxMesh = GetComponent<TextMesh>();
}
void Update ()
{
int fontSize = Mathf.Max(12, tetxMesh.fontSize);
tetxMesh.fontSize = fontSize;
float scale = 0.1f * 128 / fontSize;
tetxMesh.characterSize = scale * fontScale;
}
}
@tsubaki
Copy link
Author

tsubaki commented Jun 21, 2014

http://blog-imgs-69-origin.fc2.com/t/e/r/terasur/201406220020249a3.gif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment