using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MyText : MonoBehaviour
{
bool m_xPlus = true;
public GameObject score_object = null;
// Textオブジェクト
public float score_num = 0; // スコア変数
void Start()
{
//DelayMethodを2秒後に呼び出し、以降は1秒毎に実行
InvokeRepeating(nameof(DelayMethod), 2.0f, 1.0f);
}
void DelayMethod()
{
Text score_text = score_object.GetComponent<text>();
score_text.color = new Color(1.0f, 0.0f, 0.0f, 1.0f);
score_text.fontSize = 80;
// テキストの表示を入れ替える
score_text.text = "Score:" + score_num;
if (m_xPlus)
{
score_num += 1;
if (score_num >= 20)
m_xPlus = false;
}
else
{
score_num -= 1;
if (score_num <= 0)
m_xPlus = true;
}
}
void Update()
{
}
}
////////////////////////////////