Skip to content

Commit

Permalink
ESM Script template update (#73)
Browse files Browse the repository at this point in the history
* updated esm script template

* removed space

* moved link for scripting above class

* Update src/assets/createScript.js

Co-authored-by: Will Eastcott <[email protected]>

* Update src/assets/createScript.js

Co-authored-by: Will Eastcott <[email protected]>

* Update src/assets/createScript.js

Co-authored-by: Will Eastcott <[email protected]>

* removed swap from template

---------

Co-authored-by: Will Eastcott <[email protected]>
  • Loading branch information
kpal81xd and willeastcott authored Jun 25, 2024
1 parent ce5117e commit 4dfc8ec
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/assets/createScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,32 +81,34 @@ ${className}.prototype.update = function(dt) {
// learn more about scripting here:
// https://developer.playcanvas.com/user-manual/scripting/
`.trim();
`.trim();
}

function createEsmBoilerplate(className, scriptName) {
return `
import { Script } from 'playcanvas';
/**
* The {@link https://api.playcanvas.com/classes/Engine.Script.html | Script} class is
* the base class for all PlayCanvas scripts. Learn more about writing scripts in the
* {@link https://developer.playcanvas.com/user-manual/scripting/ | scripting guide}.
*/
export class ${className} extends Script {
/**
* Called when the script is about to run for the first time.
*/
initialize() {
}
/**
* Called for enabled (running state) scripts on each tick.
*
* @param {number} dt - The delta time in seconds since the last frame.
*/
update(dt) {
}
// uncomment the swap method to enable hot-reloading for this script
// update the method body to copy state from the old instance
// swap(old) { };
}
// learn more about scripting here:
// https://developer.playcanvas.com/user-manual/scripting/
`.trim();

`.trim();
}

export { createScript };

0 comments on commit 4dfc8ec

Please sign in to comment.