Ejemplo n.º 1
0
        private void RepopulateLayoutGroup()
        {
            int prevNumLines = textContainers.Count;
            int numLines     = Mathf.Max(0, Mathf.FloorToInt(LineLayoutGroup.rect.height / VirtualConsoleComplexLinePrefab.rect.height));
            int deltaLines   = numLines - prevNumLines;

            if (deltaLines < 0)
            {
                for (int i = 0; i < -deltaLines; ++i)
                {
                    Destroy(textContainers[i].gameObject);
                }
                textContainers.RemoveRange(0, -deltaLines);
            }
            else if (deltaLines > 0)
            {
                for (int i = 0; i < deltaLines; ++i)
                {
                    RectTransform             newLine    = Instantiate(VirtualConsoleComplexLinePrefab, LineLayoutGroup);
                    VirtualConsoleComplexLine tContainer = newLine.GetComponent <VirtualConsoleComplexLine>();

                    int historyLineIndex = History.CompletedLines.Count - numLines + i;
                    if (historyLineIndex >= 0 && historyLineIndex < History.CompletedLines.Count)
                    {
                        tContainer.SetContent(History.CompletedLines[historyLineIndex]);
                    }
                    else
                    {
                        tContainer.SetContent(new List <TextBlock>());
                    }
                    newLine.SetAsFirstSibling();
                    textContainers.Insert(0, tContainer);
                }
            }
        }
Ejemplo n.º 2
0
 private void BeginNewTextBlock(bool newline)
 {
     if (newline)
     {
         VirtualConsoleComplexLine line = textContainers[0];
         textContainers.RemoveAt(0);
         textContainers.Add(line);
         line.SetContent(null);
         line.UITransform.SetAsLastSibling();
         activeTextBlocks.Clear();
     }
     activeTextBlocks.Add(null);
 }