phaser icon indicating copy to clipboard operation
phaser copied to clipboard

Input Debug not removed when Input cleared from GameObject

Open spayton opened this issue 2 years ago • 0 comments

Version

Phaser 3.6 beta

Description

When debug is enabled on a game object input and then the input is subsequently cleared, any debug object is left hanging.

Additional Information

I have been testing a fix for this, which works, but I'm not sure if this is the best way. Needs someone with a better system overview to approve.

I'm simply removing the debug in InputPlugin.clear() before the gameobject reference is released, eg

        // If GameObject.input already cleared from higher class
        if (input)
        {
            input.gameObject.scene.input.removeDebug(input.gameObject); // <-- this line added
            input.gameObject = undefined;
            input.target = undefined;
            input.hitArea = undefined;
            input.hitAreaCallback = undefined;
            input.callbackContext = undefined;

            gameObject.input = null;
        }

spayton avatar Jun 08 '22 16:06 spayton