Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const {ccclass, property} = cc._decorator;
- @ccclass export default class NewClass extends cc.Component {
- // LIFE-CYCLE CALLBACKS:
- objectFromResource: Object
- onLoad () {
- console.log("Starting onLoad() Function")
- var url = cc.url.raw('resources/json_resource.json')
- cc.loader.load(url, (err, res) => {
- cc.log(res)
- this.objectFromResource = res
- console.log("Loaded URL")
- });
- console.log("Ending onLoad() Function")
- }
- start () {
- console.log('Starting start() Function')
- console.log(this.objectFromResource) //logging as null
- console.log('Ending start() function')
- }
- update (dt) {
- }
- }
- Cocos Creator v2.1.1
- JSONReader.ts:16 Starting onLoad() Function
- JSONReader.ts:33 Ending onLoad() Function
- JSONReader.ts:37 Starting start() Function
- JSONReader.ts:38 undefined
- JSONReader.ts:39 Ending start() function
- JSONReader.ts:22 {__type__: "cc.JsonAsset", _name: "json_resource", _objFlags: 0, _native: "", json: Array(784)}
- JSONReader.ts:24 Loaded URL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement