public void RegisterAttachText(Transform target, Func <string> strFunc, Vector3 offset, Color color, int size) { AttachTextEntry entry = null; for (int ix = 0; ix < _attachTextEntries.Count; ix++) { if (!_attachTextEntries[ix].occupied) { entry = _attachTextEntries[ix]; break; } } if (entry == null) { entry = new AttachTextEntry(); _attachTextEntries.Add(entry); } entry.occupied = true; entry.offset = offset; entry.transform = target; entry.strFunc = strFunc; entry.color = color; entry.size = size; // get first text entry.content.text = strFunc(); #if UNITY_EDITOR entry.flag = DrawFlag.None; #else // in builds consider gizmo is already drawn entry.flag = DrawFlag.DrawnGizmo; #endif return; }
public void RegisterAttachText(Transform target, Func <string> strFunc, Vector3 offset, Color color, int size) { CheckInitialized(); AttachTextEntry entry = null; for (int ix = 0; ix < _attachTextEntries.Count; ix++) { if (!_attachTextEntries[ix].occupied) { entry = _attachTextEntries[ix]; break; } } if (entry == null) { entry = new AttachTextEntry(); _attachTextEntries.Add(entry); } entry.occupied = true; entry.offset = offset; entry.transform = target; entry.strFunc = strFunc; entry.color = color; entry.size = size; // get first text entry.content.text = strFunc(); entry.flag = DrawFlag.DrawnGizmo; return; }
void GuiAttachTextEntry(Camera n_camera, AttachTextEntry entry) { if (entry._Transform == null) { return; } var world_pos = entry._Transform.position + entry._Offset; var screen_pos = n_camera.WorldToScreenPoint(world_pos); screen_pos.y = Screen.height - screen_pos.y; this._text_style.normal.textColor = entry._Color; this._text_style.fontSize = entry._Size; var rect = new Rect(screen_pos, this._text_style.CalcSize(entry._Content)); GUI.Label(rect, entry._Content, this._text_style); }
private void GUIAttachTextEntry(Camera camera, AttachTextEntry entry) { if (entry.transform == null) { return; } Vector3 worldPos = entry.transform.position + entry.offset; Vector3 screenPos = camera.WorldToScreenPoint(worldPos); screenPos.y = Screen.height - screenPos.y; _textStyle.normal.textColor = entry.color; _textStyle.fontSize = entry.size; Rect rect = new Rect(screenPos, _textStyle.CalcSize(entry.content)); GUI.Label(rect, entry.content, _textStyle); return; }
public void RegisterAttachText( Transform target, Func <string> str_func, Vector3 offset, Color color, int size) { this.CheckInitialized(); AttachTextEntry entry = null; foreach (var t in this._attach_text_entries) { if (!t._Occupied) { entry = t; break; } } if (entry == null) { entry = new AttachTextEntry(); this._attach_text_entries.Add(entry); } entry._Occupied = true; entry._Offset = offset; entry._Transform = target; entry._StrFunc = str_func; entry._Color = color; entry._Size = size; // get first text entry._Content.text = str_func(); #if UNITY_EDITOR entry._Flag = DrawFlag.None_; #else // in builds consider gizmo is already drawn entry.flag = DrawFlag.DrawnGizmo; #endif }
private void GUIAttachTextEntry(Camera camera, AttachTextEntry entry, bool isSceneCam) { if (entry.transform == null) { return; } Vector3 worldPos = entry.transform.position + entry.offset; Vector3 heading = worldPos - camera.transform.position; if (Vector3.Dot(camera.transform.forward, heading) <= camera.nearClipPlane) { return; } Vector3 screenPos = GetCameraScreenPos(camera, worldPos, isSceneCam); _textStyle.normal.textColor = entry.color; _textStyle.fontSize = entry.size; Rect rect = new Rect(screenPos, _textStyle.CalcSize(entry.content)); GUI.Label(rect, entry.content, _textStyle); return; }