1 2 3 4 5 6 7 8 9 10 11
| void DrawText(Vector3 worldPos, string text, Color? colour = null) { Handles.BeginGUI(); if (colour.HasValue) GUI.color = colour.Value; var view = SceneView.currentDrawingSceneView; Vector3 screenPos = view.camera.WorldToScreenPoint(worldPos); Vector2 size = GUI.skin.label.CalcSize(new GUIContent(text)); GUI.Label(new Rect(screenPos.x + 15, view.position.height - screenPos.y, size.x, size.y), text); Handles.EndGUI(); }
|