Unable to view mesh via UI meshrenderer with dynamic instantiation

I am currently trying to use UIMeshRenderer in a list to display the inventory of a player.

The weapon shows up fine in the editor, ( after scaling it 5000, 5000, 5000)
however when viewing it in preview / play mode it dissapears.

I am using a typescript component to dynamically refresh these tasks, like so:

resources.load(`ArmoryIcons/MeshHolder`, Prefab, (err, PrefabIcon) => {
                DataArray.forEach(element => {
                    let NewBtn = instantiate(this.ItemBtn)
                    let ElementHeader = (Section == 'Characters' ? 'Body_Material0' : `${element}_Material0`)

                    resources.load(`${Section}/${element}/${ElementHeader}`, Mesh, (err, meshinst) => {
                        let NewDisplayBtn = instantiate(PrefabIcon)

                        console.log(meshinst)

                        NewBtn.parent = this.node
                        NewDisplayBtn['parent'] = NewBtn
                        NewDisplayBtn.getChildByName('Mesh').getComponent(MeshRenderer).mesh = meshinst

                        this.Debounce = false;
                    })
                });
            })

Why is the mesh not viewable in the preview? Is there a better way to go about this?

Hi,bro!
from my own experience, I think you could check the layer of the node before.
to see if it is set to UI_2D

1 Like

Hey man,
Thanks for you reply, it turned out to be the widget, i was dynamically instantiating ‘MeshHolder’ into a parent node. I set the parent node and mesh holder all under the same prefab and it fixed the issue.

Have a good day!

1 Like