VisualLogger.cs
757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using LAViD.Unity.Utils;
using System.Collections.Generic;
using UnityEngine.UI;
namespace LAViD.VLibras.Utils {
public class VisualLogger : PlayerLogger {
private Text textObj;
public int maximumLines = 20;
private List<string> logs = new List<string>();
private bool logged = false;
protected override void Start()
{
base.Start();
this.textObj = this.gameObject.GetComponent<Text>();
}
protected override void write(string text)
{
this.logs.Insert(0, text);
if (this.logs.Count > this.maximumLines)
this.logs.RemoveAt(this.logs.Count - 1);
logged = true;
}
public void Update()
{
if (logged)
{
logged = false;
this.textObj.text = string.Join("\n", this.logs.ToArray());
}
}
}
}