Friday, April 12, 2024
HomeGame DevelopmentUnable to view mesh by way of UI meshrenderer with dynamic instantiation...

Unable to view mesh by way of UI meshrenderer with dynamic instantiation – Cocos Creator

I’m at the moment attempting to make use of UIMeshRenderer in an inventory to show the stock of a participant.

The weapon exhibits up high-quality within the editor, ( after scaling it 5000, 5000, 5000)
nonetheless when viewing it in preview / play mode it dissapears.

I’m utilizing a typescript element to dynamically refresh these duties, like so:

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

                    sources.load(`${Part}/${factor}/${ElementHeader}`, Mesh, (err, meshinst) => {
                        let NewDisplayBtn = instantiate(PrefabIcon)


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

                        this.Debounce = false;

Why is the mesh not viewable within the preview? Is there a greater option to go about this?

from my very own expertise, I believe you may verify the layer of the node earlier than.
to see whether it is set to UI_2D

1 Like

Hey man,
Thanks for you reply, it turned out to be the widget, i used to be dynamically instantiating ‘MeshHolder’ right into a dad or mum node. I set the dad or mum node and mesh holder all beneath the identical prefab and it mounted the difficulty.

Have a great day!



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments

Arnavsijapati on Planet of Lana – Beta Demo
Jai Kishor Upadhyay on Planet of Lana – Beta Demo