Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Asset Bundle support? #36

Closed
badoet opened this issue Oct 8, 2014 · 1 comment
Closed

Asset Bundle support? #36

badoet opened this issue Oct 8, 2014 · 1 comment

Comments

@badoet
Copy link
Contributor

badoet commented Oct 8, 2014

is there support for asset bundle?
or will it works out of the box with the current unirx library?

@neuecc
Copy link
Owner

neuecc commented Oct 9, 2014

What support do you need?
for WWW.LoadFromCacheOrDownload ?
Currently, not.
maybe you can use following code(this is from UniRx Unity forum by azrijamil)

public static IObservable<WWW> LoadFromCacheOrDownload(string url, UniRx.IProgress<float> progress = null)
{
    return Observable.FromCoroutine<WWW>((observer, cancellation) => LoadFromCacheOrDownloadCore(WWW.LoadFromCacheOrDownload(url, 1), observer, progress, cancellation));
}


static IEnumerator LoadFromCacheOrDownloadCore(WWW www, IObserver<WWW> observer, UniRx.IProgress<float> reportProgress, CancellationToken cancel)
{
    using (www)
    {
        while (!www.isDone && !cancel.IsCancellationRequested)
        {
            if (reportProgress != null)
            {
                try
                {
                    reportProgress.Report(www.progress);
                }
                catch (Exception ex)
                {
                    observer.OnError(ex);
                    yield break;
                }
            }
            yield return null;
        }

        if (cancel.IsCancellationRequested) yield break;

        if (!string.IsNullOrEmpty(www.error))
        {
            observer.OnError(new WWWErrorException(www));
        }
        else
        {
            observer.OnNext(www);
            observer.OnCompleted();
        }
    }
}

Is this good?
If it's good, I'll add this.
(note:this code is can't change version(only 1!). should fix)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants