示例#1
0
        /// <summary>
        /// Internal method to add a new Color Gradient Preset to the dictionary.
        /// </summary>
        /// <param name="hashCode"></param>
        /// <param name="spriteAsset"></param>
        private void AddColorGradientPreset_Internal(int hashCode, TMP_ColorGradient spriteAsset)
        {
            if (m_ColorGradientReferenceLookup.ContainsKey(hashCode)) return;

            // Add reference to Color Gradient Preset Asset.
            m_ColorGradientReferenceLookup.Add(hashCode, spriteAsset);
        }
示例#2
0
 private void AddColorGradientPreset_Internal(int hashCode, TMP_ColorGradient spriteAsset)
 {
     if (!m_ColorGradientReferenceLookup.ContainsKey(hashCode))
     {
         m_ColorGradientReferenceLookup.Add(hashCode, spriteAsset);
     }
 }
示例#3
0
 private bool TryGetColorGradientPresetInternal(int hashCode, out TMP_ColorGradient gradientPreset)
 {
     gradientPreset = null;
     if (m_ColorGradientReferenceLookup.TryGetValue(hashCode, out gradientPreset))
     {
         return(true);
     }
     return(false);
 }
示例#4
0
        void Start()
        {
            //Set the color as it's unlocked or not
            if (!unlocked)
            {
                defaultTextColor = GetComponent <TextMeshProUGUI>().colorGradientPreset;
            }
            else
            {
                defaultTextColor = unlockedTextColor;
            }

            //lastTextcolor = defaultTextcolor;
            lastTextColor = unlockedTextColor;
            m_TextComponent.colorGradientPreset = defaultTextColor;
        }
 /// <summary>
 /// Function returning the Color Gradient Preset corresponding to the provided hash code.
 /// </summary>
 /// <param name="hashCode"></param>
 /// <param name="gradientPreset"></param>
 /// <returns></returns>
 public static bool TryGetColorGradientPreset(int hashCode, out TMP_ColorGradient gradientPreset)
 {
     return(MaterialReferenceManager.instance.TryGetColorGradientPresetInternal(hashCode, out gradientPreset));
 }
 /// <summary>
 /// Add new Color Gradient Preset to dictionary.
 /// </summary>
 /// <param name="hashCode"></param>
 /// <param name="spriteAsset"></param>
 public static void AddColorGradientPreset(int hashCode, TMP_ColorGradient spriteAsset)
 {
     MaterialReferenceManager.instance.AddColorGradientPreset_Internal(hashCode, spriteAsset);
 }
 public static void ON_COLOR_GRAIDENT_PROPERTY_CHANGED(TMP_ColorGradient gradient)
 {
     COLOR_GRADIENT_PROPERTY_EVENT.Call(gradient);
 }
示例#8
0
        void LateUpdate()
        {
            if (TMP_TextUtilities.IsIntersectingRectTransform(m_TextComponent.rectTransform, Input.mousePosition, m_Camera))
            {
                #region Example of Character or Sprite Selection
                int charIndex = TMP_TextUtilities.FindIntersectingCharacter(m_TextComponent, Input.mousePosition, m_Camera, false);
                if (charIndex != -1 && charIndex != m_lastCharIndex)
                {
                    m_lastCharIndex = charIndex;

                    TMP_TextElementType elementType = m_TextComponent.textInfo.characterInfo[charIndex].elementType;

                    // Send event to any event listeners depending on whether it is a character or sprite.
                    if (elementType == TMP_TextElementType.Character)
                    {
                        SendOnCharacterSelection(m_TextComponent.textInfo.characterInfo[charIndex].character, charIndex);
                    }
                    else if (elementType == TMP_TextElementType.Sprite)
                    {
                        SendOnSpriteSelection(m_TextComponent.textInfo.characterInfo[charIndex].character, charIndex);
                    }
                }
                #endregion


                #region Example of Word Selection
                // Check if Mouse intersects any words and if so assign a random color to that word.
                int wordIndex = TMP_TextUtilities.FindIntersectingWord(m_TextComponent, Input.mousePosition, m_Camera);
                if (wordIndex != -1 && wordIndex != m_lastWordIndex)
                {
                    m_lastWordIndex = wordIndex;

                    // Get the information about the selected word.
                    TMP_WordInfo wInfo = m_TextComponent.textInfo.wordInfo[wordIndex];

                    // Send the event to any listeners.
                    SendOnWordSelection(wInfo.GetWord(), wInfo.firstCharacterIndex, wInfo.characterCount);
                }
                #endregion


                #region Example of Line Selection
                // Check if Mouse intersects any words and if so assign a random color to that word.
                int lineIndex = TMP_TextUtilities.FindIntersectingLine(m_TextComponent, Input.mousePosition, m_Camera);

                if (lineIndex != -1 && lineIndex != m_lastLineIndex && unlocked)
                {
                    m_lastLineIndex = lineIndex;
                    m_TextComponent.colorGradientPreset = hoverTextColor;
                    lastTextColor = hoverTextColor;
                    //changeHoverColorNext = false;

                    // Get the information about the selected word.
                    TMP_LineInfo lineInfo = m_TextComponent.textInfo.lineInfo[lineIndex];

                    // Send the event to any listeners.
                    char[] buffer = new char[lineInfo.characterCount];
                    for (int i = 0; i < lineInfo.characterCount && i < m_TextComponent.textInfo.characterInfo.Length; i++)
                    {
                        buffer[i] = m_TextComponent.textInfo.characterInfo[i + lineInfo.firstCharacterIndex].character;
                    }

                    string lineText = new string(buffer);

                    SendOnLineSelection(lineText, lineInfo.firstCharacterIndex, lineInfo.characterCount);
                }



                #endregion


                #region Example of Link Handling
                // Check if mouse intersects with any links.
                int linkIndex = TMP_TextUtilities.FindIntersectingLink(m_TextComponent, Input.mousePosition, m_Camera);

                // Handle new Link selection.
                if (linkIndex != -1 && linkIndex != m_selectedLink)
                {
                    m_selectedLink = linkIndex;

                    // Get information about the link.
                    TMP_LinkInfo linkInfo = m_TextComponent.textInfo.linkInfo[linkIndex];

                    // Send the event to any listeners.
                    SendOnLinkSelection(linkInfo.GetLinkID(), linkInfo.GetLinkText(), linkIndex);
                }
                #endregion
            }
            //else if (!changeHoverColorNext)
            else if (!selected && lastTextColor != defaultTextColor)
            {
                m_TextComponent.colorGradientPreset = defaultTextColor;
                m_lastLineIndex = -1;
                lastTextColor   = defaultTextColor;
                //Debug.Log("Changed to default color!");
            }
            else if (selected && lastTextColor != hoverTextColor)
            {
                m_TextComponent.colorGradientPreset = hoverTextColor;
                lastTextColor = hoverTextColor;
                //Debug.Log("Changed to hovercolor color!");
            }
        }
示例#9
0
 private bool TryGetColorGradientPresetInternal(int hashCode, out TMP_ColorGradient gradientPreset)
 {
     gradientPreset = null;
     return(this.m_ColorGradientReferenceLookup.TryGetValue(hashCode, out gradientPreset));
 }
示例#10
0
 public static void AddColorGradientPreset(int hashCode, TMP_ColorGradient spriteAsset)
 {
     instance.AddColorGradientPreset_Internal(hashCode, spriteAsset);
 }
示例#11
0
 public static bool TryGetColorGradientPreset(int hashCode, out TMP_ColorGradient gradientPreset)
 {
     return(instance.TryGetColorGradientPresetInternal(hashCode, out gradientPreset));
 }