mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-02 20:24:26 -07:00
Initial commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TNHQoLImprovements
|
||||
{
|
||||
public class TokenCounter : MonoBehaviour
|
||||
{
|
||||
void Start()
|
||||
{
|
||||
transform.parent = GameObject.Find("_NewTAHReticle/TAHReticle_HealthBar").transform;
|
||||
transform.localPosition = new Vector3(1, 0, -.5f);
|
||||
transform.localRotation = Quaternion.Euler(90, 0, 0);
|
||||
transform.localScale = new Vector3(0.002f, 0.002f, 0.002f);
|
||||
|
||||
StartCoroutine(SetTokenImage());
|
||||
}
|
||||
|
||||
private IEnumerator SetTokenImage()
|
||||
{
|
||||
int debug_iterations = 0;
|
||||
Sprite tokenSprite = null;
|
||||
while (tokenSprite == null) // END: loop until Token sprite is found
|
||||
{
|
||||
var obj = GameObject.Find("_TNH_ObjectConstructor(Clone)/_CanvasHolder/_UITest_Canvas/Icon_0/Cost_1/Image");
|
||||
if (obj != null)
|
||||
{
|
||||
tokenSprite = obj.GetComponent<Image>().sprite;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_iterations++;
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
}
|
||||
}
|
||||
Debug.Log("Token sprite found after " + debug_iterations.ToString() + " iterations.");
|
||||
transform.GetChild(0).GetComponent<Image>().sprite = tokenSprite;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
int tokens = InPlay.tnhManager.GetNumTokens();
|
||||
transform.GetChild(1).GetComponent<Text>().text = tokens.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user