private void Awake() { GameObject timeProvidersGo = new GameObject("-TimeProvider"); SimpleTimeProvider mainCoroutineTimeProvider = timeProvidersGo.AddComponent <SimpleTimeProvider>(); coroutineManager = new CoroutineManager(); coroutineManager.TimeProvider = mainCoroutineTimeProvider; resourceStorage = new ResourceStorage(100); //Loader for load any file from www WebRequestLoader webLoader = new WebRequestLoader(coroutineManager); //Creator for cast loaded by www byte[] to string webLoader.RegisterResourceCreator(new StringDataCreator()); //Loader to load bundle from disk LocalFolderBundlesLoader bundlesLoader = new LocalFolderBundlesLoader(bundlesFolderPath, coroutineManager); //Loader to load bundle from server static folder //WebRequestBundlesLoader bundlesLoader = new WebRequestBundlesLoader(bundlesFolderPath, coroutineManager); resourceStorage.RegisterResourceLoader(webLoader); resourceStorage.RegisterResourceLoader(bundlesLoader); coroutineManager.StartCoroutine(this, WorkProcess()); }
private IEnumerator WorkProcess() { string manifestPath = String.Empty; string bundlesPath = String.Empty; #if UNITY_EDITOR foreach (var findAsset in AssetDatabase.FindAssets(manifestName)) { if (AssetDatabase.GUIDToAssetPath(findAsset).Contains(".json")) { manifestPath = AssetDatabase.GUIDToAssetPath(findAsset); break; } } foreach (var findAsset in AssetDatabase.FindAssets(bundlesFolderPath)) { if (AssetDatabase.GUIDToAssetPath(findAsset).Contains(".u3d")) { bundlesPath = AssetDatabase.GUIDToAssetPath(findAsset).Replace(bundlesFolderPath + ".u3d", ""); bundlesPath = Application.dataPath.Replace("/Assets", "/") + bundlesPath; break; } } resourceStorage = new ResourceStorage(100); UnityResourceFromBundleLoader resFromBundlesLoader = new UnityResourceFromBundleLoader(coroutineManager); LocalFolderBundlesLoader bundlesLoader = new LocalFolderBundlesLoader(bundlesPath, coroutineManager); resourceStorage.RegisterResourceLoader(resFromBundlesLoader); resourceStorage.RegisterResourceLoader(bundlesLoader); var manifest = AssetDatabase.LoadAssetAtPath <TextAsset>(manifestPath); var jsonSerializer = new JsonSerializer(new JsonSerializerSettings { Formatting = Formatting.Indented }, Encoding.UTF8); var manifestAsJson = jsonSerializer.DeserializeString <AssetBundleManifest>(manifest.text); bundlesLoader.Manifest.AddManifestPart(manifestAsJson); #endif var loadPrefab = resourceStorage.LoadResource <GameObject>(this, resourceName); yield return(loadPrefab); Instantiate(loadPrefab.Resource); //Del me resourceStorage.ReleaseFromCache(this, resourceName); loadPrefab = resourceStorage.LoadResource <GameObject>(this, resourceName); yield return(loadPrefab); Instantiate(loadPrefab.Resource); }