Example #1
0
        //public TMP_Style()

        //{

        //Debug.Log("New Style with Name: " + m_Name + " was created. ID: ");

        //}



        /// <summary>

        /// Function to update the content of the int[] resulting from changes to OpeningDefinition & ClosingDefinition.

        /// </summary>

        public void RefreshStyle()

        {
            m_HashCode = TMP_TextUtilities.GetSimpleHashCode(m_Name);



            m_OpeningTagArray = new int[m_OpeningDefinition.Length];

            for (int i = 0; i < m_OpeningDefinition.Length; i++)
            {
                m_OpeningTagArray[i] = m_OpeningDefinition[i];
            }



            m_ClosingTagArray = new int[m_ClosingDefinition.Length];

            for (int i = 0; i < m_ClosingDefinition.Length; i++)
            {
                m_ClosingTagArray[i] = m_ClosingDefinition[i];
            }



#if UNITY_EDITOR
            // Event to update objects when styles are changed in the editor.

            TMPro_EventManager.ON_TEXT_STYLE_PROPERTY_CHANGED(true);
#endif
        }
        /// <summary>
        ///
        /// </summary>
        private void LoadStyleDictionaryInternal()
        {
            if (m_StyleLookupDictionary == null)
            {
                m_StyleLookupDictionary = new Dictionary <int, TMP_Style>();
            }
            else
            {
                m_StyleLookupDictionary.Clear();
            }

            // Read Styles from style list and store them into dictionary for faster access.
            for (int i = 0; i < m_StyleList.Count; i++)
            {
                m_StyleList[i].RefreshStyle();

                if (!m_StyleLookupDictionary.ContainsKey(m_StyleList[i].hashCode))
                {
                    m_StyleLookupDictionary.Add(m_StyleList[i].hashCode, m_StyleList[i]);
                }
            }

            #if UNITY_EDITOR
            //// Event to update objects when styles are changed in the editor.
            TMPro_EventManager.ON_TEXT_STYLE_PROPERTY_CHANGED(true);
            #endif
        }
 public void RefreshStyle()
 {
     m_HashCode        = TMP_TextUtilities.GetSimpleHashCode(m_Name);
     m_OpeningTagArray = new int[m_OpeningDefinition.Length];
     for (int i = 0; i < m_OpeningDefinition.Length; i++)
     {
         m_OpeningTagArray[i] = m_OpeningDefinition[i];
     }
     m_ClosingTagArray = new int[m_ClosingDefinition.Length];
     for (int j = 0; j < m_ClosingDefinition.Length; j++)
     {
         m_ClosingTagArray[j] = m_ClosingDefinition[j];
     }
     TMPro_EventManager.ON_TEXT_STYLE_PROPERTY_CHANGED(/*isChanged:*/ true);
 }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        private void LoadStyleDictionaryInternal()
        {
            if (m_StyleLookupDictionary == null)
            {
                m_StyleLookupDictionary = new Dictionary <int, TMP_Style>();
            }
            else
            {
                m_StyleLookupDictionary.Clear();
            }

            // Read Styles from style list and store them into dictionary for faster access.
            for (int i = 0; i < m_StyleList.Count; i++)
            {
                m_StyleList[i].RefreshStyle();

                if (!m_StyleLookupDictionary.ContainsKey(m_StyleList[i].hashCode))
                {
                    m_StyleLookupDictionary.Add(m_StyleList[i].hashCode, m_StyleList[i]);
                }
            }

            // Add Normal Style if it does not already exists
            int normalStyleHashCode = TMP_TextParsingUtilities.GetHashCode("Normal");

            if (!m_StyleLookupDictionary.ContainsKey(normalStyleHashCode))
            {
                TMP_Style style = new TMP_Style("Normal", string.Empty, string.Empty);
                m_StyleList.Add(style);
                m_StyleLookupDictionary.Add(normalStyleHashCode, style);
            }

            #if UNITY_EDITOR
            //// Event to update objects when styles are changed in the editor.
            TMPro_EventManager.ON_TEXT_STYLE_PROPERTY_CHANGED(true);
            #endif
        }