public static float realtimeSinceStartup ;

説明

ゲーム開始からのリアルタイム(秒)(Read Only)

ほぼすべてのケースでできますが、代わりに Time.time を使用する必要があります。



他の例:

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { print(Time.realtimeSinceStartup); } }
using UnityEngine;
using System.Collections;

// An FPS counter. // It calculates frames/second over each updateInterval, // so the display does not keep changing wildly. public class ExampleClass : MonoBehaviour { public float updateInterval = 0.5F; private double lastInterval; private int frames = 0; private float fps; void Start() { lastInterval = Time.realtimeSinceStartup; frames = 0; }

void OnGUI() { GUILayout.Label("" + fps.ToString("f2")); }

void Update() { ++frames; float timeNow = Time.realtimeSinceStartup; if (timeNow > lastInterval + updateInterval) { fps = (float)(frames / (timeNow - lastInterval)); frames = 0; lastInterval = timeNow; } } }