support asyncLoadAssets on Prefab

This commit is contained in:
Jare Guo
2017-01-18 18:02:22 +08:00
parent e572ce5f84
commit ece54ef8a4
4 changed files with 13 additions and 8 deletions
+2 -2
View File
@@ -127,8 +127,8 @@ cc.Asset = cc.Class({
},
/**
* !#en Indicates whether its dependent raw assets can support deferred load if the owner scene is marked as `asyncLoadAssets`.
* !#zh 当场景被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。
* !#en Indicates whether its dependent raw assets can support deferred load if the owner scene (or prefab) is marked as `asyncLoadAssets`.
* !#zh 当场景或 Prefab 被标记为 `asyncLoadAssets`,禁止延迟加载该资源所依赖的其它 RawAsset。
*
* @property {Boolean} preventDeferredLoadDependents
* @default false
+8
View File
@@ -39,6 +39,14 @@ var Prefab = cc.Class({
*/
data: null,
/**
* !#en Indicates the raw assets of this prefab can be load after prefab loaded.
* !#zh 指示该 Prefab 依赖的资源可否在 Prefab 加载后再延迟加载。
* @property {Boolean} asyncLoadAssets
* @default false
*/
asyncLoadAssets: undefined,
/**
* Cache function for fast instantiation
* @property {Function} _createFunction
+1 -4
View File
@@ -187,15 +187,12 @@ function canDeferredLoad (asset, item, isScene) {
}
}
else if (isScene) {
if (asset instanceof cc.SceneAsset) {
if (asset instanceof cc.SceneAsset || asset instanceof cc.Prefab) {
res = asset.asyncLoadAssets;
//if (res) {
// cc.log('deferred load raw assets for ' + item.id);
//}
}
//else if (asset instanceof cc.Scene) {
// deferredLoadRawAssetsInRuntime = asset._asyncLoadAssets;
//}
}
return res;
}
+2 -2
View File
@@ -409,11 +409,11 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
},
/**
* !#en If a loading scene is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which
* !#en If a loading scene (or prefab) is marked as `asyncLoadAssets`, all the textures of the SpriteFrame which
* associated by user's custom Components in the scene, will not preload automatically.
* These textures will be load when Sprite component is going to render the SpriteFrames.
* You can call this method if you want to load the texture early.
* !#zh 当加载中的场景被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
* !#zh 当加载中的场景或 Prefab 被标记为 `asyncLoadAssets` 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
* 只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。
*
* @method ensureLoadTexture