I want to improve my user experience in the code editor. So that my fields and other things are recognized from other scripts (hints and so on).
Found solution for myself
Change this
var Game = pc.createScript('game');
to this
class Game extends pc.ScriptType{}
pc.registerScript(Game, 'game');
So i have
class Game extends pc.ScriptType{}
pc.registerScript(Game, 'game');
/**@type {Game} */
Game.instance = null;
Game.prototype.initialize = function() {
Game.instance = this;
this.testString = '';
this.testNum = 0;
};
Game.prototype.update = function(dt) {
//this.test... hints works
};
Now the questions about this:
- Should I pay attention to the warning in my context? Because the ‘Script’ class does not work the same way.
You should not use 'ScriptType' with class syntax. Extend the 'Script' class instead.
- Is there any better approach?
- Is it possible to somehow achieve the same for attributes without unnecessary duplication or manual annotations, etc.?
- Is it possible to change the script template that is created from the editor?
It is important to note that support for older versions of chromium (~53) is required. External hosting.