【发布时间】:2021-11-29 11:26:10
【问题描述】:
我想为我的游戏创建一个游戏内商店,我想通过玩家偏好来省钱,但代码不起作用
public float AmountNumber;
public Text AmountText;
void Start() {
AmountText.text = PlayerPrefs.GetFloat("Amount").ToString();
}
// Update is called once per frame
void Update()
{
AmountText.text = AmountNumber.ToString();
PlayerPrefs.SetFloat("Amount", AmountNumber);
}
【问题讨论】:
-
它没有任何错误,它在我这边运行,它是最终脚本吗?我假设代码不是完整的代码,例如从 Monobehaviour 的类定义和继承,......它是否正确分配给场景中的 gameobject?
-
but the code isn't working没有有效的问题描述......你的问题到底是什么? -
另外请使用正确的标签!请注意,
unityscript是或更好的是曾经是一种 JavaScript 风格,类似于早期 Unity 版本中使用的自定义语言,并且现在已经不推荐使用了!你的代码显然是c#
标签: c# unity3d game-development