Not sure how help this one is.
I noticed that i could list all the script names in the console in the editor. I asked AI to make me a script that upon parsing that one script, all the scripts in the codebase to be auto parser (instead of parsing each individual script i made changes to)
Do let me know if any existing tool exists that does the same.
var ScriptReloader = pc.createScript('scriptReloader');
ScriptReloader.attributes.add('skipList', {
type: 'string',
array: true,
default: ['ammo.js', 'ammo.wasm.js', 'tween.umd.js', 'tween.umd'],
title: 'Skip List',
description: 'Script asset names to exclude from reloading'
});
/**
* Called once when the script component is first created.
*/
ScriptReloader.prototype.initialize = function () {
console.log('[ScriptReloader] Ready — save this script to reload all others.');
};
/**
* PlayCanvas calls swap() automatically every time THIS script file is saved/hot-reloaded.
* That makes it the perfect trigger to reload everything else.
*/
ScriptReloader.prototype.swap = function (old) {
// Carry over attributes from the previous instance
this.skipList = old.skipList;
console.log('[ScriptReloader] Save detected — reloading all scripts...');
this.reloadAll();
};
ScriptReloader.prototype.reloadAll = function () {
var app = this.app;
var skipNames = (this.skipList || []).concat(['ScriptReloader.js']);
var reloaded = [];
var skipped = [];
app.assets.list()
.filter(function (asset) {
return asset.type === 'script';
})
.forEach(function (asset) {
if (skipNames.indexOf(asset.name) !== -1) {
skipped.push(asset.name);
return;
}
asset.unload();
app.assets.load(asset);
reloaded.push(asset.name);
});
console.log('[ScriptReloader] Reloaded (' + reloaded.length + '):', reloaded);
if (skipped.length) {
console.log('[ScriptReloader] Skipped (' + skipped.length + '):', skipped);
}
};