CAssetBundleMgr¶
-
class CAssetBundleMgr
¶ You need to add this script by AddComponent in “Awake” method of CMainSystem.
This is the manager to cache or load the assetbundles.
When you prepare your own manager , it is unnecessary.
First ,for get the version of each asset , this script downloads the version.unity3d.
if the versions are different ,this script discards old cached data.
To have the following characteristics .
Asset bundles are version control.This script does not download assetbundles if same assetbundle downloaded in the past(WWW.LoadFromCacheOrDownload).
The loaded asset bundles are cached in memory.
It releases the cache at the scene switching .
It is possible to put a resident flag in assetbundles. These are not released at the scene switching.
Possible to switch the load path in the configuration file on the MS-Windows and the Mac ( local files without using the HTTP server can also be loaded)
The name’s format of the assetbundle is MulID .unity3d.
This value means the maximum number that this script can download at the same time.
In other words,the number of a LoadFromCacheOrDownload calling can not exceed this maximum value.
The default value is to 1.
It sets the maximum cache size of a local disk.
The default value is set to 512 * 1024 * 1024 (512Mbyte).
It sets the HTTP address.
It sets the debug path . It is effective only in MS-Windows / Mac environment .This manager preferentially loads assetbundles via this path.
Note
A file that was loaded via the debug path does not perform the cache to the local disk.
It has the error number
It has the error message
-
CAssetBundle[]
lodings
¶
This returns a list of asset bundles currently being downloaded .
This list includes what the manager deferred assetbundle downloads.
It has a number of asset bundle currently being downloaded .
This number includes what the manager deferred assetbundle downloads.
-
static CAssetBundleMgr
Instance
{ get; }¶
It has an instance of a manager
-
CAssetBundle
reference
(UInt32 id)¶
It references a assetbundle. If you have not cache it , the manager downloads it .
If it was already downloaded, it returns the existing CAssetBundle.
Whether CAssetBundle was downloaded, it is possible to determine by CAssetBundle.isLoaded.
if it returns true,the asset is already loaded.
When null is returned , it is not exist.
It examines whether the asset bundle exist .
-
void
startPreload
()¶
You need to call this function if you want to download all asset bundles that exist in order to cache on the local disk.
-
void
loadAssetVersion
()¶
Asset version (version.unity3d) to download and again , and updates the cache of asset bundle.
-
void
releaseAll
()¶
It releases all asset bundle regardless of the resident / non-resident .
After the release , you must call the loadAssetVersion.
-
class CAssetBundle
¶ It can be cast in AssetBundle.
-
AssetBundle
get
()¶
Get the AssetBundle.
It has the ID.
if it is already loaded,this value sets to true.
You can see whether it is resident .
-
AssetBundle
How to change a path to load local files.¶
It is only valid on Windows / Mac.
You make the following files in the same location as the Assets folder.
config.cf
config.local.cf
The loading order is config.cf → config.local.cf.
“config.cf” is overwritten by “config.local.cf”.
It is described as follows in config.cf
#
# config.cf
#
DEBUG_PATH = ../../../unified/AssetBuilder/assetbundles/Windows
In the Awake of CMainSystem, set as follows .
//==========================================================================
/*!Awake
* @brief Unity Callback
*/
new void Awake() {
base.Awake();
if (m_instance != null) {
Debug.LogError("already exist CMainSystem");
return;
}
m_instance = this;
#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_WEBPLAYER)
CAssetBundleMgr.debugPath = CConfig.Instance.get ("DEBUG_PATH","../Debug/");
#endif
if (KsSoftConfig.UseAssetBundle) {
gameObject.AddComponent<CAssetBundleMgr>();
}