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

Add game objects from outside rexUI dialog #436

Open
dtturcotte opened this issue May 13, 2024 · 1 comment
Open

Add game objects from outside rexUI dialog #436

dtturcotte opened this issue May 13, 2024 · 1 comment
Labels

Comments

@dtturcotte
Copy link

dtturcotte commented May 13, 2024

For some reason, I can't pass in a game object, like an image, into rexUI dialog and have it display. The image seems to only show if I create the image directly within the config object of dialog. This is the case even when I add the image to the same scene, and set the depth to higher than its other elements. If I remove the background (a roundrectangle), however, the image shows. So, it seems to be simply blocked by other elements.

    create() {
        var dialog = this.rexUI.add.dialog({
            x: 400,
            y: 300,

            background: ...,

            title: ...,

            content: this.add.image(0, 0, 'https://i.imgur.com/123.png'), // This shows the image
    create() {
        const image = this.add.image(0, 0, 'https://i.imgur.com/123.png')
      
        var dialog = this.rexUI.add.dialog({
            x: 400,
            y: 300,

            background: ...,

            title: ...,

            content: image, // This doesn't show the image
@rexrainbow
Copy link
Owner

UI element of rexUI usually does not change depth (order of rendering) of children game objects.
It seems that Background is created after Image, thus Background will render after Image.
To solve this issue, you can set depth of Background manually, or

var background = dialog.getElement('background');
dialog.sendChildToBack(background);

Reference

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

No branches or pull requests

2 participants