環境メモ
⭐️Mac OS Mojave バージョン10.14
⭐️Xcode version 10.0(10A255)
⭐️Unity 2018.2.15f1
実際に動かした動画はこちら↓↓
https://twitter.com/nonnonkapibara/status/1073235671882448896
UnityでVRシューティングゲーム作成しながら勉強してますっ!!
— non (@nonnonkapibara) 2018年12月13日
(●^o^●)v
あと、タイトル画面とスマホ用の書き出しは、週末やるぞ!#Unity #VR pic.twitter.com/btpJCQplzf


RemainTimer
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Text))]
public class RemainTimer : MonoBehaviour
{
[SerializeField] float gameTime = 20.0f; // ゲーム制限時間 [s]
Text uiText; // UIText コンポーネント
float currentTime; // 残り時間タイマー
void Start()
{
// Textコンポーネント取得
uiText = GetComponent<Text>();
// 残り時間を設定
currentTime = gameTime;
}
void Update()
{
// 残り時間を計算する
currentTime -= Time.deltaTime;
// ゼロ秒以下にならないようにする
if (currentTime <= 0.0f)
{
currentTime = 0.0f;
}
int minutes = Mathf.FloorToInt(currentTime / 60F);
int seconds = Mathf.FloorToInt(currentTime - minutes * 60);
int mseconds = Mathf.FloorToInt((currentTime - minutes * 60 - seconds) * 1000);
uiText.text = string.Format("{0:00}:{1:00}:{2:000}", minutes, seconds, mseconds);
}
}