Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Time.time

マニュアルに切り替える
public static float time;

説明

このフレームの開始する時間(Read Only)。ゲーム開始からの時間(秒)です。

ひとつのフレームで複数回呼び出す場合は同じ値を返します。 MonoBehaviour の FixedUpdate 内部から呼び出されたとき、 fixedTime プロパティーを返します。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public GameObject projectile; public float fireRate = 0.5F; private float nextFire = 0.0F; void Update() { if (Input.GetButton("Fire1") && Time.time > nextFire) { nextFire = Time.time + fireRate; GameObject clone = Instantiate(projectile, transform.position, transform.rotation) as GameObject; } } }

注意: time はすべての Awake 関数が呼び出された後に初期化されます。 time の値は Awake 関数中は定義されていません。