How do I copy material ball properties to another material ball through code

  • How do I copy texture ball properties to another texture ball?

Does you mean that you wanna change the material when runtime? If that the case I will duplicate the material and change some detail (what you wanna look like after change the material). This tutorial maybe help you to get start with changing material at runtime.

If you still insist wanna change the properties to another material I think you need to access the properties one by one.

  • I want to copy the parameters instead of replacing the texture ball directly.

I’m afraid that’s not possible to copy parameters between the two materials. At best, you can duplicate the Material asset.

Many objects use a material ball. I want to change the material ball to allow the rest to change with the object of this material ball. If you replace the material ball, you need to replace more than one object.

There was a replace option for materials that might help in this case. This option was available when you right click on the material you want to replace with another material, but it seems that this option is gone?


1 Like

Yep I understand. It’d be great to have a public API for this, but we don’t have it at the moment.
I’ve created an issue for this Create public API to copy material properties to another material · Issue #3284 · playcanvas/engine · GitHub

1 Like

That option is available for materials associated with an imported model. That is if you retain the source model, for every material generated automatically on model import you can find the Replace option on the contextual menu,

1 Like