From 725af05924fc101dffcdb8f31388254e992bef33 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Mon, 11 Apr 2016 21:23:39 +0800 Subject: [PATCH] support missing script for prefab --- cocos2d/core/load-pipeline/uuid-loader.js | 8 +++++--- cocos2d/core/platform/instantiate.js | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/load-pipeline/uuid-loader.js b/cocos2d/core/load-pipeline/uuid-loader.js index 6bfa03fffe..d72762a4d1 100644 --- a/cocos2d/core/load-pipeline/uuid-loader.js +++ b/cocos2d/core/load-pipeline/uuid-loader.js @@ -30,6 +30,7 @@ require('../platform/deserialize'); var _tdInfo = new cc.deserialize.Details(); var SCENE_ID = 'cc.Scene'; +var PREFAB_ID = 'cc.Prefab'; function loadDepends (pipeline, item, asset, tdInfo, callback) { var uuid = item.id, @@ -126,11 +127,12 @@ function loadUuid (item, callback) { return; } - var isScene = json && ( + var isInScene = json && ( (json[0] && json[0].__type__ === SCENE_ID) || - (json[1] && json[1].__type__ === SCENE_ID) + (json[1] && json[1].__type__ === SCENE_ID) || + (json[0] && json[0].__type__ === PREFAB_ID) ); - var classFinder = isScene ? cc._MissingScript.safeFindClass : function (id) { + var classFinder = isInScene ? cc._MissingScript.safeFindClass : function (id) { var cls = JS._getClassById(id); if (cls) { return cls; diff --git a/cocos2d/core/platform/instantiate.js b/cocos2d/core/platform/instantiate.js index e7a8512af9..350721bd55 100644 --- a/cocos2d/core/platform/instantiate.js +++ b/cocos2d/core/platform/instantiate.js @@ -150,8 +150,10 @@ var enumerateObject = function (obj, parent) { else { // primitive javascript object for (key in obj) { - //cc.log(key); - if (!obj.hasOwnProperty(key) || (key.charCodeAt(0) === 95 && key.charCodeAt(1) === 95)) { // starts with __ + if ( !obj.hasOwnProperty(key) || + // starts with "__" but not "__type__" + (key.charCodeAt(0) === 95 && key.charCodeAt(1) === 95 && key !== '__type__') + ) { continue; } value = obj[key];