improve log if script not found

This commit is contained in:
Jare Guo
2016-12-26 17:44:09 +08:00
parent adb94371aa
commit 8becd8f9d7
3 changed files with 85 additions and 32 deletions
+9 -6
View File
@@ -104,14 +104,17 @@ var MissingScript = cc.Class({
}
if (id) {
cc.deserialize.reportMissingClass(id);
if (data.node && (CC_EDITOR && Editor.Utils.UuidUtils.isUuid(id))) {
return MissingScript;
}
else {
return MissingClass;
}
return MissingScript.getMissingWrapper(id, data);
}
return null;
},
getMissingWrapper: function (id, data) {
if (data.node && (CC_EDITOR && Editor.Utils.UuidUtils.isUuid(id))) {
return MissingScript;
}
else {
return MissingClass;
}
}
},
onLoad: function () {
+39 -10
View File
@@ -41,14 +41,12 @@ function isSceneObj (json) {
}
function loadDepends (pipeline, item, asset, tdInfo, deferredLoadRawAssetsInRuntime, callback) {
var uuid = item.uuid, uuidList = tdInfo.uuidList;
var uuidList = tdInfo.uuidList;
var objList, propList, depends;
var i, dependUuid;
// cache dependencies for auto release
var dependKeys = item.dependKeys = [];
asset._uuid = uuid;
if (deferredLoadRawAssetsInRuntime) {
objList = [];
propList = [];
@@ -202,7 +200,13 @@ function canDeferredLoad (asset, item, isScene) {
return res;
}
var MissingClass;
function loadUuid (item, callback) {
if (CC_EDITOR) {
MissingClass = MissingClass || Editor.require('app://editor/page/scene-utils/missing-class-reporter').MissingClass;
}
var json;
if (typeof item.content === 'string') {
try {
@@ -221,15 +225,34 @@ function loadUuid (item, callback) {
return;
}
var classFinder;
var isScene = isSceneObj(json);
var classFinder = isScene ? cc._MissingScript.safeFindClass : function (id) {
var cls = JS._getClassById(id);
if (cls) {
return cls;
if (isScene) {
if (CC_EDITOR) {
MissingClass.hasMissingClass = false;
classFinder = function (type, data, owner, propName) {
var res = MissingClass.classFinder(type, data, owner, propName);
if (res) {
return res;
}
return cc._MissingScript.getMissingWrapper(type, data);
};
classFinder.onDereferenced = MissingClass.classFinder.onDereferenced;
}
cc.warnID(4903, id);
return Object;
};
else {
classFinder = cc._MissingScript.safeFindClass;
}
}
else {
classFinder = function (id) {
var cls = JS._getClassById(id);
if (cls) {
return cls;
}
cc.warnID(4903, id);
return Object;
};
}
var tdInfo = CC_JSB ? new cc.deserialize.Details() : _tdInfo;
@@ -248,6 +271,12 @@ function loadUuid (item, callback) {
return;
}
asset._uuid = item.uuid;
if (CC_EDITOR && isScene && MissingClass.hasMissingClass) {
MissingClass.reportMissingClass(asset);
}
var deferredLoad = canDeferredLoad(asset, item, isScene);
loadDepends(this.pipeline, item, asset, tdInfo, deferredLoad, callback);
+37 -16
View File
@@ -135,11 +135,13 @@ var _Deserializer = (function () {
// deserialize
for (var i = 0; i < refCount; i++) {
if (jsonArray[i]) {
var mainTarget;
if (CC_DEV) {
mainTarget = (i === 0 && target);
if (CC_EDITOR || CC_TEST) {
var mainTarget = (i === 0 && target);
this.deserializedList[i] = _deserializeObject(this, jsonArray[i], mainTarget, this.deserializedList, '' + i);
}
else {
this.deserializedList[i] = _deserializeObject(this, jsonArray[i]);
}
this.deserializedList[i] = _deserializeObject(this, jsonArray[i], mainTarget);
}
}
this.deserializedData = refCount > 0 ? this.deserializedList[0] : [];
@@ -153,7 +155,12 @@ var _Deserializer = (function () {
}
else {
this.deserializedList = [null];
this.deserializedData = jsonObj ? _deserializeObject(this, jsonObj, target) : null;
if (CC_EDITOR || CC_TEST) {
this.deserializedData = jsonObj ? _deserializeObject(this, jsonObj, target, this.deserializedList, '0') : null;
}
else {
this.deserializedData = jsonObj ? _deserializeObject(this, jsonObj) : null;
}
this.deserializedList[0] = this.deserializedData;
//// callback
@@ -172,10 +179,22 @@ var _Deserializer = (function () {
var idPropList = self._idPropList;
var idList = self._idList;
var idObjList = self._idObjList;
for (var i = 0, len = self._idList.length; i < len; i++) {
var propName = idPropList[i];
var id = idList[i];
idObjList[i][propName] = deserializedList[id];
var onDereferenced = self._classFinder && self._classFinder.onDereferenced;
var i, propName, id;
if (CC_EDITOR && onDereferenced) {
for (i = 0; i < idList.length; i++) {
propName = idPropList[i];
id = idList[i];
idObjList[i][propName] = deserializedList[id];
onDereferenced(deserializedList, id, idObjList[i], propName);
}
}
else {
for (i = 0; i < idList.length; i++) {
propName = idPropList[i];
id = idList[i];
idObjList[i][propName] = deserializedList[id];
}
}
}
@@ -201,8 +220,8 @@ var _Deserializer = (function () {
this.result.uuidPropList.push(propName);
}
else {
if (CC_DEV) {
obj[propName] = _deserializeObject(this, jsonObj, target && target[propName]);
if (CC_EDITOR || CC_TEST) {
obj[propName] = _deserializeObject(this, jsonObj, target && target[propName], obj, propName);
}
else {
obj[propName] = _deserializeObject(this, jsonObj);
@@ -426,9 +445,11 @@ var _Deserializer = (function () {
///**
// * @param {Object} serialized - The obj to deserialize, must be non-nil
// * @param {Object} [target=null]
// * @param {Object} [target=null] - editor only
// * @param {Object} [owner] - debug only
// * @param {String} [propName] - debug only
// */
function _deserializeObject (self, serialized, target) {
function _deserializeObject (self, serialized, target, owner, propName) {
var prop;
var obj = null; // the obj to return
var klass = null;
@@ -437,10 +458,10 @@ var _Deserializer = (function () {
// Type Object (including CCClass)
var type = serialized.__type__;
klass = self._classFinder(type, serialized);
klass = self._classFinder(type, serialized, owner, propName);
if (!klass) {
var noLog = self._classFinder === JS._getClassById;
if (noLog) {
var notReported = self._classFinder === JS._getClassById;
if (notReported) {
cc.deserialize.reportMissingClass(type);
}
return null;