123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class LoadInfo
- {
- public AsyncOperation asyncOperation;
- //
- // 摘要:
- // Has the operation finished? (Read Only)
- public bool isDone;
- //
- // 摘要:
- // What's the operation's progress. (Read Only)
- public float progress;
- public UnityEngine.Object asset;
- public System.Object[] allAssets;
- /// <summary>
- /// 封装系统自带的加载完成通知事件
- /// </summary>
- /// <param name="initOp"></param>
- public void InitLoadInfo(AsyncOperation initOp)
- {
- this.asyncOperation = initOp;
- if (this.asyncOperation != null)
- {
- this.asyncOperation.completed += OnCompleted;
- }
- }
-
- private void OnCompleted(AsyncOperation operation)
- {
- isDone = true;
- progress = 1;
- if (operation is ResourceRequest)
- {
- asset = (operation as ResourceRequest).asset;
- }
- else if (operation is AssetBundleRequest)
- {
- asset = (operation as AssetBundleRequest).asset;
- allAssets = (operation as AssetBundleRequest).allAssets;
- }
- else if (operation is DataAsyncOperation)
- {
- asset = (operation as DataAsyncOperation).asset;
- }
- }
- }
|