-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add animation to secret names in weapon select
- Loading branch information
1 parent
f67ed3b
commit bd77e85
Showing
6 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using TMPro; | ||
using UnityEngine; | ||
|
||
public class SecretNameTextAnimator : MonoBehaviour | ||
{ | ||
public TMP_Text textMesh; | ||
private bool isAnimated; | ||
public bool IsAnimated | ||
{ | ||
get | ||
{ | ||
return isAnimated; | ||
} | ||
set | ||
{ | ||
if (value) | ||
StartCoroutine(AnimateText()); | ||
if (!value) | ||
StopAllCoroutines(); | ||
isAnimated = value; | ||
} | ||
} | ||
|
||
private IEnumerator AnimateText() | ||
{ | ||
while (true) | ||
{ | ||
textMesh.ForceMeshUpdate(); | ||
var textInfo = textMesh.textInfo; | ||
for (int i = 0; i < textInfo.characterCount; i++) | ||
{ | ||
var charInfo = textInfo.characterInfo[i]; | ||
if (!charInfo.isVisible) | ||
continue; | ||
|
||
var charVertices = textInfo.meshInfo[charInfo.materialReferenceIndex].vertices; | ||
for (int j = 0; j < 4; j++) | ||
{ | ||
var position = charVertices[charInfo.vertexIndex + j]; | ||
charVertices[charInfo.vertexIndex + j] = position + new Vector3(0f, Mathf.Sin(Time.time * 2f + position.x * 0.01f) * 10f, 0f); | ||
Color32 rainbow = Color.HSVToRGB(Mathf.Abs(Mathf.Sin(Time.time * 0.5f + position.x * 0.1f)), 0.8f, 1.0f); | ||
textInfo.meshInfo[charInfo.materialReferenceIndex].colors32[charInfo.vertexIndex + j] = rainbow; | ||
} | ||
} | ||
textMesh.UpdateVertexData(TMP_VertexDataUpdateFlags.All); | ||
for (int i = 0; i < textInfo.meshInfo.Length; i++) | ||
{ | ||
var meshInfo = textInfo.meshInfo[i]; | ||
meshInfo.mesh.vertices = meshInfo.vertices; | ||
textMesh.UpdateGeometry(meshInfo.mesh, i); | ||
} | ||
yield return null; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters