public GetAssetBundleHash ( string assetBundleName ) : |
||
assetBundleName | string | Name of the asset bundle. |
리턴 |
public static AssetBundleManifest Create(UnityEngine.AssetBundleManifest manifest) { AssetBundleManifest result = new AssetBundleManifest() { Version = DateTime.Now.ToString("yyyyMMddHHmmss") }; if (manifest == null) { return(result); } List <string> assetbundleNames = new List <string>(); assetbundleNames.AddRange(manifest.GetAllAssetBundles()); foreach (var name in assetbundleNames) { AssetBundleInfo info = new AssetBundleInfo() { AssetBundleName = name, Hash128 = manifest.GetAssetBundleHash(name).ToString() }; info.AssetPaths.AddRange(AssetDatabase.GetAssetPathsFromAssetBundle(name)); var dependencies = manifest.GetAllDependencies(name); foreach (var depName in dependencies) { info.Dependencies.Add(assetbundleNames.IndexOf(depName)); } result.Infos.Add(info); } return(result); }
static public int GetAssetBundleHash(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif UnityEngine.AssetBundleManifest self = (UnityEngine.AssetBundleManifest)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.GetAssetBundleHash(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
IEnumerator Start() { //manifestをロード using (WWW www = new WWW (path + manifestName)) { yield return www; if (!string.IsNullOrEmpty (www.error)) { Debug.Log (www.error); yield break; } manifest = (AssetBundleManifest)www.assetBundle.LoadAsset ("AssetBundleManifest"); yield return null; www.assetBundle.Unload (false); } //sceneをロード using (WWW www = WWW.LoadFromCacheOrDownload (path + bundleName, manifest.GetAssetBundleHash (bundleName))) { yield return www; if (!string.IsNullOrEmpty (www.error)) { Debug.Log (www.error); yield break; } Application.LoadLevel (sceneName); yield return null; www.assetBundle.Unload (false); } }
public static IEnumerator LoadAssetBundle(string Fdirctory, string FassetBundleName) { string[] dps = assetBundleManifest.GetAllDependencies(FassetBundleName); AssetBundle[] temp = new AssetBundle[dps.Length]; for (int i = 0; i < dps.Length; i++) { WWW www = WWW.LoadFromCacheOrDownload(dps[i], assetBundleManifest.GetAssetBundleHash(dps[i])); yield return(www); temp[i] = www.assetBundle; } WWW tar = WWW.LoadFromCacheOrDownload(Fdirctory + FassetBundleName, assetBundleManifest.GetAssetBundleHash(FassetBundleName)); yield return(tar); AssetBundle t = tar.assetBundle; }
static public int GetAssetBundleHash(IntPtr l) { try { UnityEngine.AssetBundleManifest self = (UnityEngine.AssetBundleManifest)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.GetAssetBundleHash(a1); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
public void AddUnityManifest(UnityEngine.AssetBundleManifest manifest) { if (manifest == null) { return; } string[] inOriginList = manifest.GetAllAssetBundles(); foreach (var origin in inOriginList) { allAssetBundles.Add(origin); allDependencies.Add(origin, manifest.GetAllDependencies(origin)); allHash.Add(origin, manifest.GetAssetBundleHash(origin)); } }
/// <summary> /// 加载资源包 /// </summary> /// <param name="dirctory"></param> /// <param name="assetBundleName"></param> /// <returns></returns> public static IEnumerator LoadAssetBundle(string dirctory, string assetBundleName) { ///如果assetBundleManifest为空,结束加载。 if (assetBundleManifest == null) { yield break; } string[] dps = assetBundleManifest.GetAllDependencies(assetBundleName); AssetBundle[] temp = new AssetBundle[dps.Length]; for (int i = 0; i < dps.Length; i++) { WWW www = WWW.LoadFromCacheOrDownload(dps[i], assetBundleManifest.GetAssetBundleHash(dps[i])); yield return(www); temp[i] = www.assetBundle; } WWW tar = WWW.LoadFromCacheOrDownload(dirctory + assetBundleName, assetBundleManifest.GetAssetBundleHash(assetBundleName)); yield return(tar); AssetBundle t = tar.assetBundle; }
static int GetAssetBundleHash(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.AssetBundleManifest obj = (UnityEngine.AssetBundleManifest)ToLua.CheckObject <UnityEngine.AssetBundleManifest>(L, 1); string arg0 = ToLua.CheckString(L, 2); UnityEngine.Hash128 o = obj.GetAssetBundleHash(arg0); ToLua.PushValue(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static IEnumerator LoadAssetBundle() { string url = Application.streamingAssetsPath + "/AssetBundles/"; string path = CFG.WWWstreamingAssetsPathPrefix + url + "AssetBundles"; WWW nwww = WWW.LoadFromCacheOrDownload(path, 0); yield return(nwww); if (string.IsNullOrEmpty(nwww.error)) { AssetBundle mab = nwww.assetBundle; UnityEngine.Object g0 = mab.LoadAsset("AssetBundleManifest"); AssetBundleManifest main = g0 as AssetBundleManifest; mab.Unload(false); string[] dps = main.GetAllDependencies("Commen"); AssetBundle[] temp = new AssetBundle[dps.Length]; foreach (var item in dps) { WWW durkl = WWW.LoadFromCacheOrDownload(item, main.GetAssetBundleHash(item)); yield return(durkl); temp[0] = durkl.assetBundle; } WWW tar = WWW.LoadFromCacheOrDownload(CFG.WWWstreamingAssetsPathPrefix + url + "Commen", main.GetAssetBundleHash("Commen"), 0); yield return(tar); AssetBundle t = tar.assetBundle; Sprite _tt = t.LoadAsset <Sprite>("20"); GameObject g = new GameObject(); var r = g.AddComponent <SpriteRenderer>(); r.sprite = _tt; } else { #if UNITY_EDITOR || Development Debuger.Log(nwww.error); #endif } }
static AssetBundleManifest OutputResult(string resultFile, float useTime, UnityEngine.AssetBundleManifest manifest) { if (manifest == null) { return(null); } AssetBundleManifest result = new AssetBundleManifest(); result.buildTime = useTime; List <AssetBundleManifest.AssetBundleBuild> bundles = new List <AssetBundleManifest.AssetBundleBuild>(); foreach (var name in manifest.GetAllAssetBundles()) { AssetBundleManifest.AssetBundleBuild bundle = new AssetBundleManifest.AssetBundleBuild(); bundle.assetBundleName = name; bundle.dependency = manifest.GetDirectDependencies(name); bundle.hash = manifest.GetAssetBundleHash(name).ToString(); bundles.Add(bundle); } result.builds = bundles.ToArray(); File.WriteAllText(resultFile, JsonUtility.ToJson(result, true)); return(result); }
private string[] GetAssetbundlesNeedsUpdate(AssetBundleManifest servermanifest, AssetBundleManifest localmanifest) { List<string> result = new List<string>(); var allassets = servermanifest.GetAllAssetBundles(); for (int i = 0; i < allassets.Length; i++) { Debug.Log("compare hash for bundle:" + allassets[i]); if (localmanifest.GetAssetBundleHash(allassets[i]).ToString() != servermanifest.GetAssetBundleHash(allassets[i]).ToString()) result.Add(allassets[i]); } return result.ToArray(); }
// =====ここからメソッド群===== // 作成したアセットバンドル情報を、ソートしたディクショナリー形式にして返す static private SortedDictionary<string, string> CreateAssetbundleSortedDictionary(AssetBundleManifest assetBundleManifest) { string[] allAssetBundles = assetBundleManifest.GetAllAssetBundles(); SortedDictionary<string, string> forSortList = new SortedDictionary<string, string>(); for( int i = 0; i < allAssetBundles.Length ; i++ ) { string hash = assetBundleManifest.GetAssetBundleHash( allAssetBundles[i] ).ToString(); forSortList.Add(allAssetBundles[i], hash); } // 結果出力 Debug.Log("=====SortedDictionary:OutputStart====="); foreach(var data in forSortList) { Debug.Log("key : " + data.Key + "/" + "Value : " + data.Value); } Debug.Log("=====SortedDictionary:OutputEnd====="); return forSortList; }