GUI ADT constructor : Creating multiple ADT layers for meshes at once (help needed t.getScene is not a function)

Dears,
I’m nearly ashamed to ask but I just have to. Well, you Guys know by now that I’m a poor coder so I guess it doesn’t matter anymore. :stuck_out_tongue_winking_eye:
Whenever I try to use a for loop to create multiple ADT layers, I bounce into this error (t. getScene is not a function). I don’t know just what I’m doing wrong with my constructor. I tried a lot of different ways but none worked. I mean I can do it for anything else than the GUI. Just need to know what it is I’m doing wrong here. Thanks in advance,

From my experience the _getScene is not a function happens usually when I pass by mistake something that’s not a scene to a scene argument :stuck_out_tongue: And that’s what happened here on line 48, it’s receiving a string instead of a mesh:
image

1 Like

Thanks. Stupid me. I got this before (I should know by now). Just this small brain of mine :stuck_out_tongue_winking_eye:

Thanks for it did indeed point me in the right direction and I fixed this part.
Yet now, I have another question I could have thought of before (sry for that).

I’m wondering how I should parse my snippet (knowing it’s the same for a serie of meshes/adt).

If I am doing this in my constructor:

var elev_gui = “#FEQNTL#2”;

…and then in a loop

advancedTexture[i].parseFromSnippetAsync(elev_gui);

Does this mean my GUI is parsed again for each ADT in the loop? Or does it automagically recognize that it is the same and parse it only once?
If not, can I parse it without assigning it and assign it later (how would I do that?)
Thanks again,

It is going to parse it again for each ADT, and assign the constrols during parsing.

Any way I can parse it only once? (may be from file?)

Hmmm unfortunately no, as we don’t have any way to “clone” controls currently :frowning: Is the object you’re trying to parse very big?

Thanks. No, the object is not big. I am just creating about 30 adt for mesh so it’s going to parse it once for each. Don’t know if this number can be considered big, I’d rather think not?

No, I don’t think it’s big, but I’m kinda curious why you need 30 exactly equal ADTs :thinking: Is it some kind of “control” object that is placed in different locations?

It’s a call elevator console for 5 elevators on 3 floors + each elevators also has a control in the inside.
Next, I will also have some very simple controls for few doors in the scene, for a total of about 30 altogether.

They are not all strictly identical, but enough to host them all in a single GUI Edit scene (similar to a tabs build, I push each different container for ADT to the left 100%. Then, depending on the tab/container I need to display, in the code, I force it to left 0. I hope it makes sense to do it like this. By any means, I find it quite convenient to work like that.

Edit: Forgot to mention that they are all part of a same building/structure and can potentially be seen all at the same time (given I will may be add multiplayer to the project later on). So, I cannot really move them around depending on player/camera view, if this was what you had in mind.

Here’s an unofficial screenshot featuring the valkyrie fighter docking on plateform B (I needed a spaceship to assess the size of my platforms and docking bays, so I used the one I had at hand :zipper_mouth_face: (just don’t tell @PatrickRyan, I didn’t ask for his permission :grinning: )
Anyways, in this screenshot you can see all five elevators in the scene.

1 Like

Ooooh I see! :o Yeah, I don’t think parsing the GUIs will be an issue, but let’s keep an eye on this :slight_smile:

1 Like

Rather than creating 30 different ADTs, it would likely be better to create one giant layout that has all the controls for each different elevator panel. If the difference is just text, you can change that value on the fly in code. If the difference is layout, you could create multiple different containers for each layout and just enable the one you need at any given moment. That way, you only need to handle one ADT and just change the parameters in that ADT for the specific elevator you are using. Since the user can’t be in more than one at a time, this will save you a lot of overhead for keeping all of those ADTs in memory.

I believe that’s already what I’m doing or I might be missing something? The point I do not understand is how can I avoid parsing this single GUI multiple times to place it on all my meshes? Can I assign a same ADT for multiple meshes? How, since I cannot clone or instanciate it?

What if the user can see more than one at a time? Should I create a static/visual texture for these controls and enable the ADT only when the user enters the trigger area? What happens in case I want to add multiplayer (not yet in the scope but I prefer to ask and anticipate). In that case, should the mp code handle what can be interacted with by the player? Sry, I’m not much of a game dev, so my question might sound a bit noobish to you. Thanks for the reading and taking the time to reply. :smiley:

@mawa, here is a simple example of reusing one ADT across several meshes. Note that I am using AdvancedDynamicTexture.CreateForMeshTexture so that I can create the ADT in mesh projection mode without needing to assign it to a mesh. In this way, it can be used as a texture like any other texture. In my case, I just assign the texture to a texture node in a node material. Since you will likely want the ADT to be emissive, this is a simple way to achieve this.

Granted, you will note that when you press buttons on one quad, the buttons on the other quad will also react since you are really only using one ADT in the scene. But if you have these on panels that cannot be seen at the same time on screen, this is likely ok.

If you do need to have more than one mesh on screen at once with unique copies of the ADT, you will have to parse it multiple times. Ideally, we would be able to clone the ADT, but right now the ADT inherits clone from Dynamic Texture, so when you clone an ADT you get a Dynamic Texture which won’t work for an ADT. I have a feature request in right now to build out a version of clone that will work with an ADT but for now you can parse multiple times to get the same result.

Thanks a lot for your reply, the details and the above trick I did not know about. At this early stage, my scene can still support the additional load of having multiple ADT so I believe I’m gonna try this first and see what sort of impact I get from there. I will try work it so that I can fairly easily switch to your solution with ADT mesh projection if I’m loosing too much performance.

Yes, I noticed that.

Do that and become my hero :man_superhero: yet once again (well, you know you already are :grin:

1 Like

@mawa, because @Deltakosh takes it as a personal challenge when I open feature requests, he already pushed a PR into the repository. Our version build for this week has already happened, but it should be in for next week’s build (v. 5.23) and the default version of the playground. Until then it will be available for testing on preview. I will also test it out, but please let us know if you find anything unexpected while using it.

1 Like

Sure wil do. Thanks again,