Esempio n. 1
0
        public static AsyncLoadAssetTag Create()
        {
            AsyncLoadAssetTag asyncLoadAssetTag = new AsyncLoadAssetTag
            {
                LoadAssetState = LoadAssetState.Loading
            };

            return(asyncLoadAssetTag);
        }
Esempio n. 2
0
        public static IEnumerator LoadAssetAsync(this ResourceComponent resourceComponent, string assetName)
        {
            AsyncLoadAssetTag asyncLoadAssetTag = AsyncLoadAssetTag.Create();

            LoadAssetCallbacks loadAssetCallbacks = new LoadAssetCallbacks((string _assetName, object asset, float duration, object userData) =>
            {
                asyncLoadAssetTag.Asset          = asset;
                asyncLoadAssetTag.LoadAssetState = LoadAssetState.Success;
            }, (string _assetName, LoadResourceStatus status, string errorMessage, object userData) =>
            {
                asyncLoadAssetTag.Asset          = null;
                asyncLoadAssetTag.LoadAssetState = LoadAssetState.Failure;
            });

            resourceComponent.LoadAsset(assetName, null, 0, loadAssetCallbacks, null);


            while (asyncLoadAssetTag.LoadAssetState == LoadAssetState.Loading)
            {
                yield return(null);
            }

            yield return(asyncLoadAssetTag.Asset);
        }