InteractiveScapeGmbH / TuioUnityClient

MIT License
14 stars 2 forks source link

Fix for NullReferenceException in TuioDebug.OnDestroy() #7

Open zukio opened 9 months ago

zukio commented 9 months ago

Thank you for providing this useful program!

My error: NullReferenceException: Object reference not set to an instance of an object TuioUnity.Utils.TuioDebug.OnDestroy () (at Library/PackageCache/com.interactive-scape.tuio_client@fc3d05d54a/Runtime/Utils/TuioDebug.cs:31)

TuioDebug.cs

 private void OnDestroy()
 {
     _tuioBehaviour.OnUpdate -= UpdateText;
     Destroy(_debugText.gameObject);
 }

Null check silences this error:

private void OnDestroy()
{
    if (_tuioBehaviour != null)
    {
        _tuioBehaviour.OnUpdate -= UpdateText;
    }
    if (_debugText != null && _debugText.gameObject != null)
    {
        Destroy(_debugText.gameObject);
    }
}

I apologies for the lack of explanation. English is not my native language. I hope this is helpful for improving the package. Thank you for your time and consideration.