Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gizmo Utility
using UnityEngine;
using System.Collections;
public class GizmoUtility {
static GUIStyle _guiStyle;
static GUIStyle _GuiStyle
{
get{
if( _guiStyle == null )
{
_guiStyle = new GUIStyle();
}
return _guiStyle;
}
}
public static void HandleLabel(Vector3 position, string label, float fontSize, Color color)
{
#if UNITY_EDITOR
var sceneCamera = UnityEditor.SceneView.currentDrawingSceneView.camera;
var cameraDistance = Vector3.Distance( sceneCamera.transform.position , position);
GUIStyle style = _GuiStyle;
style.normal.textColor = color;
style.fontSize = (int)(fontSize * (512 / cameraDistance));
UnityEditor.Handles.Label(position, label, style);
#endif
}
public static void HandleLabel(Vector3 position, string label, float fontSize)
{
HandleLabel(position,label,fontSize, Gizmos.color);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.