ArabDesert/Assets/1-arab desert/2.5 update/!!a/MIKI_PC_SDK3/script/Counter.cs

43 lines
997 B
C#

/*------------------------------------------------
Counter.cs
Copyright (c) 2020 0miki0
------------------------------------------------*/
using UdonSharp;
using UnityEngine;
using UnityEngine.UI;
using VRC.SDKBase;
public class Counter : UdonSharpBehaviour
{
[SerializeField] private Text targetText;
[SerializeField] private int count = 0;
// instance
void Start()
{
}
public override void OnPlayerJoined(VRCPlayerApi player)
{
count++;
targetText = this.GetComponent<Text>();
targetText.text = count.ToString();
if (targetText.text.Length == 1)
{
targetText.text = "0" + targetText.text;
}
}
public override void OnPlayerLeft(VRCPlayerApi player)
{
count--;
targetText = this.GetComponent<Text>();
targetText.text = count.ToString();
if (targetText.text.Length == 1)
{
targetText.text = "0" + targetText.text;
}
}
}