...
class test : IRLMonoBehaviour
{
...
//主工程调用到热更新层 OnAwake
protected override void OnAwake()
{
...
//加入update注册
ILRuntimeWrapper.Instance.RegistUpdate(Update);
...
}
//主工程调用到热更新层 OnClose
public override void OnClose()
{
//关闭update方法注册
ILRuntimeWrapper.Instance.RemoveUpdate(Update);
}
...
public void startCountDown(string str,int time_)//time_秒数,可以改为float变量
{
Debug.Log("test startCountDown time1:" + time);
time = time_*50;//update每帧 大约为 0.02秒,20ms
Debug.Log("test startCountDown time2:" + time);
if (time > 0)
{
text.text = str;
}
}
//UI层注册update方法
void Update()
{
Debug.Log("test startCountDown Update time:" + time);
//Debug.Log("测试update的调用");
if (time == -11)
{
return;
}
if (time > 0)
{
Debug.Log("test star
[Unity][C#][ILRuntime]热更新中使用update倒计时
最新推荐文章于 2025-11-06 10:48:23 发布
本文详细介绍了如何在Unity游戏开发中,利用C#和ILRuntime技术进行热更新,并实现了更新过程中的倒计时功能。通过ILRuntime,可以实现在不重启应用的情况下更新游戏代码,提高用户体验。

最低0.47元/天 解锁文章
9608

被折叠的 条评论
为什么被折叠?



