本文整理汇总了C#中UnityEngine.AssetBundle.Unload方法的典型用法代码示例。如果您正苦于以下问题:C# AssetBundle.Unload方法的具体用法?C# AssetBundle.Unload怎么用?C# AssetBundle.Unload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.AssetBundle
的用法示例。
在下文中一共展示了AssetBundle.Unload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DownloadAssetBundle
IEnumerator DownloadAssetBundle()
{
yield return StartCoroutine(AssetBundleManager.downloadAssetBundle(url, version));
bundle = AssetBundleManager.getAssetBundle(url, version);
if (bundle != null)
AssetLoader.Instance.SetInfoText("Download Success.... ");
else
AssetLoader.Instance.SetInfoText("Download error please retry");
GameObject obj = Instantiate(bundle.LoadAsset("ExampleObject"),Vector3.zero,Quaternion.identity) as GameObject;
// Unload the AssetBundles compressed contents to conserve memory
//Debug.Log(obj);
bundle.Unload(false);
}
示例2: AddPackage
public static UIPackage AddPackage(AssetBundle desc, AssetBundle res, string resourceNamePrefix)
{
byte[] bytes = ((TextAsset)desc.mainAsset).bytes;
if (desc != res)
desc.Unload(true);
return AddPackage(bytes, res, resourceNamePrefix);
}
示例3: UnLoadSource
/// <summary>
/// 卸载资源
/// </summary>
/// <param name="bundle">卸载的资源</param>
/// <param name="unload"></param>
public static void UnLoadSource(AssetBundle bundle, bool unload)
{
if (bundle == null)
{
LCSConsole.WriteError("卸载资源为空!");
return;
}
bundle.Unload(unload);
}
示例4: Download
private IEnumerator Download(string url)
{
// Start a download of the given URL
//Random argument added to the back of the URL to prevent caching
string randomValue = "?t=" + Random.value;
url += randomValue;
www = new WWW(url);
isDownloading = true;
downloadStatus.color = Color.black;
// Wait for download to complete
yield return www;
isDownloading = false;
if (www.error != null)
{
Debug.Log(www.error);
downloadStatus.text = www.error;
}
// Load and retrieve the AssetBundle
bundle = www.assetBundle;
if (bundle == null)
{
downloadStatus.color = Color.red;
downloadStatus.text = DOWNLOAD_FAIL_MESSAGE;
}
// Load all the objects
Object[] assetbundlesObject = bundle.LoadAllAssets();
foreach (Object o in assetbundlesObject)
{
objectCollection.AddGameObjects((GameObject)o);
}
objectCollection.PrepareUserObjects();
// Unload the AssetBundles compressed contents to conserve memory
bundle.Unload(false);
// Frees the memory from the web stream
www.Dispose();
downloadStatus.color = Color.blue;
downloadStatus.text = DOWNLOAD_PASS_MESSAGE;
}
示例5: LoadBundle
public IEnumerator LoadBundle()
{
ImBusy = true;
string url = "file:///"+Path.GetFullPath(ResPath);
MessageServiceClass.MessageProcessing("Loadin bundle from "+url);
WWW www = WWW.LoadFromCacheOrDownload(url, version);
yield return www;
MessageServiceClass.MessageProcessing("Bundle resources are loaded from "+ url);
assetBundle = www.assetBundle;
CircleGameObjPref = assetBundle.Load("circle") as GameObject;
for (int i = 0;i <4; i++){
BundleResourceTextures2d[i] = assetBundle.Load (BundleTexturesNames[i]) as Texture2D;
}// int i = 0;i <4; i++
assetBundle.Unload(false);
ImBusy = false;
}
示例6: AddPackage
public static UIPackage AddPackage(AssetBundle desc, AssetBundle res, string resourceNamePrefix)
{
#if UNITY_5
byte[] bytes = desc.LoadAsset<TextAsset>(desc.GetAllAssetNames()[0]).bytes;
#else
byte[] bytes = ((TextAsset)desc.mainAsset).bytes;
#endif
if (desc != res)
desc.Unload(true);
return AddPackage(bytes, res, resourceNamePrefix);
}
示例7: _Load
static IEnumerator _Load( string path, bool isScene, LoadContentInfo info )
{
AssetBundle bundle = new AssetBundle();
if( !isScene )
{
#if !UNITY_WEBPLAYER
if( !FileExistLocally( path ) )
{
Debug.Log("VirgoLoader::>>Downloading : " + path);
WWW www = new WWW( path );
while( www.isDone == false )
{
instance.percent = www.progress * 100;
yield return null;
}
instance.percent = 100f;
if( www.error != null )
{
instance.OnLoadedAssetsError(new EventArgs());
Error("VirgoLoader::>>Error: " + www.error );
}
else
bundle = www.assetBundle;
if(info.saveLocallyWhenBundle )
_SaveLocally( www );
}
else
{
instance.StartCoroutine(LoadLocalFile( path ));
}
#endif
#if UNITY_WEBPLAYER
Debug.Log("Loader (WebPlayer)::>>Downloading : " + path);
WWW www = new WWW( path );
while( www.isDone == false )
{
instance.percent = www.progress * 100;
yield return null;
}
instance.percent = 100f;
if( www.error != null )
{
instance.OnLoadedAssetsError(new EventArgs());
Error("VirgoLoader::>>Error: " + www.error );
}
else
bundle = www.assetBundle;
#endif
}
else
{
Debug.Log("VirgoLoader::>>Loading scene locally : " + path );
AsyncOperation operation;
if(!info.destroyAssetsInCurrentScene )
{
operation = Application.LoadLevelAdditiveAsync( path );
}
else
{
operation = Application.LoadLevelAsync( path );
}
operation.allowSceneActivation = info.placeInSceneWhenLoaded;
while( operation.progress < 1 )
{
instance.percent = operation.progress * 100;
yield return null;
}
instance.percent = 100f;
}
if( info.placeInSceneWhenLoaded && bundle != null)
{
if(!isScene)
{
Instantiate( bundle.mainAsset );
bundle.Unload(false);
}
}
instance.OnLoadedAssetsComplete( new EventArgs());
}
示例8: UnLoadBundle
//释放某AssetBundle
public void UnLoadBundle(AssetBundle bundle)
{
string key = "";
foreach (DictionaryEntry de in BundleTable)
{
if (bundle == (AssetBundle)de.Value){
key = de.Key.ToString();
break;
}
}
if (BundleTable.ContainsKey(key))
{
BundleTable.Remove(key);
}
if (bundle != null)
bundle.Unload(false);
}
示例9: LoadConf
//--------------COROUTINES-----------------------------------
/* LoadConf()
* Chargement de la configuration d'abri par défaut
**/
private IEnumerator LoadConf()
{
_isBuilding = true;
Montage.assetBundleLock = true;
//Attend que le objdata soit configuré
while(gameObject.GetComponent<ObjData>()==null)
{
yield return new WaitForEndOfFrame();
}
while(gameObject.GetComponent<ObjData>().GetObjectModel() == null)
{
yield return new WaitForEndOfFrame();
}
_lib = GetComponent<ObjData>().GetObjectModel().GetLibrary();
//Récupération de l'assetbundle
// OSLib libObj = GetComponent<ObjData>().GetObjectModel().GetLibrary();
WWW www = WWW.LoadFromCacheOrDownload (_lib.GetAssetBundlePath (), _lib.GetVersion ());
yield return www;
if (www.error != null)
{
Debug.Log ("AssetBundle ERROR" + www.error);
}
else
{
_assetBundle = www.assetBundle;
if (_assetBundle != null)
{
//Chargement de la config
TextAsset confXml = _assetBundle.LoadAsset (modelName+"_conf", typeof (TextAsset)) as TextAsset;
if (confXml != null)
{
_dsMdl.ParseConfFile(confXml);
}
}
_assetBundle.Unload (false);
}
www.Dispose();
//Création de l'abri par default
ArrayList stConf= _dsMdl.GetdefaultConf();
_currentColor = _dsMdl.GetColor(_currentColorIndex);
if(stConf.Count > 0)
{
// SaveTransform();
_hasFacadeInDefaultBegin = false;
_hasFacadeInDefaultEnd = false;
for(int i=0;i<stConf.Count;i=i+3)
{
ModuleType typ = ModuleType.bloc;
switch ((string)stConf[i])
{
case "facade":
typ = ModuleType.facade;
break;
case "bloc":
typ = ModuleType.bloc;
if(IsAbrifixe())
{
typ = ModuleType.multiBloc;
}
break;
case "extremite":
typ = ModuleType.extremite;
break;
case "multibloc":
typ = ModuleType.multiBloc;
break;
}
if((typ == ModuleType.facade) && (i==0))
{
_hasFacadeInDefaultBegin = true;
_saveTailleBegin = (int) stConf[i+1];
_saveStyleBegin = (string) stConf[i+2];
continue;
}
if((typ == ModuleType.facade) && (i>0))
{
_hasFacadeInDefaultEnd = true;
_saveTailleEnd = (int) stConf[i+1];
_saveStyleEnd = (string) stConf[i+2];
continue;
}
int t = (int) stConf[i+1];
string styl = (string) stConf[i+2];
_nextInsertion = true;
_decalZ = 0.0f;
yield return StartCoroutine(AddModule(t,styl,typ,/*_dsMdl.GetColor(0)*/_currentColor,true));
}
//.........这里部分代码省略.........
示例10: LoadSprite
/// <summary>
/// 动态更新图片, 打包版本使用
/// </summary>
/// <param name="name"></param>
/// <param name="isIcon"></param>
/// <returns></returns>
public Sprite LoadSprite(string name, bool isIcon = true)
{
if (isIcon)
{
//不同平台的 路径设置要不一样
if (ab_atlas_icon == null){
ab_atlas_icon = AssetBundle.CreateFromFile(Application.streamingAssetsPath + "/ui/sprite/UI_release.assetbundle"+GetPlatform());
ab_atlas_icon.Unload(false);
}
return ab_atlas_icon.LoadAsset(name, typeof(Sprite)) as Sprite;
}
else
{
if (ab_atlas_ui == null) ab_atlas_ui = AssetBundle.CreateFromFile(Application.streamingAssetsPath + "/ui/sprite/UI.assetbundle");
return ab_atlas_ui.LoadAsset(name) as Sprite;
}
}
示例11: finish_callback
//finish callback
private void finish_callback(string path , AssetBundle res)
{
GameObject.Instantiate(res.mainAsset);
res.Unload(false);
}
示例12: Start
private IEnumerator Start()
{
var www = WWW.LoadFromCacheOrDownload(BundleUrl, 0);
yield return www;
m_Bundle = www.assetBundle;
createClip();
m_Bundle.Unload(false);
}
示例13: Response
void Response(AssetBundle bundle, Action<AssetBundle> callback)
{
callback(bundle);
bundle.Unload (false);
Destroy(gameObject);
}
示例14: WWWLoad
/// <summary>
/// www加载AB资源
/// </summary>
/// <returns></returns>
public IEnumerator WWWLoad()
{
Debug.Log("WWWLoad 11");
WWW www = new WWW(assetPath);
yield return www;
Debug.Log("WWWLoad 22");
if (!string.IsNullOrEmpty(www.error))
{
Debug.LogWarning("WWWLoad is error:" + www.error + "!AssetPath is " + assetPath);
yield break;
}
assetBundle = www.assetBundle;
if (assetBundle != null)
{
if (isMainAsset)
{
objectLoad = assetBundle.mainAsset;
}
else
{
if (assetBundle.Contains(assetName))
{
if (isLoadSyn)
objectLoad = null;//assetBundle.Load(assetName, typeof(Object));
else
{
Debug.Log("WWWLoad 33");
AssetBundleRequest abReq = null; //assetBundle.LoadAsync(assetName, typeof(Object));
yield return abReq;
Debug.Log("WWWLoad 44");
if (abReq.isDone)
objectLoad = abReq.asset;
}
}
}
}
assetBundle.Unload(false);
www.Dispose();
}
示例15: ChangeModuleStyle
/* ChangeModuleStyle(int idx)
* Changement de style d'un module par le idx ième
* */
public IEnumerator ChangeModuleStyle(int idx, bool bsensfacade=false)
{
string newStyle = _tmpStylesNames[idx];
string newTag = _currentModule.GetModuleType().ToString()+"_t"+_currentModule.GetSize()+"_"+newStyle;
if(newStyle != _currentModule.GetStyle())
{
//Récupére le GameObject du nouveau style
GameObject go = null;
bool bextrem = false;
//--vv--Copie un module éxistant pour éviter de réouvrir l'assetBundle--vv--
// foreach(DynShelterModule dsMod in _modules)
// {
// if(dsMod.GetTag() == newTag)
// {
// go = (GameObject)Instantiate(dsMod.GetGameObj());
// break;
// }
// }
//--vv--Si il na pas deja été créé, ben tant pis on ouvre--vv--
// if(go == null)
// {
// OSLib libObj = GetComponent<ObjData>().GetObjectModel().GetLibrary();
WWW www = WWW.LoadFromCacheOrDownload (_lib.GetAssetBundlePath (), _lib.GetVersion ());
yield return www;
if (www.error != null)
{
Debug.Log ("AssetBundle ERROR" + www.error);
}
else
{
_assetBundle = www.assetBundle;
if (_assetBundle != null)
{
string sz = newTag;
if(sz.Contains("extrem"))
{
bextrem = true;
}
Debug.Log("assetBundle.load : "+newTag);
Object original = _assetBundle.LoadAsset (newTag, typeof(GameObject));
go = (GameObject) Instantiate (original);
}
_assetBundle.Unload (false);
}
www.Dispose();
// }
SaveTransform();
go.transform.parent = transform;
go.transform.localRotation = _currentModule.GetGameObj().transform.localRotation;//Quaternion.identity;
go.transform.localScale = Vector3.one;
if(bextrem)
{
if(bsensfacade)
{
go.transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f);
//go.transform.Rotate(0.0f, 180.0f, 0.0f);
}
_currentModule.bextrem = true;
}
else
{
_currentModule.bextrem = false;
}
if(!IsAbrifixe())
{
go.transform.localPosition = _currentModule.GetPos();
_modManager.TestModuleForGlobalMods(go);
_modManager.RemoveModFrom(_currentModule.GetGameObj());
Destroy(_currentModule.GetGameObj());
_currentModule.ChangeStyle(newStyle,go);
_modules[_selectedIndex] = _currentModule;
//ChangeModuleColor(_currentColor);
}
else
{
int curMod=0;
//foreach(DynShelterModule m in _modules)
for(int modulIndex=0;modulIndex<_modules.Count;modulIndex++)
{
DynShelterModule m = (DynShelterModule) _modules[modulIndex];
if(m.GetModuleType()==_currentModule.GetModuleType())
{
GameObject goCopy = (GameObject)Instantiate(go);
goCopy.transform.parent = transform;
goCopy.transform.localPosition = m.GetPos();
_modManager.TestModuleForGlobalMods(goCopy);
_modManager.RemoveModFrom(m.GetGameObj());
Destroy(m.GetGameObj());
m.ChangeStyle(newStyle,goCopy);
_modules[modulIndex] = m;
//.........这里部分代码省略.........