コード例 #1
0
    public void AddFunds(float amount)
    {
        _cashMoney += amount;

        // This ? operator is called null propagation, and means it will only trigger
        // if OnUpdateBalance is not null. This is true only if there are no
        // subscribers to that event.
        OnUpdateBalance?.Invoke();
    }
コード例 #2
0
 public void DeductFunds(float amount)
 {
     _cashMoney -= amount;
     OnUpdateBalance?.Invoke();
 }