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; /// /// 封装系统自带的加载完成通知事件 /// /// 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; } } }