private static string fixWWWUri(string uri) { if (!uri.StartsWith("http")) { uri = "file://" + FileUtils.PrepareBundleFile(uri); } return(uri); }
/* ========================== Load From File ========================== */ public static AssetBundle CreateBundleFromFile(string path) { #if PROFILE_FILE Profiler.BeginSample("BundleEncoder.CreateBundleFromFile"); #endif AssetBundle bundle = null; #if LOAD_FROM_FILE try { Encoding enc = GetEncodingOfFile(path); LogUtil.Trace("CreateBundleFromFile: " + path + " enc=" + enc); if (enc == Encoding.Unity) { string fullpath = FileUtils.PrepareBundleFile(path); bundle = AssetBundle.LoadFromFile(fullpath); #if PROFILE_FILE Profiler.EndSample(); #endif return(bundle); } LogUtil.Trace("CreateBundleFromFile: fallback to LoadFromMemory for this encoding"); } catch (Exception e) { // just fallback to LoadFromMemory LogUtil.Error("CreateBundleFromFile: fallback to LoadFromMemory because of Error " + e); } #endif // LOAD_FROM_FILE byte[] data = DecodeBundleFile(path); bundle = AssetBundle.LoadFromMemory(data); #if PROFILE_FILE Profiler.EndSample(); #endif return(bundle); }