herbou / Unity_ToastUI

Unity cross-platform Toast UI package
MIT License
82 stars 20 forks source link

DissToast.Dismiss() before toast load error: NullReferenceException #3

Open reahaas opened 8 months ago

reahaas commented 8 months ago

In my function "Pause game" I have a call to "Toast.Dismiss();". This raises an error because the object is not initialized yet. To fix this, just add a call to "prepare" before dismissing. Error:

NullReferenceException: Object reference not set to an instance of an object
EasyUI.Toast.Toast.Dismiss () (at Assets/MyPackages/Toast UI/Scripts/Toast.cs:113)
GameManagerScript.pauseGame () (at Assets/Scripts/GameManagerScript.cs:126)
GameManagerScript.Update () (at Assets/Scripts/GameManagerScript.cs:95)
image
reahaas commented 8 months ago

PR open: https://github.com/herbou/Unity_ToastUI/pull/4

reahaas commented 8 months ago

Workaround: Use the public attribute of the class: isLoaded

if (Toast.isLoaded){
    Toast.Dismiss();
}