Ejemplo n.º 1
0
        void Awake()
        {
            // Get a reference to the text component.
            m_TextComponent = gameObject.GetComponent <TMP_Text>();

            // Get a reference to the camera rendering the text taking into consideration the text component type.
            if (m_TextComponent.GetType() == typeof(TextMeshProUGUI))
            {
                m_Canvas = gameObject.GetComponentInParent <Canvas>();
                if (m_Canvas != null)
                {
                    if (m_Canvas.renderMode == RenderMode.ScreenSpaceOverlay)
                    {
                        m_Camera = null;
                    }
                    else
                    {
                        m_Camera = m_Canvas.worldCamera;
                    }
                }
            }
            else
            {
                m_Camera = Camera.main;
            }
        }
Ejemplo n.º 2
0
        void OnDrawGizmos()
        {
            if (m_TextComponent == null)
            {
                m_TextComponent = GetComponent<TMP_Text>();

                if (m_TextComponent == null)
                    return;
            }

            m_Transform = m_TextComponent.transform;

            // Get a reference to the text object's textInfo
            m_TextInfo = m_TextComponent.textInfo;

            // Update Text Statistics
            ObjectStats = "Characters: " + m_TextInfo.characterCount + "   Words: " + m_TextInfo.wordCount + "   Spaces: " + m_TextInfo.spaceCount + "   Sprites: " + m_TextInfo.spriteCount + "   Links: " + m_TextInfo.linkCount
                          + "\nLines: " + m_TextInfo.lineCount + "   Pages: " + m_TextInfo.pageCount;

            // Get the handle size for drawing the various
            m_ScaleMultiplier = m_TextComponent.GetType() == typeof(TextMeshPro) ? 1 : 0.1f;
            m_HandleSize = HandleUtility.GetHandleSize(m_Transform.position) * m_ScaleMultiplier;

            // Draw line metrics
            #region Draw Lines
            if (ShowLines)
                DrawLineBounds();
            #endregion

            // Draw word metrics
            #region Draw Words
            if (ShowWords)
                DrawWordBounds();
            #endregion

            // Draw character metrics
            #region Draw Characters
            if (ShowCharacters)
                DrawCharactersBounds();
            #endregion

            // Draw Quads around each of the words
            #region Draw Links
            if (ShowLinks)
                DrawLinkBounds();
            #endregion

            // Draw Quad around the bounds of the text
            #region Draw Bounds
            if (ShowMeshBounds)
                DrawBounds();
            #endregion

            // Draw Quad around the rendered region of the text.
            #region Draw Text Bounds
            if (ShowTextBounds)
                DrawTextBounds();
            #endregion
        }
Ejemplo n.º 3
0
 void Awake()
 {
     m_TextComponent = gameObject.GetComponent <TMP_Text>();
     if (m_TextComponent.GetType() == typeof(TextMeshProUGUI))
     {
         m_Canvas = gameObject.GetComponentInParent <Canvas>();
         if (m_Canvas != null)
         {
             if (m_Canvas.renderMode == RenderMode.ScreenSpaceOverlay)
             {
                 m_Camera = null;
             }
             else
             {
                 m_Camera = m_Canvas.worldCamera;
             }
         }
     }
     else
     {
         m_Camera = Camera.main;
     }
 }
Ejemplo n.º 4
0
    /// <summary>
    /// Override Unity Function
    /// </summary>
    void Awake()
    {
        textComponent = GetComponent <TMP_Text>();

        if (textComponent.GetType() == typeof(TextMeshProUGUI))
        {
            var canvas = GetComponentInParent <Canvas>();
            if (canvas != null)
            {
                if (canvas.renderMode == RenderMode.ScreenSpaceOverlay)
                {
                    cachedCamera = null;
                }
                else
                {
                    cachedCamera = canvas.worldCamera;
                }
            }
        }
        else
        {
            cachedCamera = Camera.main;
        }
    }