mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-11-11 00:36:00 +00:00
傻逼Yooasset 新版本各种问题还是用老版本吧!
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,53 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConsoleToScreen : MonoBehaviour
|
||||
{
|
||||
const int maxLines = 50;
|
||||
const int maxLineLength = 120;
|
||||
private string _logStr = "";
|
||||
|
||||
private readonly List<string> _lines = new();
|
||||
|
||||
public int fontSize = 15;
|
||||
|
||||
void OnEnable() { Application.logMessageReceived += Log; }
|
||||
void OnDisable() { Application.logMessageReceived -= Log; }
|
||||
|
||||
public void Log(string logString, string stackTrace, LogType type)
|
||||
{
|
||||
foreach (var line in logString.Split('\n'))
|
||||
{
|
||||
if (line.Length <= maxLineLength)
|
||||
{
|
||||
_lines.Add(line);
|
||||
continue;
|
||||
}
|
||||
var lineCount = line.Length / maxLineLength + 1;
|
||||
for (int i = 0; i < lineCount; i++)
|
||||
{
|
||||
if ((i + 1) * maxLineLength <= line.Length)
|
||||
{
|
||||
_lines.Add(line.Substring(i * maxLineLength, maxLineLength));
|
||||
}
|
||||
else
|
||||
{
|
||||
_lines.Add(line.Substring(i * maxLineLength, line.Length - i * maxLineLength));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_lines.Count > maxLines)
|
||||
{
|
||||
_lines.RemoveRange(0, _lines.Count - maxLines);
|
||||
}
|
||||
// _lines.Add(stackTrace);
|
||||
_logStr = string.Join("\n", _lines);
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity,
|
||||
new Vector3(Screen.width / 1200.0f, Screen.height / 800.0f, 1.0f));
|
||||
GUI.Label(new Rect(10, 10, 800, 370), _logStr, new GUIStyle { fontSize = 10 });
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f75d46640fcd41f49a2bc14a946c16cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -147,6 +147,7 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 67180524}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
@@ -154,7 +155,6 @@ Transform:
|
||||
m_Children:
|
||||
- {fileID: 1371077986}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &67180526
|
||||
MonoBehaviour:
|
||||
@@ -254,13 +254,13 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 790008994}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &1371077985
|
||||
GameObject:
|
||||
@@ -286,13 +286,13 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1371077985}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 67180525}
|
||||
m_RootOrder: -1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1371077987
|
||||
MonoBehaviour:
|
||||
@@ -307,6 +307,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_AvailableProcedureTypeNames:
|
||||
- HotMain.SHGame.Procedure.ProcedureLoadLauncher
|
||||
- Plugins.SHFrame.SHGame.Procedure.ProcedureInitializePackage
|
||||
- Plugins.SHFrame.SHGame.Procedure.ProcedureUpdatePackageManifest
|
||||
- Plugins.SHFrame.SHGame.Procedure.ProcedureUpdatePackageVersion
|
||||
@@ -395,11 +396,18 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1371947665}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 1371947668}
|
||||
- {fileID: 790008996}
|
||||
- {fileID: 67180525}
|
||||
|
||||
@@ -1,297 +0,0 @@
|
||||
using HybridCLR;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Plugins.SHFrame.SHGame.YooAsset;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
/// 脚本工作流程:
|
||||
/// 1.下载资源,用YooAsset资源框架进行下载
|
||||
/// 1)资源文件,ab包等
|
||||
/// 2)热更新dll
|
||||
/// 3) AOT泛型补充元数据dll
|
||||
/// 2.给AOT dll补充元数据,通过RuntimeApi.LoadMetadataForAOTAssembly()
|
||||
/// 3.通过实例化一个prefab,运行热更新代码
|
||||
/// </summary>
|
||||
public class LoadDll : MonoBehaviour
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 资源系统运行模式
|
||||
/// </summary>
|
||||
public EPlayMode PlayMode = EPlayMode.OfflinePlayMode;
|
||||
|
||||
//补充元数据dll的列表,
|
||||
//通过RuntimeApi.LoadMetadataForAOTAssembly()函数来补充AOT泛型的原始元数据
|
||||
public static List<string> AOTMetaAssemblyNames { get; } = new List<string>()
|
||||
{
|
||||
"mscorlib.dll",
|
||||
"System.dll",
|
||||
"System.Core.dll",
|
||||
};
|
||||
|
||||
void Start()
|
||||
{
|
||||
//StartCoroutine(DownLoadAssets(this.StartGame));
|
||||
|
||||
StartCoroutine(DownLoadAssetsByYooAssets(this.StartGame));
|
||||
}
|
||||
|
||||
private static Dictionary<string, byte[]> s_assetDatas = new Dictionary<string, byte[]>();
|
||||
|
||||
public static byte[] GetAssetData(string dllName)
|
||||
{
|
||||
return s_assetDatas[dllName];
|
||||
}
|
||||
|
||||
private string GetWebRequestPath(string asset)
|
||||
{
|
||||
var path = $"{Application.streamingAssetsPath}/{asset}";
|
||||
if (!path.Contains("://"))
|
||||
{
|
||||
path = "file://" + path;
|
||||
}
|
||||
if (path.EndsWith(".dll"))
|
||||
{
|
||||
path += ".bytes";
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
IEnumerator DownLoadAssetsByYooAssets(Action onDownloadComplete)
|
||||
{
|
||||
// 1.初始化资源系统
|
||||
YooAssets.Initialize();
|
||||
|
||||
string packageName = "DefaultPackage";
|
||||
// 创建默认的资源包
|
||||
var package = YooAssets.TryGetPackage(packageName) ?? YooAssets.CreatePackage(packageName);
|
||||
|
||||
// 设置该资源包为默认的资源包,可以使用YooAssets相关加载接口加载该资源包内容。
|
||||
YooAssets.SetDefaultPackage(package);
|
||||
|
||||
if (PlayMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
Debug.Log("编辑器模式");
|
||||
//编辑器模拟模式
|
||||
var initParameters = new EditorSimulateModeParameters();
|
||||
initParameters.EditorFileSystemParameters =
|
||||
FileSystemParameters.CreateDefaultEditorFileSystemParameters(
|
||||
EditorSimulateModeHelper.SimulateBuild(EDefaultBuildPipeline.ScriptableBuildPipeline, "DefaultPackage")
|
||||
);
|
||||
yield return package.InitializeAsync(initParameters);
|
||||
}
|
||||
else if (PlayMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
Debug.Log("在线模式");
|
||||
// 注意:GameQueryServices.cs 太空战机的脚本类,详细见StreamingAssetsHelper.cs
|
||||
string defaultHostServer = "http://127.0.0.1/CDN/Android/v1.0";
|
||||
string fallbackHostServer = "http://127.0.0.1/CDN/Android/v1.0";
|
||||
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
||||
var cacheFileSystem = FileSystemParameters.CreateDefaultCacheFileSystemParameters(remoteServices);
|
||||
var buildinFileSystem = FileSystemParameters.CreateDefaultBuildinFileSystemParameters();
|
||||
|
||||
var initParameters = new HostPlayModeParameters();
|
||||
initParameters.BuildinFileSystemParameters = buildinFileSystem;
|
||||
initParameters.CacheFileSystemParameters = cacheFileSystem;
|
||||
|
||||
yield return package.InitializeAsync(initParameters);
|
||||
}
|
||||
else if (PlayMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
Debug.Log("离线模式");
|
||||
// var buildinFileSystem = FileSystemParameters.CreateDefaultBuildinRawFileSystemParameters();
|
||||
// var initParameters = new OfflinePlayModeParameters();
|
||||
// initParameters.BuildinFileSystemParameters = buildinFileSystem;
|
||||
// yield return package.InitializeAsync(initParameters);
|
||||
// var initParametersOfflinePlayMode = new OfflinePlayModeParameters();
|
||||
// yield return package.InitializeAsync(initParametersOfflinePlayMode);
|
||||
|
||||
var createParameters = new OfflinePlayModeParameters();
|
||||
createParameters.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(new FileStreamDecryption());
|
||||
yield return package.InitializeAsync(createParameters);
|
||||
}
|
||||
|
||||
|
||||
//2.获取资源版本
|
||||
var operation = package.RequestPackageVersionAsync();
|
||||
yield return operation;
|
||||
|
||||
if (operation.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
//更新失败
|
||||
Debug.LogError(operation.Error);
|
||||
//TODO
|
||||
yield break;
|
||||
}
|
||||
string PackageVersion = operation.PackageVersion;
|
||||
|
||||
//3.更新补丁清单
|
||||
var operation2 = package.UpdatePackageManifestAsync(PackageVersion);
|
||||
yield return operation2;
|
||||
|
||||
if (operation2.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
//更新失败
|
||||
Debug.LogError(operation2.Error);
|
||||
//TODO:
|
||||
yield break;
|
||||
}
|
||||
|
||||
//4.下载补丁包
|
||||
yield return Download();
|
||||
//TODO:判断是否下载成功...
|
||||
|
||||
var assets = new List<string>
|
||||
{
|
||||
"HotSamples.dll",
|
||||
}.Concat(AOTMetaAssemblyNames);
|
||||
|
||||
foreach (var asset in assets)
|
||||
{
|
||||
var handle = package.LoadRawFileAsync(asset);
|
||||
yield return handle;
|
||||
byte[] fileData = handle.GetRawFileData();
|
||||
s_assetDatas[asset] = fileData;
|
||||
Debug.Log($"dll:{asset} size:{fileData.Length}");
|
||||
}
|
||||
|
||||
onDownloadComplete();
|
||||
}
|
||||
|
||||
IEnumerator Download()
|
||||
{
|
||||
int downloadingMaxNum = 10;
|
||||
int failedTryAgain = 3;
|
||||
int timeout = 60;
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
var downloader = package.CreateResourceDownloader(downloadingMaxNum, failedTryAgain, timeout);
|
||||
|
||||
//没有需要下载的资源
|
||||
if (downloader.TotalDownloadCount == 0)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
//需要下载的文件总数和总大小
|
||||
int totalDownloadCount = downloader.TotalDownloadCount;
|
||||
long totalDownloadBytes = downloader.TotalDownloadBytes;
|
||||
|
||||
//注册回调方法
|
||||
downloader.OnDownloadErrorCallback = OnDownloadErrorFunction;
|
||||
downloader.OnDownloadProgressCallback = OnDownloadProgressUpdateFunction;
|
||||
downloader.OnDownloadOverCallback = OnDownloadOverFunction;
|
||||
downloader.OnStartDownloadFileCallback = OnStartDownloadFileFunction;
|
||||
|
||||
//开启下载
|
||||
downloader.BeginDownload();
|
||||
yield return downloader;
|
||||
|
||||
//检测下载结果
|
||||
if (downloader.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
//下载成功
|
||||
Debug.Log("更新完成!");
|
||||
//TODO:
|
||||
}
|
||||
else
|
||||
{
|
||||
//下载失败
|
||||
Debug.LogError("更新失败!");
|
||||
//TODO:
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始下载
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="sizeBytes"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void OnStartDownloadFileFunction(string fileName, long sizeBytes)
|
||||
{
|
||||
Debug.Log(string.Format("开始下载:文件名:{0}, 文件大小:{1}", fileName, sizeBytes));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载完成
|
||||
/// </summary>
|
||||
/// <param name="isSucceed"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void OnDownloadOverFunction(bool isSucceed)
|
||||
{
|
||||
Debug.Log("下载" + (isSucceed ? "成功" : "失败"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新中
|
||||
/// </summary>
|
||||
/// <param name="totalDownloadCount"></param>
|
||||
/// <param name="currentDownloadCount"></param>
|
||||
/// <param name="totalDownloadBytes"></param>
|
||||
/// <param name="currentDownloadBytes"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void OnDownloadProgressUpdateFunction(int totalDownloadCount, int currentDownloadCount, long totalDownloadBytes, long currentDownloadBytes)
|
||||
{
|
||||
Debug.Log(string.Format("文件总数:{0}, 已下载文件数:{1}, 下载总大小:{2}, 已下载大小:{3}", totalDownloadCount, currentDownloadCount, totalDownloadBytes, currentDownloadBytes));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载出错
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="error"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void OnDownloadErrorFunction(string fileName, string error)
|
||||
{
|
||||
Debug.LogError(string.Format("下载出错:文件名:{0}, 错误信息:{1}", fileName, error));
|
||||
}
|
||||
|
||||
void StartGame()
|
||||
{
|
||||
LoadMetadataForAOTAssemblies();
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
System.Reflection.Assembly.Load(GetAssetData("HotSamples.dll"));
|
||||
#endif
|
||||
|
||||
//委托加载方式,加载prefab
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
AssetHandle handle = package.LoadAssetAsync<GameObject>("HotPrefab");
|
||||
handle.Completed += Handle_Completed;
|
||||
|
||||
//AssetBundle prefabAb = AssetBundle.LoadFromMemory(GetAssetData("prefabs"));
|
||||
//GameObject testPrefab = Instantiate(prefabAb.LoadAsset<GameObject>("HotUpdatePrefab.prefab"));
|
||||
}
|
||||
|
||||
private void Handle_Completed(AssetHandle obj)
|
||||
{
|
||||
GameObject go = obj.InstantiateSync();
|
||||
Debug.Log($"Prefab name is {go.name}");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 为aot assembly加载原始metadata, 这个代码放aot或者热更新都行。
|
||||
/// 一旦加载后,如果AOT泛型函数对应native实现不存在,则自动替换为解释模式执行
|
||||
/// </summary>
|
||||
private static void LoadMetadataForAOTAssemblies()
|
||||
{
|
||||
/// 注意,补充元数据是给AOT dll补充元数据,而不是给热更新dll补充元数据。
|
||||
/// 热更新dll不缺元数据,不需要补充,如果调用LoadMetadataForAOTAssembly会返回错误
|
||||
///
|
||||
HomologousImageMode mode = HomologousImageMode.SuperSet;
|
||||
foreach (var aotDllName in AOTMetaAssemblyNames)
|
||||
{
|
||||
byte[] dllBytes = GetAssetData(aotDllName);
|
||||
// 加载assembly对应的dll,会自动为它hook。一旦aot泛型函数的native函数不存在,用解释器版本代码
|
||||
LoadImageErrorCode err = RuntimeApi.LoadMetadataForAOTAssembly(dllBytes, mode);
|
||||
Debug.Log($"LoadMetadataForAOTAssembly:{aotDllName}. mode:{mode} ret:{err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21612b697232f004dbebce22c0000dd8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -19,7 +19,21 @@ namespace Plugins.SHFrame.SHGame.Procedure
|
||||
public static string RawFilePackageName = "RawFilePackage";
|
||||
public static string DefaultPackageName = "DefaultPackage";
|
||||
|
||||
protected internal override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
|
||||
//热更新的dll名称
|
||||
public static readonly string[] HotDllName =
|
||||
{
|
||||
};
|
||||
|
||||
public static readonly string[] AotMetaAssemblyFiles =
|
||||
{
|
||||
"mscorlib.dll",
|
||||
"System.dll",
|
||||
"System.Core.dll",
|
||||
};
|
||||
|
||||
|
||||
protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
base.OnEnter(procedureOwner);
|
||||
InitPackage(procedureOwner).Forget();
|
||||
@@ -54,43 +68,34 @@ namespace Plugins.SHFrame.SHGame.Procedure
|
||||
switch (PlayMode)
|
||||
{
|
||||
case EPlayMode.EditorSimulateMode:
|
||||
Log.Debug($"编辑器模拟模式");
|
||||
// 编辑器模拟模式
|
||||
EDefaultBuildPipeline buildPipeline = isRaw ? EDefaultBuildPipeline.RawFileBuildPipeline : EDefaultBuildPipeline.ScriptableBuildPipeline;
|
||||
var initParametersEditorSimulateMode = new EditorSimulateModeParameters();
|
||||
initParametersEditorSimulateMode.EditorFileSystemParameters =
|
||||
FileSystemParameters.CreateDefaultEditorFileSystemParameters(
|
||||
EditorSimulateModeHelper.SimulateBuild(buildPipeline, packageName)
|
||||
);
|
||||
var initParametersEditorSimulateMode = new EditorSimulateModeParameters
|
||||
{
|
||||
SimulateManifestFilePath = EditorSimulateModeHelper.SimulateBuild(buildPipeline, packageName)
|
||||
};
|
||||
initOperation = package.InitializeAsync(initParametersEditorSimulateMode);
|
||||
break;
|
||||
case EPlayMode.OfflinePlayMode:
|
||||
Log.Debug($"单机模式");
|
||||
// 单机模式
|
||||
var createParameters = new OfflinePlayModeParameters
|
||||
var initParametersOfflinePlayMode = new OfflinePlayModeParameters
|
||||
{
|
||||
BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters()
|
||||
DecryptionServices = new FileStreamDecryption()
|
||||
};
|
||||
initOperation = package.InitializeAsync(createParameters);
|
||||
initOperation = package.InitializeAsync(initParametersOfflinePlayMode);
|
||||
break;
|
||||
case EPlayMode.HostPlayMode:
|
||||
Log.Debug($"在线模式");
|
||||
//联机运行模式
|
||||
string defaultHostServer = "http://127.0.0.1/CDN/Android/v1.0";
|
||||
string fallbackHostServer = "http://127.0.0.1/CDN/Android/v1.0";
|
||||
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
||||
var cacheFileSystem = FileSystemParameters.CreateDefaultCacheFileSystemParameters(remoteServices);
|
||||
var buildinFileSystem = FileSystemParameters.CreateDefaultBuildinFileSystemParameters();
|
||||
|
||||
var initParameters = new HostPlayModeParameters();
|
||||
initParameters.BuildinFileSystemParameters = buildinFileSystem;
|
||||
initParameters.CacheFileSystemParameters = cacheFileSystem;
|
||||
initOperation = package.InitializeAsync(initParameters);
|
||||
// //联机运行模式
|
||||
// var initParametersHostPlayMode = new HostPlayModeParameters
|
||||
// {
|
||||
// BuildinQueryServices = new GameQueryServices(),
|
||||
// RemoteServices = new RemoteServices(GetHostServerURL(packageName), GetHostServerURL(packageName))
|
||||
// };
|
||||
// initOperation = package.InitializeAsync(initParametersHostPlayMode);
|
||||
break;
|
||||
}
|
||||
|
||||
Log.Debug($"执行初始化");
|
||||
await initOperation;
|
||||
await initOperation.ToUniTask();
|
||||
|
||||
return package;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using HybridCLR;
|
||||
using Plugins.SHFrame.SHGame.Procedure;
|
||||
using SHFrame;
|
||||
using SHFrame.FSM;
|
||||
using YooAsset;
|
||||
|
||||
namespace HotMain.SHGame.Procedure
|
||||
{
|
||||
public class ProcedureLoadLauncher : ProcedureBase
|
||||
{
|
||||
private static Assembly _launcherAss;
|
||||
|
||||
protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
base.OnEnter(procedureOwner);
|
||||
CreatePackageDownloader(procedureOwner).Forget();
|
||||
}
|
||||
|
||||
private async UniTask CreatePackageDownloader(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
// 打包时内置在包体内的资源 直接先使用包体资源,实例化 登录加载界面后,再去检查是否需要下载更新
|
||||
//加载AOT
|
||||
await LoadMetadataForAOTAssemblies();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 为aot assembly加载原始metadata, 这个代码放aot或者热更新都行。
|
||||
/// 一旦加载后,如果AOT泛型函数对应native实现不存在,则自动替换为解释模式执行
|
||||
/// </summary>
|
||||
private async UniTask LoadMetadataForAOTAssemblies()
|
||||
{
|
||||
var package = YooAssets.GetPackage(ProcedureInitializePackage.RawFilePackageName);
|
||||
|
||||
Log.Debug("加载AOT泛型dll数据");
|
||||
// 注意,补充元数据是给AOT dll补充元数据,而不是给热更新dll补充元数据。
|
||||
// 热更新dll不缺元数据,不需要补充,如果调用LoadMetadataForAOTAssembly会返回错误
|
||||
var mode = HomologousImageMode.SuperSet;
|
||||
foreach (var aotDllName in ProcedureInitializePackage.AotMetaAssemblyFiles)
|
||||
{
|
||||
var handle = package.LoadRawFileSync(aotDllName);
|
||||
await handle.ToUniTask();
|
||||
// 加载assembly对应的dll,会自动为它hook。一旦aot泛型函数的native函数不存在,用解释器版本代码
|
||||
var err = RuntimeApi.LoadMetadataForAOTAssembly(handle.GetRawFileData(), mode);
|
||||
Log.Debug($"LoadMetadataForAOTAssembly:{aotDllName}. mode:{mode} ret:{err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b77504dd9e24ad49ebed9a8def0fe26
|
||||
timeCreated: 1728926184
|
||||
@@ -10,7 +10,7 @@ namespace Plugins.SHFrame.SHGame.Procedure
|
||||
/// </summary>
|
||||
public class ProcedureUpdatePackageManifest : ProcedureBase
|
||||
{
|
||||
protected internal override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
base.OnEnter(procedureOwner);
|
||||
UpdateManifest(procedureOwner).Forget();
|
||||
@@ -38,7 +38,7 @@ namespace Plugins.SHFrame.SHGame.Procedure
|
||||
ResourcePackage package = YooAssets.GetPackage(packageName);
|
||||
|
||||
//2.获取资源版本
|
||||
RequestPackageVersionOperation updateVerOperation = package.RequestPackageVersionAsync(false);
|
||||
UpdatePackageVersionOperation updateVerOperation = package.UpdatePackageVersionAsync(false);
|
||||
await updateVerOperation.ToUniTask();
|
||||
|
||||
// TODO 如果初始化失败弹出提示界面
|
||||
@@ -1,4 +1,5 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using HotMain.SHGame.Procedure;
|
||||
using SHFrame;
|
||||
using SHFrame.FSM;
|
||||
using YooAsset;
|
||||
@@ -10,7 +11,7 @@ namespace Plugins.SHFrame.SHGame.Procedure
|
||||
/// </summary>
|
||||
public class ProcedureUpdatePackageVersion : ProcedureBase
|
||||
{
|
||||
protected internal override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
base.OnEnter(procedureOwner);
|
||||
UpdatePackages(procedureOwner).Forget();
|
||||
@@ -22,6 +23,9 @@ namespace Plugins.SHFrame.SHGame.Procedure
|
||||
if (!result) return;
|
||||
result = await UpdatePackageVersion(ProcedureInitializePackage.DefaultPackageName);
|
||||
if (!result) return;
|
||||
|
||||
//切换到更新资源版本
|
||||
ChangeState<ProcedureLoadLauncher>(procedureOwner);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +33,7 @@ namespace Plugins.SHFrame.SHGame.Procedure
|
||||
{
|
||||
ResourcePackage package = YooAssets.GetPackage(packageName);
|
||||
//2.获取资源版本
|
||||
RequestPackageVersionOperation updateVerOperation = package.RequestPackageVersionAsync(false);
|
||||
UpdatePackageVersionOperation updateVerOperation = package.UpdatePackageVersionAsync(false);
|
||||
await updateVerOperation.ToUniTask();
|
||||
|
||||
// TODO 如果初始化失败弹出提示界面
|
||||
@@ -67,7 +67,7 @@ namespace Plugins.SHFrame.SHGame.YooAsset
|
||||
{
|
||||
BundleStream bundleStream = new BundleStream(fileInfo.FileLoadPath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
managedStream = bundleStream;
|
||||
return AssetBundle.LoadFromStream(bundleStream, fileInfo.FileLoadCRC, GetManagedReadBufferSize());
|
||||
return AssetBundle.LoadFromStream(bundleStream, fileInfo.ConentCRC, GetManagedReadBufferSize());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -78,23 +78,7 @@ namespace Plugins.SHFrame.SHGame.YooAsset
|
||||
{
|
||||
BundleStream bundleStream = new BundleStream(fileInfo.FileLoadPath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
managedStream = bundleStream;
|
||||
return AssetBundle.LoadFromStreamAsync(bundleStream, fileInfo.FileLoadCRC, GetManagedReadBufferSize());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取解密的字节数据
|
||||
/// </summary>
|
||||
byte[] IDecryptionServices.ReadFileData(DecryptFileInfo fileInfo)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取解密的文本数据
|
||||
/// </summary>
|
||||
string IDecryptionServices.ReadFileText(DecryptFileInfo fileInfo)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
return AssetBundle.LoadFromStreamAsync(bundleStream, fileInfo.ConentCRC, GetManagedReadBufferSize());
|
||||
}
|
||||
|
||||
private static uint GetManagedReadBufferSize()
|
||||
@@ -30,7 +30,14 @@ namespace SHFrame.Editor
|
||||
}
|
||||
else if (EditorApplication.isPlaying)
|
||||
{
|
||||
EditorGUILayout.LabelField("Current Procedure", t.CurrentProcedure == null ? "None" : t.CurrentProcedure.GetType().ToString());
|
||||
try
|
||||
{
|
||||
EditorGUILayout.LabelField("Current Procedure", t.CurrentProcedure == null ? "None" : t.CurrentProcedure.GetType().ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace SHFrame.Editor
|
||||
{
|
||||
private static readonly string[] RuntimeAssemblyNames =
|
||||
{
|
||||
"SHFrame",
|
||||
"Assembly-CSharp",
|
||||
"SHFrame.Runtime",
|
||||
};
|
||||
|
||||
private static readonly string[] RuntimeOrEditorAssemblyNames =
|
||||
{
|
||||
"SHFrame",
|
||||
"Assembly-CSharp",
|
||||
"SHFrame.Runtime",
|
||||
};
|
||||
|
||||
|
||||
@@ -13,9 +13,7 @@ MonoBehaviour:
|
||||
m_Name: BuildinCatalog
|
||||
m_EditorClassIdentifier:
|
||||
PackageName: DefaultPackage
|
||||
PackageVersion: 2024-10-14-1193
|
||||
PackageVersion: 2024-10-15-121
|
||||
Wrappers:
|
||||
- BundleGUID: 6e7621677213f3254dc11b107c126e0a
|
||||
FileName: 6e7621677213f3254dc11b107c126e0a.bundle
|
||||
- BundleGUID: e9c321218523545e7d9d80824c77a138
|
||||
FileName: e9c321218523545e7d9d80824c77a138.bundle
|
||||
- BundleGUID: 749c4a9a7fd617e9eacedb8d88c3e174
|
||||
FileName: 749c4a9a7fd617e9eacedb8d88c3e174.bundle
|
||||
|
||||
@@ -13,13 +13,13 @@ MonoBehaviour:
|
||||
m_Name: BuildinCatalog
|
||||
m_EditorClassIdentifier:
|
||||
PackageName: RawFilePackage
|
||||
PackageVersion: 2024-10-14-1193
|
||||
PackageVersion: 2024-10-15-121
|
||||
Wrappers:
|
||||
- BundleGUID: 3323855830799371855418d404b9d19f
|
||||
FileName: 3323855830799371855418d404b9d19f.rawfile
|
||||
- BundleGUID: 570a7c285a3c681be978ebe1bef253e6
|
||||
FileName: 570a7c285a3c681be978ebe1bef253e6.rawfile
|
||||
- BundleGUID: 75298c75d0f841401337a076fd57bf8f
|
||||
FileName: 75298c75d0f841401337a076fd57bf8f.rawfile
|
||||
- BundleGUID: 8f404b79586ad99c09110638a80237f4
|
||||
FileName: 8f404b79586ad99c09110638a80237f4.rawfile
|
||||
- BundleGUID: 20cb526248ed8fbc2a222e07849f4c64
|
||||
FileName: 20cb526248ed8fbc2a222e07849f4c64.rawfile
|
||||
- BundleGUID: 35a3cb8929f188fd948a376f07dc7189
|
||||
FileName: 35a3cb8929f188fd948a376f07dc7189.rawfile
|
||||
- BundleGUID: 4e1f435ea2f1bfd9b23da97f5b2e2e63
|
||||
FileName: 4e1f435ea2f1bfd9b23da97f5b2e2e63.rawfile
|
||||
- BundleGUID: 79fed19d1f8259b979898e24fa6f6bfb
|
||||
FileName: 79fed19d1f8259b979898e24fa6f6bfb.rawfile
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d47a2126befc0a541bc52ebd594f4f8d
|
||||
guid: dd16eaf198793c848b9a014724c43280
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
@@ -1 +1 @@
|
||||
2024-10-14-1193
|
||||
2024-10-15-131
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
e1415831b19cf4ffffe868d6d12a26c5
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8857aada23ad8934bb83dfafaa382841
|
||||
guid: 1bc927fe3c11b0e4db2d275b2c6eda4d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
@@ -0,0 +1 @@
|
||||
c918b2f39c28747c068427f6499fcc11
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c8700e5a670dea45b3244c0008cb22a
|
||||
guid: 253946b296feb0943a18d893c2ed3e16
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04b54a6ad64db0c4aa1e435d4db6c77b
|
||||
guid: 465ede1251ba0bd47aac80dd35883eec
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48d69fdf01fcebc44a35db256a0d6f2a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d8da02feee275e44b1830c325be6c92
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 452e5bfcc5b1540499a40f24643eae55
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 401e8afd8e6e98941a87ff955d31a934
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 797dc218afdd7e34d9d05b1c85ca1171
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5992a68cbdfc984c9bdc6f48639d1bc
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86c11fa1233788a49b07c2255ae3849c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1 +1 @@
|
||||
2024-10-14-1193
|
||||
2024-10-15-131
|
||||
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54eb3e84bd1428c44890809c869bc5ca
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1 +0,0 @@
|
||||
ce07ea90c0ed2cddfb8a162acb3b5a9a
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9e676165cc6d1648810b9271e19c480
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87a1fb271c7f63a46ac4c113f9225de5
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1 @@
|
||||
bb2a6addb83bf0abb192d135cd9953a6
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9674dff3d6102349a3c38405d57135f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user