GameManager类
using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameManager : MonoBehaviour { private static GameManager gm; public static GameManager getGM{ get{ return gm; } } public int level = 1; public int HP = 100; void Awake () { gm = this; } public void addHP(int count){ HP = HP + count; } public void reduceHP(int count){ HP = HP - count; } }
在其他脚本中就可以调用GameManager里的方法
GameManager.getGM.addHP ();
暂无关于此日志的评论。