mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
support asyncLoadAssets on Prefab
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user