[SOLVED] Templates and parenting

Hello , i created template from my entity in hierarchy it contains all 2D GUI elements for my Mobile screen, i have made GUI for Desktop screen and Mobile screen sizes and decided to make it this way that i will remove it from hierarchy and add it through script into hierarchy based on screen size or device you play on, it all works fine, even my template seems to be correctly set as child of the entity it used to be… but the GUI wont appear at all on screen, its like it wasnt even there, but when i manually put the template under that entity i want it on then GUI appears on screen properly, i quite dont understand what im doing wrong as im doing the same but through script, is there some thing i should set on template?

i initialize the templates through attributes, the script it is attached on is set to be the first to run at first in script loading order

part of a code to instantiate a template and set its new parent, i tried to check console log to see if the template was really set properly and it seems all is good

  • the entity i try to put my template under is also under 2D Screen

Not sure what could be the issue, but at least when working in screen space, use local frame. So, instead of instance.setPosition, use instance.setLocalPosition. Try to console log the instantiated entity and check its contents, if something look amiss.

1 Like

Yeah firstly i used LocalPosition but left it like that when testing GlobalPosition, just forgot to set it back, i also checked the log and what i understood seemed fine

Can you maybe see something i dont? thanks for reply

E: Even when i check logs of all children in my template i see it has everything it supposed to, its weird when i manually move the template into hierarchy it works just fine, when its put there through script it doesnt work at all even though the template is moved into hierarchy properly as expected

Looks fine. From this point I’d suggest making a tiny repro. A template with a single image that you would instantiate the same way you do in your project and try to repro. Then someone could look at it.

I tried to make a background as template, just simple UI element with image and it worked with no problem, background image appeared… weird

I see it has no (group) element component, so maybe the position or rotation of the child elements are lost?

Yes, the templated entity which contains all of my UI elements has no UI element, out of curiosity i put element on the templated entity and background image appeared only so i guess it has something to do with that… that entity has about 20 or 30 UI elements so it would be hard to set position or rotation to each of them, as it includes another blank entities with another children with UI elements

Does this mean the problem of the topic is solved?

Just tested it out, each entity that has children has to have UI group element, cant be a single blank entity that covers a group of UI elements, i guess it is fixed and hopefuly people find this useful in future

E: well guess it didnt help me with the other template, one was fixed as i mentioned above but seems like its not working for both templates

E2: yes, it was the same solution, i was just too blind

E3: SOLVED, the solution was to give each blank entity UI group element