The last few weeks I’ve been writing some scripts that extend the editor functionality in PlayCanvas. My workflow was to edit scripts on my desktop and then copy/paste them into the developer console to test them. This works fine but I was wondering how editor scripts might be supported natively by PlayCanvas so that the built in file and code editor could be used. After wrestling with a few approaches I settled on a toolbar button that lists all editor scripts in the current project as well as from any provided github repo. Here are some instructions on how to test the concept:
If you copy/paste this code into your dev console and run the ‘addEditorScriptsPlugin()’ function, a button will be added to your toolbar that lists all .js scripts found in the project that start with an ‘Editor_’ prefix. Clicking a script in the context menu will attempt to run that script by calling the script name’s function… so if you have an Editor_helloWorld.js script in your project you need to implement a function Editor_helloWorld() inside the script as the entry point.
There is also support for listing scripts from a provided GitHub repo, if you click the ‘Add PlayCanvas Scripts from GitHub’ button it will prompt for a GitHub repo Url and use the github api to search for any/all .js files and add them to the toolbar context menu. (The scripts will only be downloaded when you attempt to run them)
I could see the GitHub repo feature being a powerful and easy way for the PlayCanvas community to track/share their editor scripts/solutions without requiring the PlayCanvas developers to stand up a proprietary backend.
Let me know what you guys think, I am open to any/all feedback!