Skip to content

Fix for NullReferenceException in TuioDebug.OnDestroy() #7

@zukio

Description

@zukio

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions