Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Create a project and save it as, say, "test.ccb". Create a javascript file called "test.js" and save it in the same folder as "test.ccb" "Publish as windows" and you will see that "test.js" file is executed But "Publish as WebGl" and you will see the "test.js" file is not executed. How come ? Bug? |
||||
|
I don't think it works that way - but you can workaround it easilly by referencing your scirpt from html file. |
||||
|
@okeoke Why wouldn't it work that way? Its a great feature to have especially if you want to code complicated game logic. You are right in that we can reference the script file from the html file but couple of problems with that a) every time you test your project from within the editor the html file gets changed b) you might want to run your js code after the engine has loaded your game/assets etc. So the timing of when your js code is executed becomes important. |
||||
|
Well, I'm not sure why it doesn't work that way. I usually rename YOUR_PROJECT_NAME.html to index.html and use external http-server, and then simply open index.html in browser and restart the page if I update the project. There are multiple ways how you can workaround it. For example, you can create script element dynamically using "execute script" action which you run before first draw. https://medium.com/@tariibaba/ja... |
||||
|
@okeoke What if I am targeting both windows and web. Two build process then? Anyway, I am sure there are number of workarounds. I posted here, not because I was looking for one, but because I was curious why this feature wasn't implemented for WebGl. |
||||
|
Ok. I guess, it's a bug. You can wait for the next update for it to be fixed. |
|