- Home /
Question by
softmarshmallow · Feb 13, 2017 at 08:12 AM ·
delegatecallbackaction
public static Callback problems
public class CoinController : MonoBehaviour {
public static Action<int> onCoinUpdated;
}
in another script
public class CoinDisplay : MonoBehaviour {
public Text coinAmountText;
void Awake()
{
CoinController.onCoinUpdated += UpdateCoinAmount;
SetCoinAmount(CoinController.coinAmount);
}
}
moved scene. and called
CoinController.onCoinUpdated(100);
still "UpdateCoinAmount" getting called and raises MissingReferenceException
why would't callback gets destroyed by it self when it's gameobject gets destroyed?? and how to make that happen??
Comment