在uzAIZombieStateManager脚本第457行添加死后执行代码,并把怪物的金钱值Gold传到GameManager里,然后再界面上显示出来。
public void Die()
{
GameManager._instance.Add(gold);
因为弄不明白Gold参数为什么在面板上显示不出来,所以在怪物身上创建了一个 UzGold脚本
/// <summary>
/// 僵尸的携带金币
/// </summary>
public class UzGold : MonoBehaviour
{
public int MyGold = 0;
public static UzGold _instance;
private void Awake()
{
_instance = this;
}
}
然后在uzAIZombieStateManager脚本里把MyGold的值赋给gold
void Awake()
{
gold = transform.GetComponent<UzGold>().MyGold;