Created
May 28, 2021 19:42
-
-
Save yanniboi/4502e9c9aecac1eb7874a1a0c4eceebb to your computer and use it in GitHub Desktop.
Displays text at certain zoom level in Unity Editor. By Alex Strook (https://twitter.com/AlexStrook/status/1398304186505236487)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEditor.SceneManagement; | |
public class EditorValueDisplay : MonoBehaviour | |
{ | |
public string const = "0000"; | |
private float _visibilityDistance = 2.5; | |
private float _worldOffset = 0.1f; | |
public void OnDrawGizmos() | |
{ | |
if (Vector3.Distance(transform.position, SceneView.currentDrawingSceneView.camera.transform.position) < _visibilityDistance) | |
{ | |
GUIStyle style = new GUIStyle(); | |
style.fontStyle = FontStyle.Bold; | |
style.fontSize = 20; | |
style.normal.textColor = Color.magenta; | |
Handles.Label(transform.position + new Vector3(0, _worldOffset, 0), code, style); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment