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); }
private IEnumerator InitProcess() { Debug.Log("Start Init process"); resourceStorage = new ResourceStorage(100); var manifestLoader = new WebRequestLoader(coroutineManager); manifestLoader.RegisterResourceCreator(new StringDataCreator()); UnityResourceFromBundleLoader resFromBundlesLoader = new UnityResourceFromBundleLoader(coroutineManager); WebRequestBundlesLoader bundlesLoader = new WebRequestBundlesLoader(serverStaticPath, coroutineManager); resourceStorage.RegisterResourceLoader(manifestLoader); resourceStorage.RegisterResourceLoader(resFromBundlesLoader); resourceStorage.RegisterResourceLoader(bundlesLoader); //Load Manifest ManifestResourceHolder manifestHolder = new ManifestResourceHolder(); var manifestLoadingOperation = resourceStorage.LoadResource <string>(manifestHolder, Path.Combine(serverStaticPath, manifestName)); yield return(manifestLoadingOperation); Debug.Log("Manifest loaded: " + manifestLoadingOperation.Resource); var jsonSerializer = new JsonSerializer(new JsonSerializerSettings { Formatting = Formatting.Indented }, Encoding.UTF8); var manifestAsJson = jsonSerializer.DeserializeString <AssetBundleManifest>(manifestLoadingOperation.Resource); bundlesLoader.Manifest.AddManifestPart(manifestAsJson); resourceStorage.ReleaseAllOwnerResourcesFromCache(manifestHolder); _prefabsResourceHolder = new PrefabsResourceHolder(); Debug.Log("Init process pass"); }