From afc8b48f5d19a0866118ccc6c5f4f627e8d3b3da Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Fri, 17 Jun 2016 20:29:10 +0800 Subject: [PATCH 1/2] spine should use postImport --- extensions/spine/editor/spine-meta.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/extensions/spine/editor/spine-meta.js b/extensions/spine/editor/spine-meta.js index 1f784581ca..5e1538eda6 100644 --- a/extensions/spine/editor/spine-meta.js +++ b/extensions/spine/editor/spine-meta.js @@ -9,7 +9,7 @@ const Fs = require('fire-fs'); const Path = require('fire-path'); const Spine = require('../lib/spine'); -const ATLAS_EXTS = ['.atlas', '.txt', '']; +const ATLAS_EXTS = ['.atlas', '.txt', '.atlas.txt', '']; const SPINE_ENCODING = { encoding: 'utf-8' }; const CustomAssetMeta = Editor.metas['custom-asset']; @@ -63,12 +63,9 @@ class TextureParser { var path = Path.resolve(base, name); var uuid = Editor.assetdb.fspathToUuid(path); if (!uuid) { + Editor.error('Can not find texture "%s" for atlas "%s"', line, this.atlasPath); return; } - //if (!uuid) { - // cc.error('Can not find texture "%s" for atlas "%s"', line, this.atlasPath); - // return; - //} //var texture = Editor.serialize.asAsset(uuid); var url = Editor.assetdb.uuidToUrl(uuid); this.textures.push(url); @@ -136,7 +133,7 @@ class SpineMeta extends CustomAssetMeta { return res; } - import (fspath, cb) { + postImport (fspath, cb) { Fs.readFile(fspath, SPINE_ENCODING, (err, data) => { if (err) { return cb(err); From 0300460296f6ec17726124acefbbf7300de2feab Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Sat, 18 Jun 2016 14:06:55 +0800 Subject: [PATCH 2/2] spine meta should support postImport being called twice --- extensions/spine/editor/spine-meta.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/extensions/spine/editor/spine-meta.js b/extensions/spine/editor/spine-meta.js index 5e1538eda6..7d178df9a2 100644 --- a/extensions/spine/editor/spine-meta.js +++ b/extensions/spine/editor/spine-meta.js @@ -62,13 +62,18 @@ class TextureParser { var base = Path.dirname(this.atlasPath); var path = Path.resolve(base, name); var uuid = Editor.assetdb.fspathToUuid(path); - if (!uuid) { - Editor.error('Can not find texture "%s" for atlas "%s"', line, this.atlasPath); - return; + if (uuid) { + console.log('UUID is initialized for "%s".', path); + var url = Editor.assetdb.uuidToUrl(uuid); + this.textures.push(url); + } + else if (!Fs.existsSync(path)) { + Editor.error('Can not find texture "%s" for atlas "%s"', line, this.atlasPath); + } + else { + // AssetDB may call postImport more than once, we can get uuid in the next time. + console.warn('WARN: UUID not yet initialized for "%s".', path); } - //var texture = Editor.serialize.asAsset(uuid); - var url = Editor.assetdb.uuidToUrl(uuid); - this.textures.push(url); } unload () {} }