-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDisplaySection.cs
53 lines (50 loc) · 1.73 KB
/
DisplaySection.cs
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
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
namespace PerfectionDisplay
{
class DisplaySection : MonoBehaviour
{
public PerfectDisplay perfectDisplay;
TextMeshPro scoreMesh;
public string title;
public string color;
void Awake()
{
scoreMesh = Instantiate(Resources.FindObjectsOfTypeAll<TextMeshPro>().First());
scoreMesh.transform.SetParent(transform);
scoreMesh.text = "";
scoreMesh.fontSize = 4;
scoreMesh.lineSpacing = -25f;
scoreMesh.lineSpacingAdjustment = -25f;
scoreMesh.paragraphSpacing = -25f;
scoreMesh.color = Color.white;
scoreMesh.font = Plugin.mainFont;
scoreMesh.overflowMode = TextOverflowModes.Overflow;
scoreMesh.enableWordWrapping = false;
scoreMesh.richText = true;
scoreMesh.alignment = TextAlignmentOptions.Center;
}
public void UpdateText(int score, string percent)
{
if (!perfectDisplay.showNumbers && !perfectDisplay.showPercent) return;
string text = "<color=" + color + ">" + title+"\n";
if (perfectDisplay.showNumbers) text += score + "\n";
if (perfectDisplay.showPercent) text += percent + "%";
scoreMesh.text = text;
scoreMesh.ForceMeshUpdate();
}
public void UpdatePosition(float x)
{
transform.localPosition = perfectDisplay.displayPosition+new Vector3(x,0,0);
}
public float GetWidth()
{
return scoreMesh.GetRenderedValues().x+0.1f;
}
}
}