问题描述
我的游戏评分系统需要您的帮助吗?我在本地测试了游戏,得分完美,可以在不同场景中显示相同的得分。不幸的是,当我将其构建为 HTML5 WebGL 并将其上传到我的网站时,分数在其他场景中没有显示。我不确定是什么导致了这个问题,下面是编码:
第一个文件:StaticVar.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StaticVar : MonoBehavIoUr
{
public Transform player;
public static float num = 0;
// Update is called once per frame
// void Update()
// {
// num = player.position.z;
// }
public void OnCollisionEnter(Collision other)
{
if(other.gameObject.tag != "Hit")
{
num++;
// Debug.Log("Amount of time bumped into walls " + hits);
}
}
}
第二个文件:score.cs
using UnityEngine;
using UnityEngine.UI;
public class score : MonoBehavIoUr
{
public Transform player;
public Text scoreText;
// Update is called once per frame
void Update()
{
scoreText.text = StaticVar.num.ToString("0");
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)