-
Notifications
You must be signed in to change notification settings - Fork 0
/
MagicText.cs
69 lines (38 loc) · 1.49 KB
/
MagicText.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using ThunderRoad;
using TMPro;
namespace WandSpellss
{
class MagicText : MonoBehaviour
{
public TMP_Text textComponent;
void Start() {
textComponent = this.gameObject.AddComponent<TextMeshPro>();
}
void Update() {
textComponent.ForceMeshUpdate();
var textInfo = textComponent.textInfo;
for (int i = 0; i < textInfo.characterCount; ++i) {
var charInfo = textInfo.characterInfo[i];
if (!charInfo.isVisible) {
continue;
}
var verts = textInfo.meshInfo[charInfo.materialReferenceIndex].vertices;
for (int j = 0; j < 4; ++j) {
var orig = verts[charInfo.vertexIndex + j];
verts[charInfo.vertexIndex + j] = orig + new Vector3(0, Mathf.Sin(Time.time * 2f + orig.x * 0.01f) * 10f, 0);
}
}
for (int i = 0; i < textInfo.meshInfo.Length; ++i) {
var meshInfo = textInfo.meshInfo[i];
meshInfo.mesh.vertices = meshInfo.vertices;
textComponent.UpdateGeometry(meshInfo.mesh, i);
}
}
}
}