示例#1
0
        public void RegisterDrawText(Vector3 anchor, string text, Color color, int size, float timer, bool popUp)
        {
            DrawTextEntry entry = null;

            for (int ix = 0; ix < _drawTextEntries.Count; ix++)
            {
                if (!_drawTextEntries[ix].occupied)
                {
                    entry = _drawTextEntries[ix];
                    break;
                }
            }
            if (entry == null)
            {
                entry = new DrawTextEntry();
                _drawTextEntries.Add(entry);
            }

            entry.occupied     = true;
            entry.anchor       = anchor;
            entry.content.text = text;
            entry.size         = size;
            entry.color        = color;
            entry.duration     = entry.timer = timer;
            entry.popUp        = popUp;
#if UNITY_EDITOR
            entry.flag = DrawFlag.None;
#else
            //	in builds consider gizmo is already drawn
            entry.flag = DrawFlag.DrawnGizmo;
#endif

            return;
        }
        private void GUIDrawTextEntry(Camera camera, DrawTextEntry entry, bool isSceneCam)
        {
            Vector3 worldPos = entry.anchor;
            Vector3 heading  = worldPos - camera.transform.position;

            if (Vector3.Dot(camera.transform.forward, heading) <= camera.nearClipPlane)
            {
                return;
            }
            Vector3 screenPos = GetCameraScreenPos(camera, worldPos, isSceneCam);

            if (entry.popUp)
            {
                float ratio = entry.timer / entry.duration;
                screenPos.y -= (1 - ratio * ratio) * entry.size * 1.5f;
            }

            _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;
        }
示例#3
0
        public void RegisterDrawText(Vector3 anchor, string text, Color color, int size, float timer, bool popUp)
        {
            CheckInitialized();

            DrawTextEntry entry = null;

            for (int ix = 0; ix < _drawTextEntries.Count; ix++)
            {
                if (!_drawTextEntries[ix].occupied)
                {
                    entry = _drawTextEntries[ix];
                    break;
                }
            }
            if (entry == null)
            {
                entry = new DrawTextEntry();
                _drawTextEntries.Add(entry);
            }

            entry.occupied     = true;
            entry.anchor       = anchor;
            entry.content.text = text;
            entry.size         = size;
            entry.color        = color;
            entry.duration     = entry.timer = timer;
            entry.popUp        = popUp;
            entry.flag         = DrawFlag.DrawnGizmo;

            return;
        }
示例#4
0
                void GuiDrawTextEntry(Camera n_camera, DrawTextEntry entry)
                {
                    var world_pos  = entry._Anchor;
                    var screen_pos = n_camera.WorldToScreenPoint(world_pos);

                    screen_pos.y = Screen.height - screen_pos.y;

                    if (entry._PopUp)
                    {
                        var ratio = entry._Timer / entry._Duration;
                        screen_pos.y -= (1 - ratio * ratio) * entry._Size * 1.5f;
                    }

                    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);
                }
示例#5
0
                public void RegisterDrawText(
                    Vector3 anchor,
                    string text,
                    Color color,
                    int size,
                    float timer,
                    bool pop_up)
                {
                    this.CheckInitialized();

                    DrawTextEntry entry = null;

                    foreach (var t in this._draw_text_entries)
                    {
                        if (!t._Occupied)
                        {
                            entry = t;
                            break;
                        }
                    }

                    if (entry == null)
                    {
                        entry = new DrawTextEntry();
                        this._draw_text_entries.Add(entry);
                    }

                    entry._Occupied     = true;
                    entry._Anchor       = anchor;
                    entry._Content.text = text;
                    entry._Size         = size;
                    entry._Color        = color;
                    entry._Duration     = entry._Timer = timer;
                    entry._PopUp        = pop_up;
          #if UNITY_EDITOR
                    entry._Flag = DrawFlag.None_;
          #else
                    //	in builds consider gizmo is already drawn
                    entry.flag = DrawFlag.DrawnGizmo;
#endif
                }
示例#6
0
        private void GUIDrawTextEntry(Camera camera, DrawTextEntry entry)
        {
            Vector3 worldPos  = entry.anchor;
            Vector3 screenPos = camera.WorldToScreenPoint(worldPos);

            screenPos.y = Screen.height - screenPos.y;

            if (entry.popUp)
            {
                float ratio = entry.timer / entry.duration;
                screenPos.y -= (1 - ratio * ratio) * entry.size * 1.5f;
            }

            _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;
        }