Created
January 14, 2015 01:56
-
-
Save tsubaki/496a12d2a23b6d27c3b6 to your computer and use it in GitHub Desktop.
Gizmo Utility
This file contains hidden or 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 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