Editor Tool to remove duplicate materials

Hi all,

We are using the multiple fbx files approach to be able to access everything in editor.

Now the known issue is regarding material, if part A and part B use same material in 3dsMax e.g. then I have two materials after importing in Playcanvas.

@Leonidas my idea is to create a chrome extension to be able to parse everything in assets, find duplicated material, based on name only (I know it’s dangerous, but it’s ok in our case), and then make everthing point to only one material as needed and then remove unused old material assets.

wow. not so simple for a newbie like me in Playcanvas.

First of all, is the chrome extension approach a good idea ? I simply need a button to launch the tool, but probably will have many tools/scripts in the future, so many buttons…

Also do you think what I propose is doable ?

Thanks in advance for your help !

Hi @Pouli,

Definitely it’s doable, the Playcanvas team has gone to great lengths to provide a very robust editor API.

I am aware it’s unofficial right now and potential to change, but you can easily test and improve your workflow using it.

The browser extension approach can definitely work, though it requires some work to put in place. You can start playing with the editor directly from the console.

For finding/removing assets it’s so simple as this, paste it in the console and it will find and remove the first material named Mat Test.

var asset = editor.call('assets:findOne', (asset) => {
   return asset.get('name') === 'Mat Test';
})[1];

editor.call('assets:delete', asset);