Unity运用-get set
1、get set 访问器的应用
private string m_VerticalAxis = "Vertical"; public string verticalAxis { get { return m_VerticalAxis; } set { m_VerticalAxis = value; } }
class Bank { private int money;//私有字段 public int Money //属性 { //GET访问器,可以理解成另类的方法,返回已经被赋了值的私有变量money get { return money; } //SET访问器,将我们打入的值赋给私有变量money set { money = value; } } }

浙公网安备 33010602011771号