【发布时间】:2015-12-12 18:48:32
【问题描述】:
我正在设计我的第一个游戏,我正在尝试创建一个步长为 5 秒的时间变量(比如比实时慢 5 倍)。
这是我拥有 GUI 的地方(仅粘贴相关部分):
using UnityEngine;
using Assets.Code.Interfaces;
using Assets.Code.Scripts;
using Assets.Code.PowerPlants;
namespace Assets.Code.States
Debug.Log (TimeManager.gametime);
public void ShowIt()
{
GUI.Box (new Rect (Screen.width - 650, 10, 100, 25), TimeManager.gametime.ToString() ); // GAME TIME HOURS
}
这是计算我的游戏时间的地方:
using System;
using UnityEngine;
namespace Assets.Code.Scripts
{
public class TimeManager
{
public static int gametime;
public TimeManager ()
{
gametime = (int)Time.timeSinceLevelLoad / 5;
}
}
}
我没有收到错误,但游戏时间的值始终为 0。这以前有效,但不再有效,我不知道为什么。有什么提示吗?
【问题讨论】:
标签: c# unity3d unity3d-gui