UILabel.GetWordAtCharacterIndex C# (CSharp) Méthode

GetWordAtCharacterIndex() public méthode

Retrieve the word right under the specified character index.
public GetWordAtCharacterIndex ( int characterIndex ) : string
characterIndex int
Résultat string
	public string GetWordAtCharacterIndex (int characterIndex)
	{
		if (characterIndex != -1 && characterIndex < mText.Length)
		{
			int linkStart = mText.LastIndexOf(' ', characterIndex, characterIndex) + 1;
			int linkEnd = mText.IndexOf(' ', characterIndex);
			if (linkEnd == -1) linkEnd = mText.Length;

			if (linkStart != linkEnd)
			{
				string word = mText.Substring(linkStart, linkEnd - linkStart);
				return NGUIText.StripSymbols(word);
			}
		}
		return null;
	}

Usage Example

    static int GetWordAtCharacterIndex(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        UILabel obj  = (UILabel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UILabel");
        int     arg0 = (int)LuaScriptMgr.GetNumber(L, 2);
        string  o    = obj.GetWordAtCharacterIndex(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
All Usage Examples Of UILabel::GetWordAtCharacterIndex