I was hoping to just get message-bus.js and put it into PlayCanvas along with jQuery and have it work, but as frequently happens when I pull other .js into playcanvas, the scripts are unable to parse.
Trying to eliminate the possibility that it’s just some error in the external library (though the backend engineer tested this .js and it works just fine outside of playcanvas), I tried to simply download and import jQuery
https://jquery.com/download/ - got the uncompressed version of 3.2.1 from here, copied the entire file and put it into playcanvas and changed the script load order so it’s the first one loaded.I hit parse and it comes back with this error:
What am I doing wrong here? I’m new to web programming, but jQuery seems like a generic library. I’ve seen other people talk about importing libraries and the official method seems to be by just copying and pasting the .js. Shouldn’t this just work?
Hmm… Odd. I’ve dragged both the messagebus library and jquery into a blank new project with no problem on launch. I assume you got that error when you parsed it? In which case, I wouldn’t worry about the error as the ‘parsing’ in the editor is for PlayCanvas scripts.
Every js script you put into the project is automatically loaded. They do not need to be attached to entities to ‘run’. The only ‘scripts’ that can be attached to entities are the PlayCanvas ‘scripts’ objects which are defined in the script files.
var Sandbox = pc.createScript('sandbox'); // Creates a PlayCanvas 'script' object