// dialgoue box private CharInfoWrapper ShowLetter(char ch, Vector2 lastPos, Transform charOrigin) { if (char.IsWhiteSpace(ch)) { return(null); } PFontLoader.CharInfo ci = pFontLoader.chars[char.ToUpper(ch)]; var go = OP.GetItem(); var sr = go.GetComponent <SpriteRenderer>(); CharInfoWrapper ciw = new CharInfoWrapper(ci, go); if (sr == null) { sr = go.AddComponent <SpriteRenderer>(); sr.sortingLayerID = DialogueBoxAnim.gameObject.GetComponent <SpriteRenderer>().sortingLayerID; sr.sortingOrder = 1; } go.transform.SetParent(charOrigin); lastPos = getNextPos(lastPos, ci); go.transform.localPosition = lastPos; go.SetActive(true); recycleObject.Add(go); sr.sprite = ci.sprite; this.lastPos.Set(lastPos.x + ci.width / 2 / pixelPerUnit, lastPos.y); return(ciw); }
// ---------- WORDS PARSER ---------------------------------------------------------------- public bool digestNextLetter() { if (nextSentence.Count == 0) { return(false); } char ch = nextSentence.Dequeue(); bool isletter = false; CharInfoWrapper ciw = null; if (char.IsWhiteSpace(ch)) { lastPos.Set(lastPos.x + pFontLoader.charWidthInPixel / pixelPerUnit, lastPos.y); wordObject.Clear(); } else if (char.IsLetter(ch)) { ciw = ShowLetter(ch, lastPos, charOrigin); isletter = true; } else if (pFontLoader.chars.Keys.Contains(ch)) { ciw = ShowLetter(ch, lastPos, charOrigin); isletter = true; } else { throw new InvalidDataException(); } if (isletter) { wordObject.Add(ciw); } return(true); }