internal AssetReferenceTracker(AssetReferenceT <TObject> _reference, AssetReferenceTrackerCallbackDelegate <TObject> _callback)
        {
            handle = _reference.LoadAssetAsync();

            loadingTrackers.Add(handle, new Pair(this, _callback));
            handle.Completed += OnCompleted;
        }
Exemplo n.º 2
0
    private void Awake()
    {
        // https://forum.unity.com/threads/how-to-play-video-from-adressable-assetbundle-on-android.685261/
        //Caching.ClearCache();
        Caching.compressionEnabled = false;

        if (buttonPlayVideo == null)
        {
            Debug.Log("Not Set Play Button");
            return;
        }
        vPlayer = GetComponent <VideoPlayer>();

        opHandle            = videoClip.LoadAssetAsync <VideoClip>();
        opHandle.Completed += (_op) =>
        {
            textAssetDownloadStatus.text = "Play";

            buttonPlayVideo.onClick.AddListener(() =>
            {
                vPlayer.clip = _op.Result;
                vPlayer.Play();
            });
        };
        //opHandle.OperationException.
    }
        public static AsyncOperationHandle <T> LoadAssetAsync <T>(AssetReferenceT <T> pAsset, Action <float> pProgress = null, Action <T> pOnCompleted = null) where T : Object
        {
            var operation = pAsset.LoadAssetAsync();

            WaitLoadTask(operation, pProgress, pOnCompleted);
            return(operation);
        }
Exemplo n.º 4
0
        protected void LoadAsset()
        {
            var assetRef = new AssetReferenceT <UnityEngine.Object>(path);

            assetReference              = assetRef;
            assetAsyncHandle            = assetRef.LoadAssetAsync();
            assetAsyncHandle.Completed += AddressableLoadCompleted;

            status = ContentAsyncStatus.Loading;
        }
Exemplo n.º 5
0
    private IEnumerator _CoroutineLoadAsset(float _delaySec)
    {
        textAssetDownloadStatus.text = "Wait";

        yield return(new WaitForSeconds(_delaySec));

        opHandle            = audioClipSample.LoadAssetAsync <AudioClip>();
        opHandle.Completed += (_op) =>
        {
            textAssetDownloadStatus.text = "Play";

            var audioSource = GetComponent <AudioSource>();
            audioSource.clip = _op.Result;
            buttonPlay.onClick.AddListener(() =>
            {
                audioSource.Play();
            });
        };
    }
 public static UniTask <T> LoadAssetAsync <T>(this AssetReferenceT <T> assetReference, IProgress <float> progress = null, PlayerLoopTiming playerLoopTiming = PlayerLoopTiming.Update, CancellationToken cancellationToken = default) where T : UnityEngine.Object
 {
     return(assetReference.LoadAssetAsync <T>().ConfigureAwait(progress, playerLoopTiming, cancellationToken));
 }
 /// <summary>
 /// Load the object using an asset reference.
 /// </summary>
 /// <param name="reference">The asset reference.</param>
 public AssetLoadingHandle(AssetReferenceT <T> reference)
     : base(reference.LoadAssetAsync())
 {
     base.onCompleted += OnCompleted;
 }