Jump to content

Add child to ScreenSpaceCanvas2D after construction


royibernthal
 Share

Recommended Posts

Is there a way to add a child to ScreenSpaceCanvas2D after its already been constructed?

I tried this for instance but it doesn't seem to be the direction:

var text = new BABYLON.Text2D("Test", {
            id: "text",
            marginAlignment: "h: center, v:center",
            fontName: "20pt Arial",
        });

ui.children.push(text);
text.parent = ui; //TypeError: setting a property that has only a getter

 

 

Link to comment
Share on other sites

23 hours ago, royibernthal said:

Is there a way without specifying the children or parent in any constructor?

In other words, add child to parent after both are already constructed.

Hello, no unfortunately right now it's all at construction time because the relation is immutable...I know this is a limitation, I've just created a trello card to remember about it and develop it when I'll have the time to. https://trello.com/c/0KTDa7mM

Link to comment
Share on other sites

2 hours ago, Nockawa said:

Hello, no unfortunately right now it's all at construction time because the relation is immutable...I know this is a limitation, I've just created a trello card to remember about it and develop it when I'll have the time to. https://trello.com/c/0KTDa7mM

Hi, that's good to know thanks.

I don't know how the engine works under the hood so it might not be an option, but it'd be great if scene wouldn't have to be passed in 3D constructors as well.

Link to comment
Share on other sites

7 hours ago, royibernthal said:

Hi, that's good to know thanks.

I don't know how the engine works under the hood so it might not be an option, but it'd be great if scene wouldn't have to be passed in 3D constructors as well.

Well, this is a totally different thing. I'm not sure it will happen one day but I can't speak on the behalf of @Deltakosh. Scene objects are tightly coupled to the scene itself, making them independent would be a pretty big rework for a small benefit, I'm not sure it's worth the shot.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...