1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- using YooAsset;
- using Cysharp.Threading.Tasks;
- public class Boot : MonoBehaviour
- {
- ///<summary>訧埭婦</summary>
- public static ResourcePackage package;
- private async void Awake()
- {
- if (await InitYooAsset() == EOperationStatus.Succeed)
- {
- gameObject.AddComponent<GameManager>();
- }
- }
- /// <summary>
- /// 場宎趙YooAsset
- /// </summary>
- /// <returns></returns>
- public async UniTask<EOperationStatus> InitYooAsset()
- {
- YooAssets.Initialize();
- var package = YooAssets.CreatePackage("DefaultPackage");
- YooAssets.SetDefaultPackage(package);
- InitializationOperation operation = null;
- #if UNITY_EDITOR
- var initParameters = new EditorSimulateModeParameters();
- var simulateManifestFilePath = EditorSimulateModeHelper.SimulateBuild(EDefaultBuildPipeline.BuiltinBuildPipeline, "DefaultPackage");
- initParameters.SimulateManifestFilePath = simulateManifestFilePath;
- operation = package.InitializeAsync(initParameters);
- await operation.Task;
- #else
- var initParameters = new OfflinePlayModeParameters();
- operation = package.InitializeAsync(initParameters);
- await operation.Task;
- #endif
- return operation.Status;
- }
- /// <summary>
- /// 堈傷訧埭華硊脤戙督昢濬
- /// </summary>
- private class RemoteServices : IRemoteServices
- {
- private readonly string _defaultHostServer;
- private readonly string _fallbackHostServer;
- public RemoteServices(string defaultHostServer, string fallbackHostServer)
- {
- _defaultHostServer = defaultHostServer;
- _fallbackHostServer = fallbackHostServer;
- }
- string IRemoteServices.GetRemoteMainURL(string fileName)
- {
- return $"{_defaultHostServer}/{fileName}";
- }
- string IRemoteServices.GetRemoteFallbackURL(string fileName)
- {
- return $"{_fallbackHostServer}/{fileName}";
- }
- }
-
- }
|