private static List <TypedTextSymbol> CreateSymbolListFromText(string text) { var symbolList = new List <TypedTextSymbol>(); int parsedCharacters = 0; while (parsedCharacters < text.Length) { TypedTextSymbol symbol = null; // Check for tags var remainingText = text.Substring(parsedCharacters, text.Length - parsedCharacters); if (RichTextTag.StringStartsWithTag(remainingText)) { var tag = RichTextTag.ParseNext(remainingText); symbol = new TypedTextSymbol(tag); } else { symbol = new TypedTextSymbol(remainingText.Substring(0, 1)); } parsedCharacters += symbol.Length; symbolList.Add(symbol); } return(symbolList); }
/// <summary> /// 根据字符串创建文本标记 /// </summary> /// <param name="_text"></param> /// <returns></returns> private static void CreateSymbolsFromText(string _text) { int textSymbolIndex = 0; int parsedCharacters = 0; while (parsedCharacters < _text.Length) { TextSymbol symbol = null; // 检查富文本标签 var remainingText = _text.Substring(parsedCharacters, _text.Length - parsedCharacters); if (RichTextTag.StringStartsWithTag(remainingText)) { var tag = RichTextTag.ParseNext(remainingText); if (null != tag) { // 富文本标签的文本标记 symbol = GetTextSymbol(textSymbolIndex++); symbol.Tag = tag; } } if (null == symbol) { // 普通字符的文本标记 symbol = GetTextSymbol(textSymbolIndex++); symbol.Character = remainingText.Substring(0, 1); } parsedCharacters += symbol.Length; } m_ValidTextSymbolCount = textSymbolIndex; }
public void Update() { if (Input.GetKeyDown(KeyCode.Tilde)) { var tag = RichTextTag.ParseNext("blah<color=red>boo</color"); LogTag(tag); tag = RichTextTag.ParseNext("<color=blue>blue</color"); LogTag(tag); tag = RichTextTag.ParseNext("No tag in here"); LogTag(tag); tag = RichTextTag.ParseNext("No <color=blueblue</color tag here either"); LogTag(tag); tag = RichTextTag.ParseNext("This tag is a closing tag </bold>"); LogTag(tag); } if (Input.GetKeyDown(KeyCode.Space)) { HandlePrintNextClicked(); } }
public void Update() { if (Input.GetKeyDown(KeyCode.Tilde)) { var tag = RichTextTag.ParseNext("blah<color=red>boo</color"); LogTag(tag); tag = RichTextTag.ParseNext("<color=blue>blue</color"); LogTag(tag); tag = RichTextTag.ParseNext("No tag in here"); LogTag(tag); tag = RichTextTag.ParseNext("No <color=blueblue</color tag here either"); LogTag(tag); tag = RichTextTag.ParseNext("This tag is a closing tag </bold>"); LogTag(tag); } if (Input.GetButtonUp("Shoot") || Input.GetButtonUp("Use")) { HandlePrintNextClicked(); } if (choiceButtons[0].IsActive() && initializeButtonChoice == false) { if (Input.GetButtonUp("MoveLeft")) { choiceButtons[0].FindSelectableOnLeft(); initializeButtonChoice = true; } else if (Input.GetButtonUp("MoveRight")) { choiceButtons[0].FindSelectableOnRight(); initializeButtonChoice = true; } else if (Input.GetButtonUp("Shoot") || Input.GetButtonUp("Use")) { choiceButtons[0].Select(); initializeButtonChoice = true; } } }