Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created January 14, 2015 01:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/496a12d2a23b6d27c3b6 to your computer and use it in GitHub Desktop.
Save tsubaki/496a12d2a23b6d27c3b6 to your computer and use it in GitHub Desktop.
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