Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions stop working after refresh #62

Open
SamNugget opened this issue Jan 11, 2025 · 0 comments
Open

Extensions stop working after refresh #62

SamNugget opened this issue Jan 11, 2025 · 0 comments

Comments

@SamNugget
Copy link

When using a custom extension, if you refresh chrome with dev tools open, the custom extension does not work until dev tools is reopened;

To reproduce, use this custom extension:

import { ButtonMetadata, ExtensionMetadata, PixiMetadata, TreeExtension } from "@pixi/devtools";
import { Container } from "pixi.js";

export class SceneTreeExtension implements TreeExtension
{
    readonly extension = {
        type: "sceneTree"
        //name?: string | undefined
        //priority?: number | undefined
    } as ExtensionMetadata;
    
    updateNodeMetadata?(node: Container, metadata: PixiMetadata): PixiMetadata {
        return metadata;
    }
    onButtonPress?: ((container: Container, name: string, pressed?: boolean) => void) | undefined;
    onContextButtonPress?: ((container: Container, contextMenuName: string) => void) | undefined;
    onRename?: ((container: Container, newName: string) => void) | undefined;
    onDeleted?: ((container: Container) => void) | undefined;
    onSwap?: ((container: Container, newIndex: number) => void) | undefined;

    public onSelected(/*container: Container*/): void
    {
        console.log("Selected!");
    }

    panelButtons?: ButtonMetadata[] | undefined;
}

Create devtools like so:

    initDevtools({
        pixi: PIXI,
        extensions: [new SceneTreeExtension()],
        app: app
    });

When a new page is opened, and dev tools is opened, it works and prints "Selected!" to the console.
Refreshing the page (with dev tools open) will cause the custom extension to not work unless dev tools is reopened, or until a new window is opened. The tool works normally, so can cause the user to proceed without realizing their custom extension is not working.

A workaround is to call, but I think this should be handled elsewhere.
window.__PIXI_DEVTOOLS_WRAPPER__?.reset();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant