Running scripts in-editor or at build creation time

Hey guys,

1. Is it possible to run a script in the editor window without launching the game?
I am creating a grid of different type of blocks on which player can snap from one block to another to move. Each block is required to be named as a coordinate on the grid. It’s a hassle to rename my blocks when redesigning the grid block pattern. So basically what I need is, to be able to automatically rename my entities as soon as they are repositioned in the hierarchy.

2. Is it possible to run a script at the time of creating a build?
I am going to have some code in the game which should only be available in my scripts under certain conditions. So when creating a build I want to run a custom script that will remove that code from my scripts before the _gamescripts.js in the build is minimized. Please note, here I want the scripts in the game to have the code but only remove it in the combined js created in the build

  1. Sounds like you want to try the Editor API Editor API | Learn PlayCanvas

  2. I’m afraid not. Your best route here is to run a script/tool on the downloaded build which can be automated with the REST API. What I would do is download the build without script minification, unzip it, remove code from game-scripts, minimise the code and re-zip. We do other operations like this in GitHub - playcanvas/playcanvas-rest-api-tools: A set of tools to use with the PlayCanvas REST API for common jobs such as downloading a build and archiving a project

I know a user that used comments like ifdefs to remove sections of code for debug, release builds.

Thanks! yaustar. This is exactly what I needed.

Solar Games also has extended tools already for the Editor that could save you some time: Tools - Solar Games