/// <summary> /// Analyzes UI for display. Assumes ideal height for provided width wihtout invalidating or painting. /// </summary> /// <param name="g">A Graphics object used for measurements.</param> /// <param name="width">Control's width.</param> public void Analyze(Graphics g, int width) { bool isTextPoolNew = textPool == null; // If width or script has not changed, nothing to do. if (analyzedWidth == width) return; analyzedWidth = Width; positionedBlocks = null; targetHiliteIndexes = null; // This is how we measure StringFormat sf = StringFormat.GenericTypographic; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; // On-demand: measure a space's width - for entry text flow // Also line height in entry text if (spaceWidth == 0) { SizeF sz = g.MeasureString(spaceTestStr, getFont(fntSenseLatin), 65535, sf); spaceWidth = (int)sz.Width; lemmaCharHeight = sz.Height; lemmaLineHeight = sz.Height * Magic.LemmaLineHeightScale; sz = g.MeasureString(Magic.PinyinSpaceTestString, getFont(fntPinyinHead), 65535, sf); pinyinSpaceWidth = sz.Width; } // Create text pool if needed if (textPool == null) textPool = new TextPool(); // Headword and pinyin // Will not measure redundantly doAnalyzeHeadword(g); doAnalyzePinyin(g); // OK, now onto body // Measure blocks in themselves on demand // Will not measure redundantly doMeasureBlocks(g); // Finalize text pool - compact in memory if (isTextPoolNew) textPool.FinishBuilding(); // Get rid of entry. Not keeping it in memory once we're done analyzing. entry = null; // Arrange blocks float lemmaW = ((float)width) - headInfo.HeadwordRight - padMid - padRight; float lemmaL = headInfo.HeadwordRight + padMid; float lastTop = doArrangeBlocks(lemmaL, lemmaW); // My height: bottom of headword or bottom of entry, whichever is lower float entryHeight = lastTop + padBottom; float zhoHeight = headInfo.HeadwordBottom + padBottom; float trueHeight = Math.Max(entryHeight, zhoHeight); // Assume this height, and also provided width Size = new Size(width, (int)trueHeight); }
void AddElement(string element) { GameObject text = TextPool.GetOneText(); text.transform.parent = grid.transform; text.GetComponent <Text>().text = element; }
//The elements add from the left to the right. void AddHeader(string header) { GameObject text = TextPool.GetOneText(); text.transform.parent = grid.transform; text.GetComponent <Text>().fontStyle = FontStyle.Bold; text.GetComponent <Text>().text = header; }
// Use this for initialization void Start() { text_pool_obj = Instantiate(text_pool_prefab, transform.parent); Vector2 size = GetComponentInParent <RectTransform>().sizeDelta; text_pool_obj.transform.localScale = new Vector3(size.x / width, size.y / height, 1); text_pool = text_pool_obj.GetComponent <TextPool>(); key = 0; }
public void Init(TextPool _pool) { if (inited) { return; } pool = _pool; box = Instantiate(box_prefab, transform); text = Instantiate(text_prefab, transform); time = 0; inited = true; }
public void Init(TextPool _pool) { if (inited) { return; } pool = _pool; portrait = Instantiate(portrait_prefab, transform); box = Instantiate(box_prefab, transform); speaker = Instantiate(speaker_prefab, transform); text = Instantiate(text_prefab, transform); game_controller = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); inited = true; }
private void Awake() { Instance = this; dictOfPools = new Dictionary <string, Queue <GameObject> >(); dictOfPrefabs = new Dictionary <string, GameObject>(); foreach (GameObject prefab in prefabs) { dictOfPools.Add(prefab.name, new Queue <GameObject>()); dictOfPrefabs.Add(prefab.name, prefab); } foreach (TextPools item in Enum.GetValues(typeof(TextPools))) { GrowPool(item, 3); } }
protected virtual void Awake() { targets = new List <Character>(); foreach (var tag in enemyTags) { sight.AddTargetTag(tag); } sight.OnDetectIn += target => { Character t = target.GetComponent <Character>(); t.OnDead += RemoveTarget; targets.Add(t); }; sight.OnDetectOut += target => { Character t = target.GetComponent <Character>(); RemoveTarget(t); }; damageText = CacheObjectManager.GetAsStatic <TextPool>("DamageText"); healText = CacheObjectManager.GetAsStatic <TextPool>("HealText"); }
private void Start() { textPool = transform.GetChild(0).GetComponent <TextPool>(); camera_ = Camera.main; }
// Use this for initialization void Start() { instance = this; StatementObjList = new StatementObjectList (); ParagraphObjs = new List<ParagraphObject>(); ParagraphObject p1 = new ParagraphObject (); ParagraphObjs.Add (p1); ParagraphObject p2 = new ParagraphObject (); ParagraphObjs.Add (p2); ParagraphObject p3 = new ParagraphObject (); ParagraphObjs.Add (p3); ParagraphObject p4 = new ParagraphObject (); ParagraphObjs.Add (p4); }
void Awake() { Instance = this; }
/// <summary> /// Analyzes UI for display. Assumes ideal height for provided width wihtout invalidating or painting. /// </summary> /// <param name="g">A Graphics object used for measurements.</param> /// <param name="width">Control's width.</param> public void Analyze(Graphics g, int width) { bool isTextPoolNew = textPool == null; // If width or script has not changed, nothing to do. if (analyzedWidth == width) { return; } analyzedWidth = Width; positionedBlocks = null; targetHiliteIndexes = null; // This is how we measure StringFormat sf = StringFormat.GenericTypographic; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; // On-demand: measure a space's width - for entry text flow // Also line height in entry text if (spaceWidth == 0) { SizeF sz = g.MeasureString(spaceTestStr, getFont(fntSenseLatin), 65535, sf); spaceWidth = (int)sz.Width; lemmaCharHeight = sz.Height; lemmaLineHeight = sz.Height * Magic.LemmaLineHeightScale; sz = g.MeasureString(Magic.PinyinSpaceTestString, getFont(fntPinyinHead), 65535, sf); pinyinSpaceWidth = sz.Width; } // Create text pool if needed if (textPool == null) { textPool = new TextPool(); } // Headword and pinyin // Will not measure redundantly doAnalyzeHeadword(g); doAnalyzePinyin(g); // OK, now onto body // Measure blocks in themselves on demand // Will not measure redundantly doMeasureBlocks(g); // Finalize text pool - compact in memory if (isTextPoolNew) { textPool.FinishBuilding(); } // Get rid of entry. Not keeping it in memory once we're done analyzing. entry = null; // Arrange blocks float lemmaW = ((float)width) - headInfo.HeadwordRight - padMid - padRight; float lemmaL = headInfo.HeadwordRight + padMid; float lastTop = doArrangeBlocks(lemmaL, lemmaW); // My height: bottom of headword or bottom of entry, whichever is lower float entryHeight = lastTop + padBottom; float zhoHeight = headInfo.HeadwordBottom + padBottom; float trueHeight = Math.Max(entryHeight, zhoHeight); // Assume this height, and also provided width Size = new Size(width, (int)trueHeight); }