help!!!

summer_final 2020-02-17 05:38:26
实现功能:计时5秒后显示Iamge

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


public class time1 : MonoBehaviour {
int hour;
int minute;
int second;
int millisecond;
float timeSpend = 0.0f;

public GameObject cImage;

public Text text_timeSpend;
// Use this for initialization
void Start () {

cImage.active = false;

//canntImage.SetActive(false);

}

// Update is called once per frame
void Update () {
timeSpend += Time.deltaTime;


hour = (int)timeSpend / 3600;
minute = ((int)timeSpend - hour * 3600) / 60;
second = (int)timeSpend - hour * 3600 - minute * 60;
millisecond = (int)((timeSpend - (int)timeSpend) * 1000);
text_timeSpend.text = string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", hour, minute, second, millisecond);

if (second ==5)
{
cImage.active = true;

// canntImage.SetActive(true);

}

运行后显示:NullReferenceException: Object reference not set to an instance of an object求助解决
...全文
11 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

5,530

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 模式及实现
社区管理员
  • 模式及实现社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧