path | Path of the file on disk. |
crc | An optional CRC-32 checksum of the uncompressed content. If this is non-zero, then the content will be compared against the checksum before loading it, and give an error if it does not match. |
offset | An optional byte offset. This value specifies where to start reading the AssetBundle from. |
AssetBundle Loaded AssetBundle object or null if failed.
Synchronously loads an AssetBundle from a file on disk.
The function supports bundles of any compression type.
In case of lzma compression, the data will be decompressed to the memory. Uncompressed and chunk-compressed bundles can be read directly from disk.
Compared to LoadFromFileAsync, this version is synchronous and will not return until it is done creating the AssetBundle object.
This is the fastest way to load an AssetBundle.
public class LoadFromFileExample extends MonoBehaviour { function Start() { var myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "myassetBundle")); if (myLoadedAssetBundle == null) { Debug.Log("Failed to load AssetBundle!"); return; } var prefab = myLoadedAssetBundle.LoadAsset.<GameObject>("MyObject"); Instantiate(prefab); myLoadedAssetBundle.Unload(false); } }
using UnityEngine; using System.Collections;
public class LoadFromFileExample : MonoBehaviour { void Start () { var myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "myassetBundle")); if (myLoadedAssetBundle == null) { Debug.Log("Failed to load AssetBundle!"); return; }
var prefab = myLoadedAssetBundle.LoadAsset<GameObject>("MyObject"); Instantiate(prefab);
myLoadedAssetBundle.Unload(false); } }
See Also: AssetBundle, LoadFromFileAsync.
path | Path of the file on disk. |
crc | An optional CRC-32 checksum of the uncompressed content. If this is non-zero, then the content will be compared against the checksum before loading it, and give an error if it does not match. |
offset | An optional byte offset. This value specifies where to start reading the AssetBundle from. |
void Loaded AssetBundle object or null if failed.
Synchronously loads an AssetBundle from a file on disk.
The function supports bundles of any compression type.