예제 #1
0
 public void UpdateStyleDictionaryKey(int old_key, int new_key)
 {
     if (m_StyleDictionary.ContainsKey(old_key))
     {
         TMP_Style value = m_StyleDictionary[old_key];
         m_StyleDictionary.Add(new_key, value);
         m_StyleDictionary.Remove(old_key);
     }
 }
예제 #2
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
        }