public bool UnLoadAssetbundleDirectly(string assetName) { stLoadActor pLoadInfo = null; if (m_strAllLoad.TryGetValue(assetName, out pLoadInfo)) { if (pLoadInfo != null) { pLoadInfo.m_iCount--; if (pLoadInfo.m_iCount <= 0) { if (pLoadInfo.pAsset != null) { pLoadInfo.pAsset.Unload(false); } m_strAllLoad.Remove(assetName); pLoadInfo.pObj = null; } } return(true); } return(false); }
public void LoadAssetbundleScene(string path, string levelName, bool isAdditive) { UnLoadAssetbundleDirectly(path); AssetBundle ab = IcResources.LoadAssetbundleFromFile(path); if (ab != null) { //if (isAdditive) // Application.LoadLevelAdditive(levelName); //else // Application.LoadLevel(levelName); if (isAdditive) { UnityEngine.SceneManagement.SceneManager.LoadScene(levelName, UnityEngine.SceneManagement.LoadSceneMode.Additive); } else { UnityEngine.SceneManagement.SceneManager.LoadScene(levelName, UnityEngine.SceneManagement.LoadSceneMode.Single); } stLoadActor pInfo = new stLoadActor(); pInfo.assetName = levelName; pInfo.path = path; pInfo.pObj = null; pInfo.m_iCount = 1; pInfo.pAsset = ab; m_strAllLoad[path] = pInfo; } else { UnityEngine.Debug.LogError("LoadAssetbundleSceneDirectly failed. levelName=" + levelName); } }
public Object LoadAssetbundleDirectly(string path, string assetName, System.Type type) { // if (ajfs != null) // return ajfs; stLoadActor pLoadInfo = null; if (m_strAllLoad.TryGetValue(path, out pLoadInfo)) { if (pLoadInfo != null) { pLoadInfo.m_iCount++; return(pLoadInfo.pObj); } return(null); } AssetBundle ab = IcResources.LoadAssetbundleFromFile(path); if (ab != null) { Object ajfs = ab.LoadAsset(assetName, type); if (ajfs != null) { stLoadActor pInfo = new stLoadActor(); pInfo.assetName = assetName; pInfo.path = path; pInfo.pObj = ajfs; pInfo.m_iCount = 1; pInfo.pAsset = ab; m_strAllLoad[path] = pInfo; } return(ajfs); } return(null); }