Example #1
0
        public override IEnumerator LoadAsync(Action onComplete, Action onFailed)
        {
            if (string.IsNullOrEmpty(resourcesPath))
            {
                onFailed();
                yield break;
            }

            var updateYield = ExternalResources.UpdateAsset(resourcesPath).ToYieldInstruction(false);

            yield return(updateYield);

            if (updateYield.HasError)
            {
                onFailed();
                yield break;
            }

            if (Priority != AssetFileLoadPriority.DownloadOnly)
            {
                var loadYield = ExternalResources.LoadAsset <T>(resourcesPath, false).ToYieldInstruction(false);

                yield return(loadYield);

                if (loadYield.HasError)
                {
                    onFailed();
                    yield break;
                }

                Asset = loadYield.Result;
                OnLoadComplete(Asset);

                if (Asset == null)
                {
                    IsLoadError = true;
                    onFailed();

                    yield break;
                }
            }

            IsLoadEnd = true;
            onComplete();
        }
Example #2
0
        public override IEnumerator LoadAsync(Action onComplete, Action onFailed)
        {
            if (string.IsNullOrEmpty(resourcesPath))
            {
                onFailed();
                yield break;
            }

            var updateYield = ExternalResources.UpdateAsset(resourcesPath).ToYieldInstruction(false);

            yield return(updateYield);

            if (updateYield.HasError)
            {
                onFailed();
                yield break;
            }

            if (Priority != AssetFileLoadPriority.DownloadOnly)
            {
                var cueYield = ExternalResources.GetCueInfo(resourcesPath, soundName).ToYieldInstruction();

                while (!cueYield.IsDone)
                {
                    yield return(null);
                }

                CueInfo = cueYield.Result;

                if (CueInfo == null)
                {
                    IsLoadError = true;
                    onFailed();

                    yield break;
                }
            }

            IsLoadEnd = true;
            onComplete();
        }