make missing script behavior customizable

This commit is contained in:
Jare Guo
2016-07-24 11:28:25 +08:00
parent b1fadcc04e
commit 2cd4b08e68
2 changed files with 21 additions and 12 deletions
@@ -90,6 +90,13 @@ var MissingScript = cc.Class({
return cls;
}
if (id) {
if (CC_EDITOR && Editor.UuidUtils.isUuid(id)) {
id = Editor.UuidUtils.decompressUuid(id);
cc.warn('Can not find script "%s"', id);
}
else {
cc.warn('Can not find class "%s"', id);
}
return MissingScript;
}
return null;
+14 -12
View File
@@ -197,7 +197,7 @@ var _Deserializer = (function () {
}
}
var _dereference = function (self) {
function _dereference (self) {
// 这里不采用遍历反序列化结果的方式,因为反序列化的结果如果引用到复杂的外部库,很容易堆栈溢出。
var deserializedList = self.deserializedList;
var idPropList = self._idPropList;
@@ -208,7 +208,7 @@ var _Deserializer = (function () {
var id = idList[i];
idObjList[i][propName] = deserializedList[id];
}
};
}
if (CC_DEV) {
_Deserializer.prototype._callVisitorInEditor = function () {
@@ -386,8 +386,8 @@ var _Deserializer = (function () {
// * @param {Object} serialized - The obj to deserialize, must be non-nil
// * @param {Object} [target=null]
// */
var _deserializeObject = function (self, serialized, target) {
var propName, prop;
function _deserializeObject (self, serialized, target) {
var prop;
var obj = null; // the obj to return
var klass = null;
if (serialized.__type__) {
@@ -397,12 +397,16 @@ var _Deserializer = (function () {
var type = serialized.__type__;
klass = self._classFinder(type);
if (!klass) {
if (CC_EDITOR && Editor.UuidUtils.isUuid(type)) {
type = Editor.UuidUtils.decompressUuid(type);
cc.warn('Can not find script "%s"', type);
return null;
var noLog = self._classFinder === JS._getClassById;
if (noLog) {
if (CC_EDITOR && Editor.UuidUtils.isUuid(type)) {
type = Editor.UuidUtils.decompressUuid(type);
cc.warn('Can not find script "%s"', type);
}
else {
cc.warn('Can not find class "%s"', type);
}
}
cc.warn('Can not find class "%s"', type);
return null;
}
@@ -473,13 +477,11 @@ var _Deserializer = (function () {
}
}
return obj;
};
}
return _Deserializer;
})();
// FACADE
/**
* @module cc
*/