when i develop JS projects, i did call function on Browser’s console for test or debug.
i want call cocosCreator’s function on console . but CocosCreator is how can i find namespace of function(or Object)? i don’t have idea.
how can i access to class or function?
1 Like
Try any one of them:
1. Requires temporary Editing in Script beforehand
Add the component to window object.
ie do the following in onload method of your script.
window.myScript = this;
then in console type
myScript.yourFunction()
2. Need to type longer according to your node heirarchy but saves editing script temporarily ,so more robust imo.
Type in console:
var comp = cc.director.getScene().getChildByName(“Canvas”).children[1].children[3]…children[2].getComponent(“YourScriptNameAttachedOnThisReferencedNode”);
comp.yourMethod();
1 Like