public IEnumerator Init() { if (IsInited) { yield break; } #if UNITY_IOS ResourceManager.PlatformDirectory = ResourceSettings.PLATFORM_DIRECTORY_IOS; #else ResourceManager.PlatformDirectory = ResourceSettings.PLATFORM_DIRECTORY_GP; #endif var configUri = ResourceStreamingLocation.RuntimeConfigFullFileUri; using (var webRequest = UnityWebRequest.Get(configUri)) { yield return(webRequest.SendWebRequest()); if (string.IsNullOrEmpty(webRequest.error)) { var configJson = webRequest.downloadHandler.text; IsInited = ResourceManager.Init(configJson); } else { ResourceDebug.Log("{0}->Init: config load failed, uri [{1}], error [{2}]", GetType().Name, configUri, webRequest.error); } } ResourceDebug.Log("{0}->Init: config init finished, uri [{1}], success [{2}]", GetType().Name, configUri, IsInited); }
private IEnumerator InitAsync() { var startProgress = 0f; // init config var stepProgress = 0.1f; yield return(GameAssetHelperSample.Instance.Init()); if (!GameAssetHelperSample.Instance.IsInited) { ResourceDebug.Log("{0}->InitAsync: init failed.", GetType().Name); Done(false); yield break; } ResourceDebug.Log("{0}->InitAsync: init success.", GetType().Name); startProgress += stepProgress; UpdateLoadingProgress(startProgress); // load locations stepProgress = 0.6f; var request = GameAssetHelperSample.Instance.LoadAllLocationsAsync(); yield return(RunLoadRequest(request, startProgress, stepProgress)); ResourceDebug.Log("{0}->InitAsync: location load finish: error [{1}]", GetType().Name, request.Error); startProgress += stepProgress; // load asset bundles stepProgress = 0.3f; request = GameAssetHelperSample.Instance.LoadAllAssetBundlesAsync(); yield return(RunLoadRequest(request, startProgress, stepProgress)); ResourceDebug.Log("{0}->InitAsync: asset bundle load finish: error [{1}]", GetType().Name, request.Error); UpdateLoadingProgress(1f); Done(true); }