How to Run Script without Launching?


I am new to Playcanvas and was wondering if it’s possible to run a script without pressing launch?

I am trying to generate entities in code (over 4000) without having to place them manually. But I do not want this to run every time I launch the game.

Even if I could copy from the hierarchy while running or even get the json data of the hierarchy while running could work and then I just import that.


Not officially, no.

There is an editor API that is not public so you could open the console and work out what you need to call to generate an entity in the scene.

If you have an org plan, you might be able to download the project, edit the scene file by hand/script and import it.

Is there any new state regarding the possibility to run script inside Editor (without Launching) ?

I probably missed somthing but I do not understand the use of sliders in Editor UI when using customr script if I cannot run the script inside Editor. I’ve noticed I can use these sliders to change something that happens in Launch window, but then I can’t tune anything related to Editor.

My typical use case is : I’m trying to make a small editor script to enable artists to tune clearcoat values for material, as these parameters are not yet exposed in standard Editr UI. Is there any other way to achieve this ?

The sliders are more to bound the range of values you can give an attribute rather than directly affecting something in the Editor.

A Live Debugger (so you can see and editor the live game in the Editor (explore the hierarchy etc) and Editor API are pretty high on todo list. I can’t give a date just yet though.

It is possible to write Chrome Extensions or inject JS that work with the Editor now, but it’s not official and the hooks can change. @Leonidas has done this a few times with his custom tools.

Thanks a lot for this.

Do you have any idea about clearcoat settings availability in Material Editor ?

Hi @Pouli,

Checked the editor code (it’s unminified, you can take a look as well: editor.js) and I don’t think clearcoat settings are exposed yet.

So even with a script if the DB schema hasn’t been updated yet you won’t be able to make this work right now.

Hi @Leonidas !

Sorry for newbie question, but is this why, after selecting the material in the assets, if I do this in console

var item ='selector:items')[0].get("data")
I don’t see anything related to clearCoat field ?

I’m sure this materials is a StandardMaterial because when accessing it through the entity hosting it, I can modify clearCoat.

I’m confusing something between what I see on asset side and what is accessible in the material hosted by an entity…

Yes exactly, that returns an editor item which is an object responsible for serializing the entities. Right now as you correctly found out it doesn’t contain any references to clear coat mats, since this isn’t implemented in editor.

Accessing the entity on runtime is different, there you are running an instance of the Playcanvas engine (pc.App) which has been updated and it includes the clear coat material code.

Thanks for clarification.

Now let’s create a new thread regarding editor script to remove duplicate materials, maybe need your help :slightly_smiling_face:

1 Like