Example #1
0
    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 void Awake()
    {
        GameObject         timeProvidersGo           = new GameObject("-TimeProvider");
        SimpleTimeProvider mainCoroutineTimeProvider = timeProvidersGo.AddComponent <SimpleTimeProvider>();

        CoroutineManager coroutineManager = new CoroutineManager();

        coroutineManager.TimeProvider = mainCoroutineTimeProvider;

        resourceStorage = new ResourceStorage(100);
        WebRequestLoader webLoader = new WebRequestLoader(coroutineManager);

        webLoader.RegisterResourceCreator(new TextureDataCreator());
        webLoader.RegisterResourceCreator(new StringDataCreator());
        resourceStorage.RegisterResourceLoader(webLoader);
    }
    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");
    }