本文整理汇总了C#中AssetBundle类的典型用法代码示例。如果您正苦于以下问题:C# AssetBundle类的具体用法?C# AssetBundle怎么用?C# AssetBundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssetBundle类属于命名空间,在下文中一共展示了AssetBundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _LoadAssets
IEnumerator _LoadAssets(Action loadComplete, Action loadError)
{
if (Debug.isDebugBuild)
_loader = new WWW(Main.HOST + _versionBundle.url);
else
_loader = WWW.LoadFromCacheOrDownload(Main.HOST + _versionBundle.url, _versionBundle.versionValue);
yield return _loader;
if (string.IsNullOrEmpty(_loader.error))
{
if (_versionBundle.isEncrypted)
{
TextAsset encryped = _loader.assetBundle.Load(BundleLoader.ENCRYPTED_DATA, typeof(TextAsset)) as TextAsset;
byte[] encryptedData = encryped.bytes;
byte[] decryptedData = _Decrypt(encryptedData);
_bundle = AssetBundle.CreateFromMemory(decryptedData).assetBundle;
}
else
{
_bundle = _loader.assetBundle;
}
_isLoadComplete = true;
if (loadComplete != null) loadComplete();
}
else
{
Debug.LogError("Error: Load asset error with url: " + Main.HOST + _versionBundle.url + " - " + _loader.error);
if (loadError != null) loadError();
}
}
示例2: LoadBundle
/// <summary>
/// 创建
/// </summary>
/// <param name="decryptedData"></param>
/// <returns></returns>
IEnumerator LoadBundle(byte[] decryptedData)
{
AssetBundleCreateRequest acr = AssetBundle.CreateFromMemory(decryptedData);
yield return acr;
assetBundel = acr.assetBundle;
Instantiate(assetBundel.Load("Cube"));
}
示例3: AddLoadedBundleToManager
static void AddLoadedBundleToManager(AssetBundle bundle, string name)
{
if (!isBundleLoaded(bundle, name))
return;
AssetBundleManager.AddBundle(name, 0, bundle);
}
示例4: Start
void Start()
{
m_cube = AssetBundle.LoadFromFile("C:\\Users\\yunsubaek_df\\Documents\\AssetBundleTest1\\AssetBundles\\Windows\\cube-bundle");
cube_obj = (GameObject)m_cube.LoadAsset<GameObject>("Cube");
GameObject.Instantiate(cube_obj,new Vector3(1,1,1),Quaternion.identity);
}
示例5: StartLoad
private AssetBundleRequest m_cRequest; //The load request
#endregion Fields
#region Methods
/// <summary>
/// Start async load the assetbundle
/// </summary>
/// <param name="asset"></param>
/// <param name="resName"></param>
/// <param name="callback"></param>
public static AsyncLoader StartLoad(AssetBundle asset, string resName)
{
GameObject obj = new GameObject("AsyncLoader");
AsyncLoader loader = obj.AddComponent<AsyncLoader>();
loader.StartCoroutine(loader.GoLoader(asset, resName));
return loader;
}
示例6: OnAssetBundleLoaded
void OnAssetBundleLoaded(string url, AssetBundle assetBundle, params object[] args)
{
Object asset = null;
System.DateTime beginTime = System.DateTime.Now;
if (AssetInBundleName == null)
{
// 经过AddWatch调试,.mainAsset这个getter第一次执行时特别久,要做序列化
try
{
asset = assetBundle.mainAsset;
}
catch
{
CBase.LogError("[OnAssetBundleLoaded:mainAsset]{0}", url);
}
}
else
{
AssetBundleRequest request = assetBundle.LoadAsync(AssetInBundleName, typeof(Object));
asset = request.asset;
}
CResourceManager.LogLoadTime("AssetFileBridge", url, beginTime);
if (asset == null)
{
CBase.LogError("Asset is NULL: {0}", url);
}
AssetFileLoadedCallback(asset, CallbackArgs);
}
示例7: BundleLoadedHandler
private void BundleLoadedHandler(WWW request)
{
Debug.Log("Bundle loaded: " + request.url);
_bundle = request.assetBundle;
AssetBundleRequest assetBundleRequest = _bundle.LoadAsync(AssetName, typeof(GameObject));
_assetBundleQueue.Send(assetBundleRequest, AssetLoadedHandler);
}
示例8: DownloadAB
IEnumerator DownloadAB()
{
Debug.Log("downloading...");
yield return StartCoroutine(AssetBundleManager.downloadAssetBundle (url, version));
bundle = AssetBundleManager.getAssetBundle (url, version);
Debug.Log("complete");
Debug.Log(bundle);
}
示例9: OnGUI
void OnGUI()
{
if (GUILayout.Button ("Download bundle")){
bundle = AssetBundleManager.getAssetBundle (url, version);
if(!bundle)
StartCoroutine (DownloadAB());
}
}
示例10: LoadBundleFromFileUncompressed
public IEnumerator LoadBundleFromFileUncompressed(string path)
{
CheckFileExists(path);
bundle = AssetBundle.CreateFromFile(path);
CheckBundle(bundle);
Debug.Log("loaded bundle: " + path);
yield return null;
}
示例11: GoLoader
/// <summary>
/// Begin load
/// </summary>
/// <param name="asset"></param>
/// <param name="resName"></param>
/// <returns></returns>
public IEnumerator GoLoader(AssetBundle asset, string resName)
{
this.m_cRequest = asset.LoadAsync(resName, typeof(UnityEngine.Object));
for (; !this.m_cRequest.isDone; )
yield return this.m_cRequest;
GameObject.Destroy(this.gameObject);
}
示例12: Load
public AssetBundleRequest Load(string name, Type type)
{
Debug.Log("Loading " + name);
if (null == bundle)
{
bundle = www.assetBundle;
www.Dispose();
}
return bundle.LoadAsync(name, type);
}
示例13: initialize
/// <summary>
/// 初始化
/// </summary>
void initialize() {
string uri = string.Empty;
//------------------------------------Shared--------------------------------------
uri = Util.DataPath + "shared.assetbundle";
Debug.LogWarning("LoadFile::>> " + uri);
shared = AssetBundle.CreateFromFile(uri);
shared.Load("Dialog", typeof(GameObject));
ioo.gameManager.OnResourceInited(); //回调游戏管理器,执行后续操作
}
示例14: LoadBundleFromMemory
public IEnumerator LoadBundleFromMemory(byte[] buffer)
{
AssetBundleCreateRequest bundleRequest = AssetBundle.CreateFromMemory(buffer);
yield return bundleRequest;
if (bundleRequest.isDone)
{
bundle = bundleRequest.assetBundle;
CheckBundle(bundle);
}
}
示例15: MapHandler
public MapHandler(IMapLoader mapLoader, AssetBundle mapAsset, MapSettings mapSettings, int mapLayer)
{
this.mapLoader = mapLoader;
this.bundle = mapAsset;
this.mapSettings = mapSettings;
this.mapLayer = mapLayer;
this.mapOffset = new Vector3(mapSettings.length / 2, HUDConstants.MAP_HEIGHT, mapSettings.width / 2);
this.mapBounds = new Rect();
}