diff --git a/Assets/00.BuildOriginality/Editor/ArtBuild/BuildArtAssetWindow.cs b/Assets/00.BuildOriginality/Editor/ArtBuild/BuildArtAssetWindow.cs
index 17396fc..667d808 100644
--- a/Assets/00.BuildOriginality/Editor/ArtBuild/BuildArtAssetWindow.cs
+++ b/Assets/00.BuildOriginality/Editor/ArtBuild/BuildArtAssetWindow.cs
@@ -234,17 +234,10 @@ namespace Stary.Evo.Editor
using (FileStream zipStream = new FileStream(zipFilePath, FileMode.Create))
using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create))
{
- // 指定需要压缩的后缀(例如:只压缩.json和.dll文件)
- //string[] targetExtensions = { ".bundle" };
-
- // 遍历目录下所有文件
- // foreach (string filePath in Directory.GetFiles(outFilePath, "*.*", SearchOption.AllDirectories)
- // .Where(f => targetExtensions.Contains(Path.GetExtension(f),
- // StringComparer.OrdinalIgnoreCase)))
foreach (string filePath in Directory.GetFiles(outFilePath, "*.*", SearchOption.AllDirectories))
{
// 获取文件在压缩包中的相对路径
- string entryName = Path.GetRelativePath(outFilePath, filePath);
+ string entryName = $"{packageName}/{ Path.GetRelativePath(outFilePath, filePath)}";
// 创建zip条目
ZipArchiveEntry entry = archive.CreateEntry(entryName,
@@ -290,7 +283,7 @@ namespace Stary.Evo.Editor
public async Task UpdateFileDataResDomain(string zipFilePath)
{
- string ip = EditorPrefs.GetString("ip");
+ string ip = CustomEditorPrefs.GetString("ip");
var messageEntity = await WebRequestSystem.PostFile(ip + "/FileLoad/UpLoadFile", new[] { zipFilePath });
EditorUtility.DisplayProgressBar("提示", $"开始上传{packageName}(上传zip文件)", 0.5f);
if (messageEntity.code == 200)
@@ -363,7 +356,7 @@ namespace Stary.Evo.Editor
DomainName = selectedPackageNames,
Platform = EditorUserBuildSettings.activeBuildTarget.ToString(),
};
- string ip = EditorPrefs.GetString("ip");
+ string ip = CustomEditorPrefs.GetString("ip");
var resResultMessage = await WebRequestSystem.Post(ip + "/ResDomain/GetResDomainByDomain",
JsonConvert.SerializeObject(resDmainAddRequst));
//如果低于服务器版本,更新版本号
diff --git a/Assets/00.BuildOriginality/Editor/Login/LoginAssetWindow.cs b/Assets/00.BuildOriginality/Editor/Login/LoginAssetWindow.cs
index 8fdc74c..0f0327b 100644
--- a/Assets/00.BuildOriginality/Editor/Login/LoginAssetWindow.cs
+++ b/Assets/00.BuildOriginality/Editor/Login/LoginAssetWindow.cs
@@ -41,7 +41,7 @@ namespace Stary.Evo
else
{
ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
- EditorPrefs.SetString("ip", ip);
+ CustomEditorPrefs.SetString("ip", ip);
userName = hotfixMainResDomain.hotfixMainResDomainEntity.username;
password = hotfixMainResDomain.hotfixMainResDomainEntity.password;
}
@@ -97,7 +97,7 @@ namespace Stary.Evo
{
buildAssetType = BuildAssetType.Login;
message = "未登录";
- EditorPrefs.DeleteKey("Authorization");
+ CustomEditorPrefs.DeleteKey("Authorization");
}
private void SetWebRequestInfo()
@@ -107,7 +107,7 @@ namespace Stary.Evo
hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig = ip;
hotfixMainResDomain.hotfixMainResDomainEntity.username = userName;
hotfixMainResDomain.hotfixMainResDomainEntity.password = password;
- EditorPrefs.SetString("ip", ip);
+ CustomEditorPrefs.SetString("ip", ip);
EditorUtility.SetDirty(hotfixMainResDomain);
AssetDatabase.SaveAssets();
}
diff --git a/Assets/00.BuildOriginality/package.json b/Assets/00.BuildOriginality/package.json
index c8f5a45..0ad12f5 100644
--- a/Assets/00.BuildOriginality/package.json
+++ b/Assets/00.BuildOriginality/package.json
@@ -1,6 +1,6 @@
{
"name": "com.staryevo.buildoriginality",
- "version": "1.0.13",
+ "version": "1.1.0",
"displayName": "00.StaryEvo.BuildOriginality",
"description": "美术打包工具",
"unity": "2021.3",
diff --git a/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/PlayerPrefsData.cs b/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/PlayerPrefsData.cs
deleted file mode 100644
index ce3f6cb..0000000
--- a/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/PlayerPrefsData.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-/****************************************************
- 文件:StringToLayer.cs
- 作者:张铮
- 邮箱:834207172@qq.com
- 日期:2022/3/3 17:53:52
- 功能:
-*****************************************************/
-
-using System.IO;
-using System.Text;
-using UnityEditor;
-using UnityEngine;
-
-namespace Stary.Evo.Editor
-{
- public class PlayerPrefsData
- {
- [MenuItem("Evo/Utility/PlayerPrefsClear")]
- private static void PlayerPrefsClear()
- {
- PlayerPrefs.DeleteAll();
- EditorPrefs.DeleteAll();
- }
-
- }
-}
\ No newline at end of file
diff --git a/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/PlayerPrefsData.cs.meta b/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/PlayerPrefsData.cs.meta
deleted file mode 100644
index 92e6333..0000000
--- a/Assets/00.StaryEvo/Editor/Create/CreatStringToLayer/PlayerPrefsData.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: 56c6f609a1f54a48939218df73a1e4fd
-timeCreated: 1748584452
\ No newline at end of file
diff --git a/Assets/00.StaryEvo/Editor/Tools/CustomEditorPrefs.cs b/Assets/00.StaryEvo/Editor/Tools/CustomEditorPrefs.cs
new file mode 100644
index 0000000..c0bfc76
--- /dev/null
+++ b/Assets/00.StaryEvo/Editor/Tools/CustomEditorPrefs.cs
@@ -0,0 +1,278 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using UnityEditor;
+using UnityEngine;
+
+namespace Stary.Evo.Editor
+{
+ ///
+ /// 自定义EditorPrefs实现,数据存储在项目根目录的EditorPrefs.ini文件中
+ ///
+ public static class CustomEditorPrefs
+ {
+ private const string FileName = "EditorPrefs.ini";
+ private static string FilePath => Path.Combine(Application.dataPath, "..", FileName);
+
+ // 缓存的数据
+ private static Dictionary _dataCache;
+ private static bool _isDataLoaded;
+
+ ///
+ /// 设置字符串值
+ ///
+ /// 键
+ /// 值
+ public static void SetString(string key, string value)
+ {
+ LoadData();
+ _dataCache[key] = value;
+ SaveData();
+ }
+
+ ///
+ /// 获取字符串值
+ ///
+ /// 键
+ /// 默认值
+ /// 值
+ public static string GetString(string key, string defaultValue = "")
+ {
+ LoadData();
+ return _dataCache.TryGetValue(key, out var value) ? (string)value : defaultValue;
+ }
+
+ ///
+ /// 设置整数值
+ ///
+ /// 键
+ /// 值
+ public static void SetInt(string key, int value)
+ {
+ LoadData();
+ _dataCache[key] = value;
+ SaveData();
+ }
+
+ ///
+ /// 获取整数值
+ ///
+ /// 键
+ /// 默认值
+ /// 值
+ public static int GetInt(string key, int defaultValue = 0)
+ {
+ LoadData();
+ return _dataCache.TryGetValue(key, out var value) ? (int)value : defaultValue;
+ }
+
+ ///
+ /// 设置浮点数值
+ ///
+ /// 键
+ /// 值
+ public static void SetFloat(string key, float value)
+ {
+ LoadData();
+ _dataCache[key] = value;
+ SaveData();
+ }
+
+ ///
+ /// 获取浮点数值
+ ///
+ /// 键
+ /// 默认值
+ /// 值
+ public static float GetFloat(string key, float defaultValue = 0.0f)
+ {
+ LoadData();
+ return _dataCache.TryGetValue(key, out var value) ? (float)value : defaultValue;
+ }
+
+ ///
+ /// 设置布尔值
+ ///
+ /// 键
+ /// 值
+ public static void SetBool(string key, bool value)
+ {
+ LoadData();
+ _dataCache[key] = value;
+ SaveData();
+ }
+
+ ///
+ /// 获取布尔值
+ ///
+ /// 键
+ /// 默认值
+ /// 值
+ public static bool GetBool(string key, bool defaultValue = false)
+ {
+ LoadData();
+ return _dataCache.TryGetValue(key, out var value) ? (bool)value : defaultValue;
+ }
+
+ ///
+ /// 检查是否存在指定的键
+ ///
+ /// 键
+ /// 是否存在
+ public static bool HasKey(string key)
+ {
+ LoadData();
+ return _dataCache.ContainsKey(key);
+ }
+
+ ///
+ /// 删除指定的键
+ ///
+ /// 键
+ public static void DeleteKey(string key)
+ {
+ LoadData();
+ if (_dataCache.Remove(key))
+ {
+ SaveData();
+ }
+ }
+
+ ///
+ /// 清除所有数据
+ ///
+ public static void DeleteAll()
+ {
+ _dataCache.Clear();
+ SaveData();
+ }
+
+ ///
+ /// 获取所有键
+ ///
+ /// 键列表
+ public static string[] GetAllKeys()
+ {
+ LoadData();
+ return _dataCache.Keys.ToArray();
+ }
+
+ ///
+ /// 获取所有键值对
+ ///
+ /// 键值对字典
+ public static Dictionary GetAll()
+ {
+ LoadData();
+ return new Dictionary(_dataCache);
+ }
+
+ ///
+ /// 从文件加载数据
+ ///
+ private static void LoadData()
+ {
+ if (_isDataLoaded && _dataCache != null)
+ return;
+
+ _dataCache = new Dictionary();
+
+ if (!File.Exists(FilePath))
+ {
+ _isDataLoaded = true;
+ return;
+ }
+
+ try
+ {
+ var lines = File.ReadAllLines(FilePath);
+ foreach (var line in lines)
+ {
+ if (string.IsNullOrWhiteSpace(line) || line.StartsWith("#"))
+ continue;
+
+ var parts = line.Split(new[] { '=' }, 2);
+ if (parts.Length != 2)
+ continue;
+
+ var key = parts[0].Trim();
+ var valueStr = parts[1].Trim();
+
+ // 尝试解析不同类型的值
+ if (bool.TryParse(valueStr, out var boolValue))
+ {
+ _dataCache[key] = boolValue;
+ }
+ else if (int.TryParse(valueStr, out var intValue))
+ {
+ _dataCache[key] = intValue;
+ }
+ else if (float.TryParse(valueStr, out var floatValue))
+ {
+ _dataCache[key] = floatValue;
+ }
+ else
+ {
+ // 字符串类型
+ _dataCache[key] = valueStr;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Debug.LogError($"加载CustomEditorPrefs数据失败: {e.Message}");
+ _dataCache = new Dictionary();
+ }
+
+ _isDataLoaded = true;
+ }
+
+ ///
+ /// 保存数据到文件
+ ///
+ private static void SaveData()
+ {
+ if (_dataCache == null)
+ return;
+
+ try
+ {
+ var lines = new List
+ {
+ "# Custom Editor Prefs Data",
+ $"# Last Modified: {DateTime.Now}",
+ ""
+ };
+
+ foreach (var kvp in _dataCache)
+ {
+ var valueStr = kvp.Value.ToString();
+ lines.Add($"{kvp.Key}={valueStr}");
+ }
+
+ // 确保目录存在
+ var directory = Path.GetDirectoryName(FilePath);
+ if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
+ {
+ Directory.CreateDirectory(directory);
+ }
+
+ File.WriteAllLines(FilePath, lines);
+ }
+ catch (Exception e)
+ {
+ Debug.LogError($"保存CustomEditorPrefs数据失败: {e.Message}");
+ }
+ }
+
+ ///
+ /// 手动刷新数据(重新从文件加载)
+ ///
+ public static void Refresh()
+ {
+ _isDataLoaded = false;
+ LoadData();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/00.StaryEvo/Editor/Tools/CustomEditorPrefs.cs.meta b/Assets/00.StaryEvo/Editor/Tools/CustomEditorPrefs.cs.meta
new file mode 100644
index 0000000..5499585
--- /dev/null
+++ b/Assets/00.StaryEvo/Editor/Tools/CustomEditorPrefs.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 794f2171aa6c41a3a0845f2dd0b9ef91
+timeCreated: 1767769690
\ No newline at end of file
diff --git a/Assets/00.StaryEvo/Editor/Tools/PlayerPrefsWindow.cs b/Assets/00.StaryEvo/Editor/Tools/PlayerPrefsWindow.cs
new file mode 100644
index 0000000..06b72f8
--- /dev/null
+++ b/Assets/00.StaryEvo/Editor/Tools/PlayerPrefsWindow.cs
@@ -0,0 +1,367 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEditor;
+using UnityEngine;
+
+namespace Stary.Evo.Editor
+{
+ ///
+ /// PlayerPrefs和CustomEditorPrefs的管理窗口
+ ///
+ public class PlayerPrefsWindow : EditorWindow
+ {
+ private Vector2 _scrollPosition;
+ private string _searchFilter = "";
+ private Dictionary _dataCache;
+ private bool _isAutoSave = true;
+ private string _lastSaveTime = "";
+
+ // 添加新键值对的相关字段
+ private string _newKey = "";
+ private string _newStringValue = "";
+ private int _newIntValue = 0;
+ private float _newFloatValue = 0f;
+ private bool _newBoolValue = false;
+
+ private enum ValueType
+ {
+ String,
+ Int,
+ Float,
+ Bool
+ }
+
+ private ValueType _selectedValueType = ValueType.String;
+
+ // 数据存储类型
+ private enum PrefsType
+ {
+ CustomEditorPrefs,
+ CustomPlayerPrefs
+ }
+
+ private PrefsType _selectedPrefsType = PrefsType.CustomEditorPrefs;
+
+ [MenuItem("Evo/Utility/PlayerPrefs")]
+ public static void ShowWindow()
+ {
+ var window = GetWindow("PlayerPrefs Manager");
+ window.minSize = new Vector2(700, 500);
+ }
+
+ private void OnEnable()
+ {
+ RefreshData();
+ }
+
+ private void OnGUI()
+ {
+ // 顶部工具栏
+ GUILayout.BeginHorizontal(EditorStyles.toolbar);
+
+ // 数据类型选择 - 保存当前值以便检查是否有变化
+ var oldPrefsType = _selectedPrefsType;
+ _selectedPrefsType =
+ (PrefsType)EditorGUILayout.EnumPopup(_selectedPrefsType, EditorStyles.toolbarPopup,
+ GUILayout.Width(150));
+
+ // 当_selectedPrefsType被修改时,刷新数据
+ if (_selectedPrefsType != oldPrefsType)
+ {
+ RefreshData();
+ }
+
+ // 搜索框
+ _searchFilter = EditorGUILayout.TextField(_searchFilter, EditorStyles.toolbarSearchField);
+
+ // 自动保存选项
+ _isAutoSave = GUILayout.Toggle(_isAutoSave, "自动保存", EditorStyles.toolbarButton);
+
+ // 刷新按钮
+ if (GUILayout.Button("刷新", EditorStyles.toolbarButton))
+ {
+ RefreshData();
+ }
+
+ if (!_isAutoSave)
+ {
+ // 手动保存按钮
+ if (GUILayout.Button("保存", EditorStyles.toolbarButton))
+ {
+ SaveDataManually();
+ }
+ }
+
+ // 清除所有按钮
+ if (GUILayout.Button("清除所有", EditorStyles.toolbarButton, GUILayout.Width(80)))
+ {
+ if (EditorUtility.DisplayDialog("确认清除", $"确定要清除所有{_selectedPrefsType}数据吗?", "清除", "取消"))
+ {
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ CustomEditorPrefs.DeleteAll();
+ else
+ CustomPlayerPrefs.DeleteAll();
+
+ RefreshData();
+ _lastSaveTime = $"最后保存: {DateTime.Now.ToString("HH:mm:ss")}";
+ }
+ }
+
+ GUILayout.EndHorizontal();
+
+ // 保存状态提示
+ if (!string.IsNullOrEmpty(_lastSaveTime))
+ {
+ GUILayout.Label(_lastSaveTime, EditorStyles.miniLabel);
+ }
+
+ // 添加新键值对区域
+ GUILayout.BeginVertical(EditorStyles.helpBox);
+
+ GUILayout.BeginHorizontal();
+ _selectedValueType = (ValueType)EditorGUILayout.EnumPopup(_selectedValueType);
+ GUILayout.Space(20);
+ _newKey = EditorGUILayout.TextField("键:", _newKey);
+ GUILayout.Space(20);
+ // 根据选择的类型显示不同的输入框
+ switch (_selectedValueType)
+ {
+ case ValueType.String:
+ _newStringValue = EditorGUILayout.TextField("值:", _newStringValue);
+ break;
+ case ValueType.Int:
+ _newIntValue = EditorGUILayout.IntField("值:", _newIntValue);
+ break;
+ case ValueType.Float:
+ _newFloatValue = EditorGUILayout.FloatField("值:", _newFloatValue);
+ break;
+ case ValueType.Bool:
+ _newBoolValue = EditorGUILayout.Toggle("值:", _newBoolValue);
+ break;
+ }
+
+
+
+ if (GUILayout.Button("添加", GUILayout.Width(80)))
+ {
+ AddNewKeyValuePair();
+ }
+
+ GUILayout.EndHorizontal();
+ GUILayout.EndVertical();
+
+ // 内容区域
+ _scrollPosition = GUILayout.BeginScrollView(_scrollPosition);
+
+ // 绘制数据
+ DrawData();
+
+ GUILayout.EndScrollView();
+ }
+
+ private void RefreshData()
+ {
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ _dataCache = CustomEditorPrefs.GetAll();
+ else
+ _dataCache = CustomPlayerPrefs.GetAll();
+
+ Repaint();
+ }
+
+ private void DrawData()
+ {
+ var filteredData = string.IsNullOrEmpty(_searchFilter)
+ ? _dataCache
+ : _dataCache.Where(kvp => kvp.Key.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase))
+ .ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
+
+ foreach (var kvp in filteredData)
+ {
+ GUILayout.BeginHorizontal("box");
+
+ // 键名
+ GUILayout.Label(kvp.Key, GUILayout.Width(200));
+
+ // 值类型和编辑
+ var key = kvp.Key;
+ var value = kvp.Value;
+
+ if (value is string stringValue)
+ {
+ GUILayout.Label("String", GUILayout.Width(80));
+ var newValue = EditorGUILayout.TextField(stringValue);
+ if (newValue != stringValue)
+ {
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ CustomEditorPrefs.SetString(key, newValue);
+ else
+ CustomPlayerPrefs.SetString(key, newValue);
+
+ if (_isAutoSave)
+ {
+ _lastSaveTime = $"最后保存: {DateTime.Now.ToString("HH:mm:ss")}";
+ }
+
+ RefreshData();
+ }
+ }
+ else if (value is float floatValue)
+ {
+ GUILayout.Label("Float", GUILayout.Width(80));
+ var newValue = EditorGUILayout.FloatField(floatValue);
+ if (newValue != floatValue)
+ {
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ CustomEditorPrefs.SetFloat(key, newValue);
+ else
+ CustomPlayerPrefs.SetFloat(key, newValue);
+
+ if (_isAutoSave)
+ {
+ _lastSaveTime = $"最后保存: {DateTime.Now.ToString("HH:mm:ss")}";
+ }
+
+ RefreshData();
+ }
+ }
+ else if (value is int intValue)
+ {
+ GUILayout.Label("Int", GUILayout.Width(80));
+ var newValue = EditorGUILayout.IntField(intValue);
+ if (newValue != intValue)
+ {
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ CustomEditorPrefs.SetInt(key, newValue);
+ else
+ CustomPlayerPrefs.SetInt(key, newValue);
+
+ if (_isAutoSave)
+ {
+ _lastSaveTime = $"最后保存: {DateTime.Now.ToString("HH:mm:ss")}";
+ }
+
+ RefreshData();
+ }
+ }
+ else if (value is bool boolValue)
+ {
+ GUILayout.Label("Bool", GUILayout.Width(80));
+ var newValue = EditorGUILayout.Toggle(boolValue);
+ if (newValue != boolValue)
+ {
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ CustomEditorPrefs.SetBool(key, newValue);
+ else
+ CustomPlayerPrefs.SetBool(key, newValue);
+
+ if (_isAutoSave)
+ {
+ _lastSaveTime = $"最后保存: {DateTime.Now.ToString("HH:mm:ss")}";
+ }
+
+ RefreshData();
+ }
+ }
+
+ // 删除按钮
+ if (GUILayout.Button("删除", GUILayout.Width(60)))
+ {
+ if (EditorUtility.DisplayDialog("确认删除", $"确定要删除键 '{key}' 吗?", "删除", "取消"))
+ {
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ CustomEditorPrefs.DeleteKey(key);
+ else
+ CustomPlayerPrefs.DeleteKey(key);
+
+ if (_isAutoSave)
+ {
+ _lastSaveTime = $"最后保存: {DateTime.Now.ToString("HH:mm:ss")}";
+ }
+
+ RefreshData();
+ }
+ }
+
+ GUILayout.EndHorizontal();
+ }
+
+ if (filteredData.Count == 0)
+ {
+ GUILayout.Label("没有找到数据", EditorStyles.centeredGreyMiniLabel);
+ }
+ }
+
+ ///
+ /// 手动保存数据
+ ///
+ private void SaveDataManually()
+ {
+ // 这两个类在每个Set方法中已经自动保存,这里只需要更新状态提示
+ _lastSaveTime = $"最后保存: {DateTime.Now.ToString("HH:mm:ss")}";
+ EditorUtility.DisplayDialog("保存成功", $"{_selectedPrefsType}数据已保存", "确定");
+ }
+
+ ///
+ /// 添加新键值对
+ ///
+ private void AddNewKeyValuePair()
+ {
+ if (string.IsNullOrEmpty(_newKey))
+ {
+ EditorUtility.DisplayDialog("错误", "键名不能为空", "确定");
+ return;
+ }
+
+ if (_dataCache.ContainsKey(_newKey))
+ {
+ EditorUtility.DisplayDialog("错误", $"键 '{_newKey}' 已存在", "确定");
+ return;
+ }
+
+ // 根据选择的类型添加新键值对
+ switch (_selectedValueType)
+ {
+ case ValueType.String:
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ CustomEditorPrefs.SetString(_newKey, _newStringValue);
+ else
+ CustomPlayerPrefs.SetString(_newKey, _newStringValue);
+ break;
+ case ValueType.Int:
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ CustomEditorPrefs.SetInt(_newKey, _newIntValue);
+ else
+ CustomPlayerPrefs.SetInt(_newKey, _newIntValue);
+ break;
+ case ValueType.Float:
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ CustomEditorPrefs.SetFloat(_newKey, _newFloatValue);
+ else
+ CustomPlayerPrefs.SetFloat(_newKey, _newFloatValue);
+ break;
+ case ValueType.Bool:
+ if (_selectedPrefsType == PrefsType.CustomEditorPrefs)
+ CustomEditorPrefs.SetBool(_newKey, _newBoolValue);
+ else
+ CustomPlayerPrefs.SetBool(_newKey, _newBoolValue);
+ break;
+ }
+
+ if (_isAutoSave)
+ {
+ _lastSaveTime = $"最后保存: {DateTime.Now.ToString("HH:mm:ss")}";
+ }
+
+ // 清空输入框
+ _newKey = "";
+ _newStringValue = "";
+ _newIntValue = 0;
+ _newFloatValue = 0f;
+ _newBoolValue = false;
+
+ RefreshData();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/00.StaryEvo/Editor/Tools/PlayerPrefsWindow.cs.meta b/Assets/00.StaryEvo/Editor/Tools/PlayerPrefsWindow.cs.meta
new file mode 100644
index 0000000..ee85260
--- /dev/null
+++ b/Assets/00.StaryEvo/Editor/Tools/PlayerPrefsWindow.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 32bc456fb1324efcb559a6f809fc2fcb
+timeCreated: 1767767824
\ No newline at end of file
diff --git a/Assets/00.StaryEvo/Runtime/Tool/CustomPlayerPrefs.cs b/Assets/00.StaryEvo/Runtime/Tool/CustomPlayerPrefs.cs
new file mode 100644
index 0000000..8d6b150
--- /dev/null
+++ b/Assets/00.StaryEvo/Runtime/Tool/CustomPlayerPrefs.cs
@@ -0,0 +1,279 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using UnityEditor;
+using UnityEngine;
+
+namespace Stary.Evo
+{
+ ///
+ /// 自定义EditorPrefs实现,数据存储在项目根目录的EditorPrefs.ini文件中
+ ///
+ public static class CustomPlayerPrefs
+ {
+ private const string FileName = "PlayerPrefs.ini";
+ private static string FilePath => Path.Combine(Application.persistentDataPath, FileName);
+
+ // 缓存的数据
+ private static Dictionary _dataCache;
+ private static bool _isDataLoaded;
+
+ ///
+ /// 设置字符串值
+ ///
+ /// 键
+ /// 值
+ public static void SetString(string key, string value)
+ {
+ LoadData();
+ _dataCache[key] = value;
+ SaveData();
+ }
+
+ ///
+ /// 获取字符串值
+ ///
+ /// 键
+ /// 默认值
+ /// 值
+ public static string GetString(string key, string defaultValue = "")
+ {
+ LoadData();
+ _dataCache.TryGetValue(key, out var value);
+ return value is string ? (string)value : defaultValue;
+ }
+
+ ///
+ /// 设置整数值
+ ///
+ /// 键
+ /// 值
+ public static void SetInt(string key, int value)
+ {
+ LoadData();
+ _dataCache[key] = value;
+ SaveData();
+ }
+
+ ///
+ /// 获取整数值
+ ///
+ /// 键
+ /// 默认值
+ /// 值
+ public static int GetInt(string key, int defaultValue = 0)
+ {
+ LoadData();
+ return _dataCache.TryGetValue(key, out var value) ? (int)value : defaultValue;
+ }
+
+ ///
+ /// 设置浮点数值
+ ///
+ /// 键
+ /// 值
+ public static void SetFloat(string key, float value)
+ {
+ LoadData();
+ _dataCache[key] = value;
+ SaveData();
+ }
+
+ ///
+ /// 获取浮点数值
+ ///
+ /// 键
+ /// 默认值
+ /// 值
+ public static float GetFloat(string key, float defaultValue = 0.0f)
+ {
+ LoadData();
+ return _dataCache.TryGetValue(key, out var value) ? (float)value : defaultValue;
+ }
+
+ ///
+ /// 设置布尔值
+ ///
+ /// 键
+ /// 值
+ public static void SetBool(string key, bool value)
+ {
+ LoadData();
+ _dataCache[key] = value;
+ SaveData();
+ }
+
+ ///
+ /// 获取布尔值
+ ///
+ /// 键
+ /// 默认值
+ /// 值
+ public static bool GetBool(string key, bool defaultValue = false)
+ {
+ LoadData();
+ return _dataCache.TryGetValue(key, out var value) ? (bool)value : defaultValue;
+ }
+
+ ///
+ /// 检查是否存在指定的键
+ ///
+ /// 键
+ /// 是否存在
+ public static bool HasKey(string key)
+ {
+ LoadData();
+ return _dataCache.ContainsKey(key);
+ }
+
+ ///
+ /// 删除指定的键
+ ///
+ /// 键
+ public static void DeleteKey(string key)
+ {
+ LoadData();
+ if (_dataCache.Remove(key))
+ {
+ SaveData();
+ }
+ }
+
+ ///
+ /// 清除所有数据
+ ///
+ public static void DeleteAll()
+ {
+ _dataCache.Clear();
+ SaveData();
+ }
+
+ ///
+ /// 获取所有键
+ ///
+ /// 键列表
+ public static string[] GetAllKeys()
+ {
+ LoadData();
+ return _dataCache.Keys.ToArray();
+ }
+
+ ///
+ /// 获取所有键值对
+ ///
+ /// 键值对字典
+ public static Dictionary GetAll()
+ {
+ LoadData();
+ return new Dictionary(_dataCache);
+ }
+
+ ///
+ /// 从文件加载数据
+ ///
+ private static void LoadData()
+ {
+ if (_isDataLoaded && _dataCache != null)
+ return;
+
+ _dataCache = new Dictionary();
+
+ if (!File.Exists(FilePath))
+ {
+ _isDataLoaded = true;
+ return;
+ }
+
+ try
+ {
+ var lines = File.ReadAllLines(FilePath);
+ foreach (var line in lines)
+ {
+ if (string.IsNullOrWhiteSpace(line) || line.StartsWith("#"))
+ continue;
+
+ var parts = line.Split(new[] { '=' }, 2);
+ if (parts.Length != 2)
+ continue;
+
+ var key = parts[0].Trim();
+ var valueStr = parts[1].Trim();
+
+ // 尝试解析不同类型的值
+ if (bool.TryParse(valueStr, out var boolValue))
+ {
+ _dataCache[key] = boolValue;
+ }
+ else if (int.TryParse(valueStr, out var intValue))
+ {
+ _dataCache[key] = intValue;
+ }
+ else if (float.TryParse(valueStr, out var floatValue))
+ {
+ _dataCache[key] = floatValue;
+ }
+ else
+ {
+ // 字符串类型
+ _dataCache[key] = valueStr;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Debug.LogError($"加载CustomPlayerPrefs数据失败: {e.Message}");
+ _dataCache = new Dictionary();
+ }
+
+ _isDataLoaded = true;
+ }
+
+ ///
+ /// 保存数据到文件
+ ///
+ private static void SaveData()
+ {
+ if (_dataCache == null)
+ return;
+
+ try
+ {
+ var lines = new List
+ {
+ "# Custom Player Prefs Data",
+ $"# Last Modified: {DateTime.Now}",
+ ""
+ };
+
+ foreach (var kvp in _dataCache)
+ {
+ var valueStr = kvp.Value.ToString();
+ lines.Add($"{kvp.Key}={valueStr}");
+ }
+
+ // 确保目录存在
+ var directory = Path.GetDirectoryName(FilePath);
+ if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
+ {
+ Directory.CreateDirectory(directory);
+ }
+
+ File.WriteAllLines(FilePath, lines);
+ }
+ catch (Exception e)
+ {
+ Debug.LogError($"保存CustomPlayerPrefs数据失败: {e.Message}");
+ }
+ }
+
+ ///
+ /// 手动刷新数据(重新从文件加载)
+ ///
+ public static void Refresh()
+ {
+ _isDataLoaded = false;
+ LoadData();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/00.StaryEvo/Runtime/Tool/CustomPlayerPrefs.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/CustomPlayerPrefs.cs.meta
new file mode 100644
index 0000000..92e2b59
--- /dev/null
+++ b/Assets/00.StaryEvo/Runtime/Tool/CustomPlayerPrefs.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: ab4705a457b8462f8ec9023e35859260
+timeCreated: 1767771190
\ No newline at end of file
diff --git a/Assets/00.StaryEvo/Runtime/Tool/WebRequest/WebRequestSystem.cs b/Assets/00.StaryEvo/Runtime/Tool/WebRequest/WebRequestSystem.cs
index a554719..cc37f9a 100644
--- a/Assets/00.StaryEvo/Runtime/Tool/WebRequest/WebRequestSystem.cs
+++ b/Assets/00.StaryEvo/Runtime/Tool/WebRequest/WebRequestSystem.cs
@@ -21,7 +21,7 @@ namespace Stary.Evo
#if UNITY_EDITOR
authorization = EditorPrefs.GetString("Authorization");
#else
- authorization = PlayerPrefs.GetString("Authorization");
+ authorization = CustomPlayerPrefs.GetString("Authorization");
#endif
}
@@ -72,7 +72,7 @@ namespace Stary.Evo
#if UNITY_EDITOR
EditorPrefs.SetString("Authorization", authorization);
#else
- PlayerPrefs.SetString("Authorization",authorization);
+ CustomPlayerPrefs.SetString("Authorization",authorization);
#endif
Debug.Log("UnityEvo:登录成功");
@@ -100,7 +100,7 @@ namespace Stary.Evo
#if UNITY_EDITOR
authorization = EditorPrefs.GetString("Authorization");
#else
- authorization = PlayerPrefs.GetString("Authorization");
+ authorization = CustomPlayerPrefs.GetString("Authorization");
#endif
try
{
diff --git a/Assets/00.StaryEvo/package.json b/Assets/00.StaryEvo/package.json
index ec05b14..c285ae4 100644
--- a/Assets/00.StaryEvo/package.json
+++ b/Assets/00.StaryEvo/package.json
@@ -1,6 +1,6 @@
{
"name": "com.staryevo.main",
- "version": "2.0.19",
+ "version": "2.1.0",
"displayName": "00.StaryEvo",
"description": "This is an Framework package(后台服务器版本,端口9527)",
"unity": "2021.3",
diff --git a/Assets/00.StaryEvoTools/Editor/Build/BuildReport.cs b/Assets/00.StaryEvoTools/Editor/Build/BuildReport.cs
index 948ed4e..b8dd38c 100644
--- a/Assets/00.StaryEvoTools/Editor/Build/BuildReport.cs
+++ b/Assets/00.StaryEvoTools/Editor/Build/BuildReport.cs
@@ -15,7 +15,7 @@ namespace Stary.Evo.Editor
public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
{
- string platform = EditorPrefs.GetString("ChangePlayerSchema");
+ string platform = CustomEditorPrefs.GetString("ChangePlayerSchema");
// build前
if (Enum.Parse(platform) == PLayerMode.EDITOR_SIMULATEMODE)
{
diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/BuildAssetDataSetting.cs b/Assets/00.StaryEvoTools/Editor/BuildAsset/BuildAssetDataSetting.cs
index ff9000c..fee276f 100644
--- a/Assets/00.StaryEvoTools/Editor/BuildAsset/BuildAssetDataSetting.cs
+++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/BuildAssetDataSetting.cs
@@ -13,7 +13,7 @@ namespace Stary.Evo.Editor
{
public void OnEnable()
{
- viewer = new ScriptableBuildPipelineViewer(packageName, selectedBuildPipelines.ToString(),
+ viewer = new MixedBuildPipelineViewer(packageName, selectedBuildPipelines.ToString(),
packageVersion);
oldVersionX = packageVersionX;
oldVersionY = packageVersionY;
diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/BuildAssetWindow.cs b/Assets/00.StaryEvoTools/Editor/BuildAsset/BuildAssetWindow.cs
index 83cb0db..757654a 100644
--- a/Assets/00.StaryEvoTools/Editor/BuildAsset/BuildAssetWindow.cs
+++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/BuildAssetWindow.cs
@@ -162,7 +162,7 @@ namespace Stary.Evo.Editor
///
private void SetBuildPackageNames()
{
- //PlayerPrefs.SetString("BuildPackageNames", selectedPackageNames);
+ //CustomPlayerPrefs.SetString("BuildPackageNames", selectedPackageNames);
// DataSetting.packageName = selectedPackageNames;
@@ -248,69 +248,94 @@ namespace Stary.Evo.Editor
}
- public static string BuildZip(BuildAssetDataSetting setting)
+ public static string BuildZip(BuildAssetDataSetting setting)
+{
+ EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(打包zip)", 0.0f);
+ // 新增:打包为zip的逻辑
+ string zipFileName =
+ $"{setting.packageName}_{setting.packageVersion}.zip";
+ //原yooAsset目录
+ var outputPackageDirectory =
+ $"{AssetBundleBuilderHelper.GetDefaultBuildOutputRoot()}/{EditorUserBuildSettings.activeBuildTarget}/{setting.packageName}";
+
+ //RawFile目录路径
+ var outputRawFileDirectory =
+ $"{AssetBundleBuilderHelper.GetDefaultBuildOutputRoot()}/{EditorUserBuildSettings.activeBuildTarget}/{setting.packageName}_RawFile";
+
+ //拷贝目录
+ string outFilePath = $"{outputPackageDirectory}/{setting.packageVersion}";
+ string outRawFilePath = $"{outputRawFileDirectory}/{setting.packageVersion}";
+
+ var copyPackageDirectory =
+ $"{Application.streamingAssetsPath}/{YooAssetSettingsData.GetDefaultYooFolderName()}/{setting.packageName}";
+
+ //拷贝BuildinCatalog文件
+ CreateBuildinCatalogFile("BuildinCatalog.json", copyPackageDirectory, outFilePath);
+ CreateBuildinCatalogFile("BuildinCatalog.bytes", copyPackageDirectory, outFilePath);
+
+ var copyRawFilePackageDirectory =
+ $"{Application.streamingAssetsPath}/{YooAssetSettingsData.GetDefaultYooFolderName()}/{setting.packageName}_RawFile";
+ CreateBuildinCatalogFile("BuildinCatalog.json", copyRawFilePackageDirectory, outRawFilePath);
+ CreateBuildinCatalogFile("BuildinCatalog.bytes", copyRawFilePackageDirectory, outRawFilePath);
+ //输出目录
+ string zipFilePath = Path.Combine(outputPackageDirectory, zipFileName);
+ try
+ {
+ using (FileStream zipStream = new FileStream(zipFilePath, FileMode.Create))
+ using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create))
{
- EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(打包zip)", 0.0f);
- // 新增:打包为zip的逻辑
- string zipFileName =
- $"{setting.packageName}_{setting.packageVersion}.zip";
- //原yooAsset目录
- var outputPackageDirectory =
- $"{AssetBundleBuilderHelper.GetDefaultBuildOutputRoot()}/{EditorUserBuildSettings.activeBuildTarget}/{setting.packageName}";
-
- //拷贝目录
- string outFilePath = $"{outputPackageDirectory}/{setting.packageVersion}";
-
- var copyPackageDirectory =
- $"{Application.streamingAssetsPath}/{YooAssetSettingsData.GetDefaultYooFolderName()}/{setting.packageName}";
- //拷贝BuildinCatalog文件
- CreateBuildinCatalogFile("BuildinCatalog.json", copyPackageDirectory, outFilePath);
- CreateBuildinCatalogFile("BuildinCatalog.bytes", copyPackageDirectory, outFilePath);
-
- //输出目录
- string zipFilePath = Path.Combine(outputPackageDirectory, zipFileName);
- try
+ // 打包主包文件
+ foreach (string filePath in Directory.GetFiles(outFilePath, "*.*", SearchOption.AllDirectories))
{
- using (FileStream zipStream = new FileStream(zipFilePath, FileMode.Create))
- using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create))
+ // 获取文件在压缩包中的相对路径
+ string entryName =$"{setting.packageName}/{ Path.GetRelativePath(outFilePath, filePath)}";
+ // 创建zip条目
+ ZipArchiveEntry entry = archive.CreateEntry(entryName,
+ System.IO.Compression.CompressionLevel.Optimal);
+
+ // 写入文件内容
+ using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
+ using (Stream entryStream = entry.Open())
{
- // 指定需要压缩的后缀(例如:只压缩.json和.dll文件)
- //string[] targetExtensions = { ".bundle" };
+ fileStream.CopyTo(entryStream);
+ }
+ }
+
+ // 打包RawFile文件
+ if (Directory.Exists(outRawFilePath))
+ {
+ foreach (string filePath in Directory.GetFiles(outRawFilePath, "*.*", SearchOption.AllDirectories))
+ {
+ // 获取文件在压缩包中的相对路径
+ string entryName =$"{setting.packageName}_RawFile/{ Path.GetRelativePath(outRawFilePath, filePath)}";
- // 遍历目录下所有文件
- // foreach (string filePath in Directory.GetFiles(outFilePath, "*.*", SearchOption.AllDirectories)
- // .Where(f => targetExtensions.Contains(Path.GetExtension(f),
- // StringComparer.OrdinalIgnoreCase)))
- foreach (string filePath in Directory.GetFiles(outFilePath, "*.*", SearchOption.AllDirectories))
+ // 创建zip条目
+ ZipArchiveEntry entry = archive.CreateEntry(entryName,
+ System.IO.Compression.CompressionLevel.Optimal);
+
+ // 写入文件内容
+ using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
+ using (Stream entryStream = entry.Open())
{
- // 获取文件在压缩包中的相对路径
- string entryName = Path.GetRelativePath(outFilePath, filePath);
-
- // 创建zip条目
- ZipArchiveEntry entry = archive.CreateEntry(entryName,
- System.IO.Compression.CompressionLevel.Optimal);
-
- // 写入文件内容
- using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
- using (Stream entryStream = entry.Open())
- {
- fileStream.CopyTo(entryStream);
- }
+ fileStream.CopyTo(entryStream);
}
}
-
- Debug.Log($"成功打包为zip:{zipFilePath}");
- EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(打包zip)", 0.25f);
- return zipFilePath;
- }
- catch (Exception ex)
- {
- Debug.LogError($"打包zip失败:{ex.Message}");
- EditorUtility.ClearProgressBar();
- return default;
}
}
+ Debug.Log($"成功打包为zip:{zipFilePath}");
+ EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(打包zip)", 0.25f);
+ return zipFilePath;
+ }
+ catch (Exception ex)
+ {
+ Debug.LogError($"打包zip失败:{ex.Message}");
+ EditorUtility.ClearProgressBar();
+ return default;
+ }
+}
+
+
private static void CreateBuildinCatalogFile(string fileName, string copyPackageDirectory, string outFilePath)
{
// 假设 BuildinCatalog 文件名为 BuildinCatalog.json
@@ -332,7 +357,7 @@ namespace Stary.Evo.Editor
{
- string ip = EditorPrefs.GetString("ip");
+ string ip = CustomEditorPrefs.GetString("ip");
var messageEntity = await WebRequestSystem.PostFile(ip + "/FileLoad/UpLoadFile", new[] { zipFilePath });
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(上传zip文件)", 0.5f);
if (messageEntity.code == 200)
@@ -403,7 +428,7 @@ namespace Stary.Evo.Editor
DomainName = selectedPackageNames,
Platform = EditorUserBuildSettings.activeBuildTarget.ToString(),
};
- var resResultMessage = await WebRequestSystem.Post(EditorPrefs.GetString("ip") + "/ResDomain/GetResDomainByDomain",
+ var resResultMessage = await WebRequestSystem.Post(CustomEditorPrefs.GetString("ip") + "/ResDomain/GetResDomainByDomain",
JsonConvert.SerializeObject(resDmainAddRequst));
//如果低于服务器版本,更新版本号
if (resResultMessage.code != 1011)
diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangeHotUpdateMode.cs b/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangeHotUpdateMode.cs
index a5b2bb9..aab0fa8 100644
--- a/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangeHotUpdateMode.cs
+++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangeHotUpdateMode.cs
@@ -30,7 +30,7 @@ namespace Stary.Evo.Editor
[MenuItem(EditorNotUpdateMode, true)]
private static bool ValidateModeMenu()
{
- string platform = EditorPrefs.GetString("ChangeHotUpdateSchema");
+ string platform = CustomEditorPrefs.GetString("ChangeHotUpdateSchema");
Menu.SetChecked(EditorNotUpdateMode, platform == HotUpdateMode.NotUpdate.ToString());
Menu.SetChecked(EditorHotUpdateMode, platform == HotUpdateMode.HotUpdate.ToString());
//Menu.SetChecked(WebPlayMode, platform == HotUpdateMode.WEB_PLAYMODE.ToString());
@@ -54,7 +54,7 @@ namespace Stary.Evo.Editor
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
_hotUpdate = mode;
- EditorPrefs.SetString("ChangeHotUpdateSchema", _hotUpdate.ToString());
+ CustomEditorPrefs.SetString("ChangeHotUpdateSchema", _hotUpdate.ToString());
ValidateModeMenu();
AssetDatabase.Refresh();
diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePlayerMode.cs b/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePlayerMode.cs
index d1d4440..a6ca857 100644
--- a/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePlayerMode.cs
+++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePlayerMode.cs
@@ -30,7 +30,7 @@ namespace Stary.Evo.Editor
[MenuItem(EditorSimulateMode, true,3)]
private static bool ValidateModeMenu()
{
- string platform = EditorPrefs.GetString("ChangePlayerSchema");
+ string platform = CustomEditorPrefs.GetString("ChangePlayerSchema");
Menu.SetChecked(EditorSimulateMode, platform == PLayerMode.EDITOR_SIMULATEMODE.ToString());
Menu.SetChecked(HostPlayMode, platform == PLayerMode.HOST_PLAYMODE.ToString());
//Menu.SetChecked(WebPlayMode, platform == PLayerMode.WEB_PLAYMODE.ToString());
@@ -54,7 +54,7 @@ namespace Stary.Evo.Editor
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
_pLayerMode = mode;
- EditorPrefs.SetString("ChangePlayerSchema", _pLayerMode.ToString());
+ CustomEditorPrefs.SetString("ChangePlayerSchema", _pLayerMode.ToString());
ValidateModeMenu();
AssetDatabase.Refresh();
// 添加解决方案文件重新生成逻辑
diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePointClondMode.cs b/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePointClondMode.cs
index 99d9a39..2ab0fea 100644
--- a/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePointClondMode.cs
+++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/ChangePlayerMode/ChangePointClondMode.cs
@@ -30,7 +30,7 @@ namespace Stary.Evo.Editor
[MenuItem(EditorNotMode, true)]
private static bool ValidateModeMenu()
{
- string platform = EditorPrefs.GetString("ChangePoindClondSchema");
+ string platform = CustomEditorPrefs.GetString("ChangePoindClondSchema");
Menu.SetChecked(EditorNotMode, platform == PointClondMode.NotPointClond.ToString());
Menu.SetChecked(EditorImmersalMode, platform == PointClondMode.Immersal.ToString());
//Menu.SetChecked(WebPlayMode, platform == HotUpdateMode.WEB_PLAYMODE.ToString());
@@ -54,7 +54,7 @@ namespace Stary.Evo.Editor
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
_pointClondMode = mode;
- EditorPrefs.SetString("ChangePoindClondSchema", _pointClondMode.ToString());
+ CustomEditorPrefs.SetString("ChangePoindClondSchema", _pointClondMode.ToString());
ValidateModeMenu();
AssetDatabase.Refresh();
diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/CreatDomainDirectory.cs b/Assets/00.StaryEvoTools/Editor/BuildAsset/CreatDomainDirectory.cs
index b7c7ce7..cb8a94f 100644
--- a/Assets/00.StaryEvoTools/Editor/BuildAsset/CreatDomainDirectory.cs
+++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/CreatDomainDirectory.cs
@@ -17,15 +17,15 @@ namespace Stary.Evo
Debug.Log(" 自动运行 ");
- if (!EditorPrefs.HasKey("StartUp"))
+ if (!CustomEditorPrefs.HasKey("StartUp"))
{
// 通过标记记录是否已经执行过该方法
OnEditorStartUp();
- EditorPrefs.SetInt("StartUp", 1);
+ CustomEditorPrefs.SetInt("StartUp", 1);
- if (EditorPrefs.GetInt("CreatDomainDirectory") == 0)
+ if (CustomEditorPrefs.GetInt("CreatDomainDirectory") == 0)
{
- EditorPrefs.SetInt("CreatDomainDirectory", 1);
+ CustomEditorPrefs.SetInt("CreatDomainDirectory", 1);
bool isOk = EditorUtility.DisplayDialog("提示", "发现目录存在缺失,是否检索并创建缺失目录", "是", "否");
if (isOk)
{
@@ -37,17 +37,17 @@ namespace Stary.Evo
}
}
- if (EditorPrefs.GetString("ChangeHotUpdateSchema") == "")
+ if (CustomEditorPrefs.GetString("ChangeHotUpdateSchema") == "")
{
ChangeHotUpdateSchema.SetHotUpdateMode(HotUpdateMode.NotUpdate);
}
else
{
ChangeHotUpdateSchema.SetHotUpdateMode(
- Enum.Parse(EditorPrefs.GetString("ChangeHotUpdateSchema")));
+ Enum.Parse(CustomEditorPrefs.GetString("ChangeHotUpdateSchema")));
}
- if (EditorPrefs.GetString("ChangePlayerSchema") == "")
+ if (CustomEditorPrefs.GetString("ChangePlayerSchema") == "")
{
ChangePlayerSchema.SetPlayerMode(PLayerMode.EDITOR_SIMULATEMODE);
}
diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/IBuildPipelineViewer.cs b/Assets/00.StaryEvoTools/Editor/BuildAsset/IBuildPipelineViewer.cs
index dd9f9db..f487e2d 100644
--- a/Assets/00.StaryEvoTools/Editor/BuildAsset/IBuildPipelineViewer.cs
+++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/IBuildPipelineViewer.cs
@@ -118,7 +118,7 @@ namespace Stary.Evo.Editor
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(packageName,
selectedBuildPipelines, copyBuildinFileOption);
- //PlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption);
+ //CustomPlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption);
}
private void SetCopyBuildinFileParams()
@@ -126,7 +126,7 @@ namespace Stary.Evo.Editor
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(packageName,
selectedBuildPipelines, copyBuildinFileParams);
- //PlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption);
+ //CustomPlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption);
}
public void SetBuildCacheToggle()
diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/PipelineViewer/MixedBuildPipelineViewer.cs b/Assets/00.StaryEvoTools/Editor/BuildAsset/PipelineViewer/MixedBuildPipelineViewer.cs
new file mode 100644
index 0000000..64b1f0c
--- /dev/null
+++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/PipelineViewer/MixedBuildPipelineViewer.cs
@@ -0,0 +1,149 @@
+using System;
+using System.IO;
+using UnityEditor;
+using UnityEngine;
+using YooAsset;
+using YooAsset.Editor;
+
+namespace Stary.Evo.Editor
+{
+ [Serializable]
+ public class MixedBuildPipelineViewer : AbstractBuildPipelineViewer
+ {
+ public MixedBuildPipelineViewer(string packageName, string selectedBuildPipelines, string packageVersion) :
+ base(packageName, selectedBuildPipelines, packageVersion)
+ {
+ }
+
+ public override void ExecuteBuild()
+ {
+ // 1. 首先使用RawFileBuildPipeline打包视频文件
+ Debug.Log("开始使用ScriptableBuildPipeline打包其余文件...");
+ var scriptableBuildResult = BuildOtherFiles();
+ if (!scriptableBuildResult.Success)
+ {
+ Debug.LogError("其余文件打包失败!");
+ return;
+ }
+
+ // 2. 然后使用ScriptableBuildPipeline打包其余文件
+ Debug.Log("开始使用RawFileBuildPipeline打包视频文件...");
+ var rawBuildResult = BuildRawFiles();
+ if (!rawBuildResult.Success)
+ {
+ Debug.LogError("视频文件打包失败!");
+ return;
+ }
+ Debug.Log("混合打包完成!");
+ base.ExecuteBuild();
+ }
+
+ private BuildResult BuildRawFiles()
+ {
+ var rawPackageName = $"{packageName}_RawFile";
+ var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(packageName, selectedBuildPipelines);
+ var buildinFileCopyOption =
+ AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(packageName, selectedBuildPipelines);
+ var buildinFileCopyParams =
+ AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(packageName, selectedBuildPipelines);
+ var clearBuildCache =
+ AssetBundleBuilderSetting.GetPackageClearBuildCache(packageName, selectedBuildPipelines);
+ var useAssetDependencyDB =
+ AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines);
+
+ RawFileBuildParameters buildParameters = new RawFileBuildParameters();
+ buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
+ buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
+ buildParameters.BuildPipeline = selectedBuildPipelines;
+ buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle;
+ buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
+ buildParameters.PackageName = rawPackageName;
+ buildParameters.PackageVersion = packageVersion;
+ buildParameters.VerifyBuildingResult = true;
+ buildParameters.FileNameStyle = fileNameStyle;
+ buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
+ buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
+ buildParameters.ClearBuildCacheFiles = clearBuildCache;
+ buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
+ buildParameters.EncryptionServices = CreateEncryptionInstance();
+ // SetVideoGroupActive(true);
+ RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
+ return pipeline.Run(buildParameters, true);
+
+ }
+
+
+ private BuildResult BuildOtherFiles()
+ {
+ var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(packageName, selectedBuildPipelines);
+ var buildinFileCopyOption =
+ AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(packageName, selectedBuildPipelines);
+ var buildinFileCopyParams =
+ AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(packageName, selectedBuildPipelines);
+ var compressOption =
+ AssetBundleBuilderSetting.GetPackageCompressOption(packageName, selectedBuildPipelines);
+ var useAssetDependencyDB =
+ AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines);
+
+ var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(packageName, selectedBuildPipelines);
+ var builtinShaderBundleName = GetBuiltinShaderBundleName();
+
+ ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
+ buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
+ buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
+ buildParameters.BuildPipeline = selectedBuildPipelines;
+ buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
+ buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
+ buildParameters.PackageName = packageName;
+ buildParameters.PackageVersion = packageVersion;
+ buildParameters.EnableSharePackRule = true;
+ buildParameters.VerifyBuildingResult = true;
+ buildParameters.FileNameStyle = fileNameStyle;
+ buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
+ buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
+ buildParameters.CompressOption = compressOption;
+ buildParameters.ClearBuildCacheFiles = clearBuildCache;
+ buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
+ buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
+ buildParameters.EncryptionServices = CreateEncryptionInstance();
+
+
+ ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
+ var result = pipeline.Run(buildParameters, true);
+
+ return result;
+ }
+
+ // private void SetVideoGroupActive(bool isActive)
+ // {
+ // var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting;
+ // if (setting == null)
+ // {
+ // Debug.LogError("UnityEvo: 打包设置获取失败,请检查AssetBundleCollectorSettingData设置!");
+ // return;
+ // }
+ //
+ // // 使用LINQ简化Package查找
+ // var collectorPackage = setting.Packages.Find(p => p.PackageName == packageName);
+ // if (collectorPackage == null)
+ // {
+ // Debug.LogError($"UnityEvo: 打包视频文件失败【{packageName}】...未找到对应的Package文件,请检查");
+ // return;
+ // }
+ //
+ // // 定义激活和禁用规则名称
+ // string enableRule = nameof(EnableGroup);
+ // string disableRule = nameof(DisableGroup);
+ //
+ // // 遍历所有组并设置激活规则
+ // foreach (var group in collectorPackage.Groups)
+ // {
+ // // 使用三元运算符简化逻辑,减少重复代码
+ // bool shouldEnableGroup = group.GroupName == "Video" ? isActive : !isActive;
+ // group.ActiveRuleName = shouldEnableGroup ? enableRule : disableRule;
+ // }
+ //
+ // YooAsset.Editor.AssetBundleCollectorSettingData.SaveFile();
+ // }
+ }
+}
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/PipelineViewer/MixedBuildPipelineViewer.cs.meta b/Assets/00.StaryEvoTools/Editor/BuildAsset/PipelineViewer/MixedBuildPipelineViewer.cs.meta
new file mode 100644
index 0000000..b50655e
--- /dev/null
+++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/PipelineViewer/MixedBuildPipelineViewer.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: c0023f14896b4a189fd6e7c7d4d6072b
+timeCreated: 1767687803
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Editor/BuildAsset/PipelineViewer/RawfileBuildpipelineViewer.cs b/Assets/00.StaryEvoTools/Editor/BuildAsset/PipelineViewer/RawfileBuildpipelineViewer.cs
index 3d55573..6d3d840 100644
--- a/Assets/00.StaryEvoTools/Editor/BuildAsset/PipelineViewer/RawfileBuildpipelineViewer.cs
+++ b/Assets/00.StaryEvoTools/Editor/BuildAsset/PipelineViewer/RawfileBuildpipelineViewer.cs
@@ -40,7 +40,6 @@ namespace Stary.Evo.Editor
buildParameters.ClearBuildCacheFiles = clearBuildCache;
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
buildParameters.EncryptionServices = CreateEncryptionInstance();
-
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
var buildResult = pipeline.Run(buildParameters, true);
if (buildResult.Success)
diff --git a/Assets/00.StaryEvoTools/Editor/Login/LoginAssetWindow.cs b/Assets/00.StaryEvoTools/Editor/Login/LoginAssetWindow.cs
index b612811..646c02d 100644
--- a/Assets/00.StaryEvoTools/Editor/Login/LoginAssetWindow.cs
+++ b/Assets/00.StaryEvoTools/Editor/Login/LoginAssetWindow.cs
@@ -40,7 +40,7 @@ namespace Stary.Evo
else
{
ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
- EditorPrefs.SetString("ip", ip);
+ CustomEditorPrefs.SetString("ip", ip);
userName = hotfixMainResDomain.hotfixMainResDomainEntity.username;
password = hotfixMainResDomain.hotfixMainResDomainEntity.password;
}
@@ -96,7 +96,7 @@ namespace Stary.Evo
{
buildAssetType = BuildAssetType.Login;
message = "未登录";
- EditorPrefs.DeleteKey("Authorization");
+ CustomEditorPrefs.DeleteKey("Authorization");
}
private void SetWebRequestInfo()
@@ -106,7 +106,7 @@ namespace Stary.Evo
hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig = ip;
hotfixMainResDomain.hotfixMainResDomainEntity.username = userName;
hotfixMainResDomain.hotfixMainResDomainEntity.password = password;
- EditorPrefs.SetString("ip", ip);
+ CustomEditorPrefs.SetString("ip", ip);
EditorUtility.SetDirty(hotfixMainResDomain);
AssetDatabase.SaveAssets();
}
diff --git a/Assets/00.StaryEvoTools/Editor/MarkAdressable/MarkAdressable.cs b/Assets/00.StaryEvoTools/Editor/MarkAdressable/MarkAdressable.cs
index ce32e1e..a884eeb 100644
--- a/Assets/00.StaryEvoTools/Editor/MarkAdressable/MarkAdressable.cs
+++ b/Assets/00.StaryEvoTools/Editor/MarkAdressable/MarkAdressable.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
#if HotUpdate
using HybridCLR.Editor;
@@ -17,14 +18,22 @@ namespace Stary.Evo.Editor
public class MarkAdressable
{
private static AssetBundleCollectorPackage package;
- private static string _packageName;
+ private static AssetBundleCollectorPackage packageRawFile;
+ private static Dictionary addressDic = new Dictionary();
+
+ private static Dictionary _collectorGroupDic =
+ new Dictionary();
+
+ private static string _packageName;
+ private static string[] rawFiles = new[] { "Video" };
+
public static string DomainRoot
{
get { return Application.dataPath + "/Domain"; }
}
-
+
public static void AddHotfixAddressableDll()
{
CopyDllHotUpdateAssembly(BuildAssetWindow.GetBuildPackageName(),
@@ -136,26 +145,9 @@ namespace Stary.Evo.Editor
public static void AddDomainMark()
{
- // //清空主包旧数据
- AssetBundleCollectorPackage assetBundleCollectorPackage = null;
- //copydll
-
AddHotfixAddressableDll();
//清空用户旧数据
- foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
- {
- if (package.PackageName == BuildAssetWindow.GetBuildPackageName())
- {
- assetBundleCollectorPackage = package;
- }
- }
-
- if (assetBundleCollectorPackage != null)
- {
- YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage);
- }
-
string configPath =
$"Assets/Domain/{BuildAssetWindow.GetBuildPackageName()}/AddressableRes/Config/DomainConfig.asset";
DomainConfig domainConfig =
@@ -173,6 +165,23 @@ namespace Stary.Evo.Editor
});
}
+ public static void AddRawFileMark()
+ {
+ AssetBundleCollectorPackage assetBundleCollectorPackage = null;
+ var packageRawFile = $"{BuildAssetWindow.GetBuildPackageName()}_RawFile";
+ foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
+ {
+ if (packageRawFile == BuildAssetWindow.GetBuildPackageName())
+ {
+ assetBundleCollectorPackage = package;
+ }
+ }
+
+ if (assetBundleCollectorPackage != null)
+ {
+ YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage);
+ }
+ }
private static void CreateRes(string domain, string resPath, string outputPath)
{
@@ -182,11 +191,6 @@ namespace Stary.Evo.Editor
#region 自动标记
- private static Dictionary addressDic = new Dictionary();
-
- private static Dictionary _collectorGroupDic =
- new Dictionary();
-
public static void Mark()
{
addressDic.Clear();
@@ -196,39 +200,26 @@ namespace Stary.Evo.Editor
string remotedRoot = $"{DomainRoot}/{_packageName}/AddressableRes";
DirectoryInfo[] dirs = new DirectoryInfo(remotedRoot).GetDirectories();
- var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting;
- setting.ShowPackageView = true;
- setting.UniqueBundleName = true;
- //创建Package文件
- package = YooAsset.Editor.AssetBundleCollectorSettingData.CreatePackage(_packageName);
-
- //检测Packages是否存在TestPackage
- package.PackageName = _packageName;
- package.EnableAddressable = true;
- package.IncludeAssetGUID = true;
- package.AutoCollectShaders = true;
- package.IgnoreRuleName = "NormalIgnoreRule";
-
+ package = CreatePackage(_packageName);
+ packageRawFile = CreatePackage($"{_packageName}_RawFile");
//检测Packages是否存在Group
foreach (var info in dirs)
{
string groupName = info.Name;
- if (info.Name != "Atlas")
+ if (groupName.Equals("Atlas"))
{
- AssetBundleCollectorGroup collectorGroup =
- YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupName);
- collectorGroup.AssetTags = groupName;
+ continue;
+ }
- if (!_collectorGroupDic.ContainsKey(groupName))
- {
- _collectorGroupDic.Add(groupName, collectorGroup);
- }
- else
- {
- Debug.LogError("分组 : " + groupName + "已存在,请检查资源目录,避免重复");
- }
+ if (rawFiles.Contains(groupName))
+ {
+ AddGroup(packageRawFile, groupName);
+ }
+ else
+ {
+ AddGroup(package, groupName);
}
AutoMarkRootAddress(info);
@@ -240,7 +231,7 @@ namespace Stary.Evo.Editor
///自动创建图集
Debug.Log("开始创建图集");
AutoCreateSpriteAtlas(remotedRoot);
- MarkStatus();
+ DeleteMarkGroup();
YooAsset.Editor.AssetBundleCollectorSettingData.SaveFile();
// CreateRes();
@@ -276,33 +267,35 @@ namespace Stary.Evo.Editor
string groupName = dir.Name;
string assetPath = FilesUtils.AbsoluteToRelativePath("Assets", file); //Asset到文件的路径
var guid = AssetDatabase.AssetPathToGUID(assetPath);
- var group = _collectorGroupDic[groupName];
- if (group != null)
- {
- AssetBundleCollector collector = new AssetBundleCollector()
- {
- CollectPath = assetPath,
- CollectorGUID = guid,
- CollectorType = ECollectorType.MainAssetCollector,
- AddressRuleName = nameof(AddressByFolderAndFileName),
- AssetTags = groupName,
- };
- //TODO 暂时不设置
- // 如果是video目录,设置
- // if (groupName == "Video")
- // {
- // collector.PackRuleName = nameof(PackVideoFile);
- // }
-
- YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
- Debug.Log("GetAssetAddress:" + GetAssetAddress(file));
- AddAddressInfo(file, GetAssetAddress(file));
- }
- else
- {
- Debug.LogError("分组 = " + groupName + "不存在");
- }
+ AddCollector(groupName, guid, assetPath, file);
+ // var group = _collectorGroupDic[groupName];
+ // if (group != null)
+ // {
+ // AssetBundleCollector collector = new AssetBundleCollector()
+ // {
+ // CollectPath = assetPath,
+ // CollectorGUID = guid,
+ // CollectorType = ECollectorType.MainAssetCollector,
+ // AddressRuleName = nameof(AddressByFolderAndFileName),
+ // AssetTags = groupName,
+ // };
+ //
+ // //TODO 暂时不设置
+ // // 如果是video目录,设置
+ // // if (groupName == "Video")
+ // // {
+ // // collector.PackRuleName = nameof(PackVideoFile);
+ // // }
+ //
+ // YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
+ // Debug.Log("GetAssetAddress:" + GetAssetAddress(file));
+ // AddAddressInfo(file, GetAssetAddress(file));
+ // }
+ // else
+ // {
+ // Debug.LogError("分组 = " + groupName + "不存在");
+ // }
}
}
}
@@ -380,27 +373,27 @@ namespace Stary.Evo.Editor
}
var guid = AssetDatabase.AssetPathToGUID(guidPath);
-
- var group = _collectorGroupDic[groupname];
- if (group != null)
- {
- AssetBundleCollector collector = new AssetBundleCollector()
- {
- CollectPath = guidPath,
- CollectorGUID = guid,
- CollectorType = ECollectorType.MainAssetCollector,
- AddressRuleName = nameof(AddressByFolderAndFileName),
- AssetTags = groupname,
- };
- YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
-
-
- AddAddressInfo(path, GetAssetAddress(path));
- }
- else
- {
- Debug.LogError("分组 = " + GetAssetAddress(path) + "不存在");
- }
+ AddCollector(groupname, guid, guidPath, path);
+ // var group = _collectorGroupDic[groupname];
+ // if (group != null)
+ // {
+ // AssetBundleCollector collector = new AssetBundleCollector()
+ // {
+ // CollectPath = guidPath,
+ // CollectorGUID = guid,
+ // CollectorType = ECollectorType.MainAssetCollector,
+ // AddressRuleName = nameof(AddressByFolderAndFileName),
+ // AssetTags = groupname,
+ // };
+ // YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
+ //
+ //
+ // AddAddressInfo(path, GetAssetAddress(path));
+ // }
+ // else
+ // {
+ // Debug.LogError("分组 = " + GetAssetAddress(path) + "不存在");
+ // }
AssetDatabase.Refresh();
}
@@ -418,6 +411,86 @@ namespace Stary.Evo.Editor
#endregion
+ private static AssetBundleCollectorPackage CreatePackage(string packageName)
+ {
+ var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting;
+ setting.ShowPackageView = true;
+ setting.UniqueBundleName = true;
+ AssetBundleCollectorPackage assetBundleCollectorPackage = null;
+ foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
+ {
+ if (package.PackageName == packageName)
+ {
+ assetBundleCollectorPackage = package;
+ break;
+ }
+ }
+
+ if (assetBundleCollectorPackage != null)
+ {
+ YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage);
+ }
+
+ //创建Package文件
+ assetBundleCollectorPackage = YooAsset.Editor.AssetBundleCollectorSettingData.CreatePackage(packageName);
+
+ //检测Packages是否存在TestPackage
+ assetBundleCollectorPackage.PackageName = packageName;
+ assetBundleCollectorPackage.EnableAddressable = true;
+ assetBundleCollectorPackage.IncludeAssetGUID = true;
+ assetBundleCollectorPackage.AutoCollectShaders = true;
+ assetBundleCollectorPackage.IgnoreRuleName = "NormalIgnoreRule";
+
+ return assetBundleCollectorPackage;
+ }
+
+ private static void AddGroup(AssetBundleCollectorPackage package, string groupName)
+ {
+ AssetBundleCollectorGroup collectorGroup =
+ YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupName);
+ collectorGroup.AssetTags = groupName;
+
+ if (!_collectorGroupDic.ContainsKey(groupName))
+ {
+ _collectorGroupDic.Add(groupName, collectorGroup);
+ }
+ else
+ {
+ Debug.LogError("分组 : " + groupName + "已存在,请检查资源目录,避免重复");
+ }
+ }
+
+ private static void AddCollector(string groupName, string guid, string assetPath, string file)
+ {
+ var group = _collectorGroupDic[groupName];
+ if (group != null)
+ {
+ AssetBundleCollector collector = new AssetBundleCollector()
+ {
+ CollectPath = assetPath,
+ CollectorGUID = guid,
+ CollectorType = ECollectorType.MainAssetCollector,
+ AddressRuleName = nameof(AddressByFolderAndFileName),
+ AssetTags = groupName,
+ };
+
+ ////TODO 暂时不设置
+ //如果是video目录,设置
+ if (rawFiles.Contains(groupName))
+ {
+ collector.PackRuleName = nameof(PackVideoFile);
+ }
+
+ YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
+ Debug.Log("GetAssetAddress:" + GetAssetAddress(file));
+ AddAddressInfo(file, GetAssetAddress(file));
+ }
+ else
+ {
+ Debug.LogError("分组 = " + groupName + "不存在");
+ }
+ }
+
private static void AddAddressInfo(string assetPath, string address)
{
if (addressDic.ContainsKey(assetPath))
@@ -447,22 +520,22 @@ namespace Stary.Evo.Editor
#endregion
///
- /// 标记为资源分组
+ /// 删除资源为空的分组
///
- private static void MarkStatus()
+ private static void DeleteMarkGroup()
{
List deleteList = new List();
for (int i = 0; i < package.Groups.Count; i++)
{
var group = package.Groups[i];
- if (group.GroupName != "Default Local Group" && group.GroupName != "Built In Data")
+ // if (group.GroupName != "Default Local Group" && group.GroupName != "Built In Data")
+ // {
+ if (group.Collectors.Count <= 0)
{
- if (group.Collectors.Count <= 0)
- {
- ///删除没有资源的分组
- deleteList.Add(group);
- }
+ ///删除没有资源的分组
+ deleteList.Add(group);
}
+ //}
}
for (int i = 0; i < deleteList.Count; i++)
@@ -471,6 +544,8 @@ namespace Stary.Evo.Editor
}
}
+ #region 收集shader变体
+
public static void CollectSvc(string root, string packageName, Action complete)
{
string remotedRoot = $"{root}/{packageName}/ShaderVariants";
@@ -505,7 +580,6 @@ namespace Stary.Evo.Editor
ShaderVariantCollector.Run(localSavePath, packageName, 1000, CompletedCallback);
}
- // 新增方法:创建独立的ShaderVariants分组(防止多个package冲突)
private static void CreateShaderVariantsGroup(string packageName, string localSavePath)
{
string groupname = $"ShaderVariants_{packageName}";
@@ -537,5 +611,7 @@ namespace Stary.Evo.Editor
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(collectorGroup, collector);
YooAsset.Editor.AssetBundleCollectorSettingData.SaveFile();
}
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Editor/Type/BuildType.cs b/Assets/00.StaryEvoTools/Editor/Type/BuildType.cs
index c23bcdf..8fcc909 100644
--- a/Assets/00.StaryEvoTools/Editor/Type/BuildType.cs
+++ b/Assets/00.StaryEvoTools/Editor/Type/BuildType.cs
@@ -24,5 +24,7 @@ namespace Stary.Evo
// /// 原生文件构建管线 (RFBP)
// ///
// RawFileBuildPipeline,
+
+ MixedBuildPipeline
}
}
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtResEditorSimulateState.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtResEditorSimulateState.cs
index 6a4b7d5..753a597 100644
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtResEditorSimulateState.cs
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtResEditorSimulateState.cs
@@ -1,186 +1,186 @@
-using Cysharp.Threading.Tasks;
-using UnityEngine;
-using UnityEngine.Assertions;
-using YooAsset;
-
-namespace Stary.Evo
-{
- public class ArtResEditorSimulateState : AbstractFSMIStateAsync
- {
- public ArtResEditorSimulateState(IFsmSystemAsync system) : base(system)
- {
- }
-
- public override async UniTask OnEnterAsync()
- {
- Debug.Log("UnityEvo:开始资源更新...");
-
-
- // //初始化读取资源配置表
- var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
- // 请求资源版本
- var requetVersionOp = package.RequestPackageVersionAsync();
- await requetVersionOp;
- string packageVersion = "";
- if (requetVersionOp.Status == EOperationStatus.Succeed)
- {
- //更新成功
- packageVersion = requetVersionOp.PackageVersion;
- PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", packageVersion);
- Debug.Log($"UnityEvo:获取资源版本 Version : 【{packageVersion}】");
- Debug.Log($"UnityEvo:开始加载服务器资源...");
- }
- else
- {
- Debug.LogError($"UnityEvo:获取资源版本失败: 【{requetVersionOp.Error}】");
- FsmSystem.SetCurState(nameof(ResUpdateLocalState));
- return;
- }
-
- // 更新资源清单
- var updateManifestOp = package.UpdatePackageManifestAsync(packageVersion);
- await updateManifestOp;
- if (updateManifestOp.Status == EOperationStatus.Succeed)
- {
- //更新成功
- Debug.Log($"UnityEvo:更新资源清单 updateManifest : 【成功】");
- }
- else
- {
- //更新失败
- Debug.LogError($"UnityEvo:更新资源清单失败: 【{updateManifestOp.Error}】");
- }
-
- //4.下载补丁包
- await Download();
-
-
- //加载热更配置文件
- var loadArtSceneDataOp = package.LoadAssetAsync("Config_ArtSceneData");
- await loadArtSceneDataOp;
- ArtSceneData artSceneData = null;
- if (loadArtSceneDataOp.Status == EOperationStatus.Succeed)
- {
- //更新成功
- Debug.Log($"UnityEvo:加载热更配置文件 ArtSceneData : 【成功】");
- artSceneData = loadArtSceneDataOp.AssetObject as ArtSceneData;
- }
- else
- {
- Debug.LogError($"UnityEvo:加载热更配置文件 ArtSceneData : 【失败】");
- }
-
-
- if (artSceneData == null)
- {
- Debug.LogError($"UnityEvo:【{package.PackageName}】加载ArtSceneData为空,无法继续执行后续流程,请检查!!!");
- }
- }
-
- public override UniTask OnEnterAsync(T param)
- {
- return UniTask.CompletedTask;
- }
-
- public override UniTask OnEnterAsync(T1 param1, T2 param2)
- {
- return UniTask.CompletedTask;
- }
-
- public override void OnUpdate()
- {
- base.OnUpdate();
- }
-
-
- public override async UniTask OnExitAsync()
- {
- await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(AppConfig.PackageDomainName);
- AppConfig.PackageDomainName = "";
- }
-
- #region 下载热更资源
-
- public async UniTask Download()
- {
- int downloadingMaxNum = 10;
- int failedTryAgain = 3;
- var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
- var downloader = package.CreateResourceDownloader(downloadingMaxNum, failedTryAgain);
-
- //没有需要下载的资源
- if (downloader.TotalDownloadCount == 0)
- {
- Debug.Log("UnityEvo:没有需要下载的资源,跳过更新");
- return;
- }
-
- //需要下载的文件总数和总大小
- int totalDownloadCount = downloader.TotalDownloadCount;
- long totalDownloadBytes = downloader.TotalDownloadBytes;
- Debug.Log($"UnityEvo:需要下载的资源的个数【{totalDownloadCount}】,需要下载的资源的总大小{totalDownloadBytes / 1024} MB");
- //===================================适应新版本YooAsset插件的修改===================================
- //注册回调方法
- downloader.DownloadErrorCallback = OnDownloadErrorFunction;
- downloader.DownloadUpdateCallback = OnDownloadProgressUpdateFunction;
- downloader.DownloadFinishCallback = OnDownloadOverFunction;
- downloader.DownloadFileBeginCallback = OnStartDownloadFileFunction;
- //===================================适应新版本YooAsset插件的修改===================================
-
- //开启下载
- downloader.BeginDownload();
- await downloader;
-
- //检测下载结果
- if (downloader.Status == EOperationStatus.Succeed)
- {
- //下载成功
- Debug.Log("UnityEvo:资源更新完成");
- }
- else
- {
- //下载失败
- Debug.Log("UnityEvo:资源更新失败");
- }
- }
-
- //===================================适应新版本YooAsset插件的修改===================================
- ///
- /// 开始下载
- ///
- private void OnStartDownloadFileFunction(DownloadFileData downloadFileData)
- {
- Debug.Log(
- $"UnityEvo:开始下载:文件名:{downloadFileData.FileName},文件大小:{downloadFileData.FileSize / 1024f / 1024f} MB");
- }
-
- ///
- /// 下载完成
- ///
- private void OnDownloadOverFunction(DownloaderFinishData downloaderFinishData)
- {
- Debug.Log("UnityEvo:下载" + (downloaderFinishData.Succeed ? "成功" : "失败"));
- }
-
- ///
- /// 更新中
- ///
- private void OnDownloadProgressUpdateFunction(DownloadUpdateData downloadUpdateData)
- {
- Debug.Log(
- $"UnityEvo:文件总数:{downloadUpdateData.TotalDownloadCount},已下载文件数:{downloadUpdateData.CurrentDownloadCount},下载总大小:{downloadUpdateData.TotalDownloadBytes / 1024f / 1024f} MB,已下载大小{downloadUpdateData.CurrentDownloadBytes / 1024f / 1024f} MB");
- }
-
- ///
- /// 下载出错
- ///
- ///
- private void OnDownloadErrorFunction(DownloadErrorData errorData)
- {
- Debug.Log($"UnityEvo:下载出错:包名:{errorData.PackageName} 文件名:{errorData.FileName},错误信息:{errorData.ErrorInfo}");
- }
- //===================================适应新版本YooAsset插件的修改===================================
-
- #endregion
- }
-}
\ No newline at end of file
+// using Cysharp.Threading.Tasks;
+// using UnityEngine;
+// using UnityEngine.Assertions;
+// using YooAsset;
+//
+// namespace Stary.Evo
+// {
+// public class ArtResEditorSimulateState : AbstractFSMIStateAsync
+// {
+// public ArtResEditorSimulateState(IFsmSystemAsync system) : base(system)
+// {
+// }
+//
+// public override async UniTask OnEnterAsync()
+// {
+// Debug.Log("UnityEvo:开始资源更新...");
+//
+//
+// // //初始化读取资源配置表
+// var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
+// // 请求资源版本
+// var requetVersionOp = package.RequestPackageVersionAsync();
+// await requetVersionOp;
+// string packageVersion = "";
+// if (requetVersionOp.Status == EOperationStatus.Succeed)
+// {
+// //更新成功
+// packageVersion = requetVersionOp.PackageVersion;
+// PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", packageVersion);
+// Debug.Log($"UnityEvo:获取资源版本 Version : 【{packageVersion}】");
+// Debug.Log($"UnityEvo:开始加载服务器资源...");
+// }
+// else
+// {
+// Debug.LogError($"UnityEvo:获取资源版本失败: 【{requetVersionOp.Error}】");
+// FsmSystem.SetCurState(nameof(ResUpdateLocalState));
+// return;
+// }
+//
+// // 更新资源清单
+// var updateManifestOp = package.UpdatePackageManifestAsync(packageVersion);
+// await updateManifestOp;
+// if (updateManifestOp.Status == EOperationStatus.Succeed)
+// {
+// //更新成功
+// Debug.Log($"UnityEvo:更新资源清单 updateManifest : 【成功】");
+// }
+// else
+// {
+// //更新失败
+// Debug.LogError($"UnityEvo:更新资源清单失败: 【{updateManifestOp.Error}】");
+// }
+//
+// //4.下载补丁包
+// await Download();
+//
+//
+// //加载热更配置文件
+// var loadArtSceneDataOp = package.LoadAssetAsync("Config_ArtSceneData");
+// await loadArtSceneDataOp;
+// ArtSceneData artSceneData = null;
+// if (loadArtSceneDataOp.Status == EOperationStatus.Succeed)
+// {
+// //更新成功
+// Debug.Log($"UnityEvo:加载热更配置文件 ArtSceneData : 【成功】");
+// artSceneData = loadArtSceneDataOp.AssetObject as ArtSceneData;
+// }
+// else
+// {
+// Debug.LogError($"UnityEvo:加载热更配置文件 ArtSceneData : 【失败】");
+// }
+//
+//
+// if (artSceneData == null)
+// {
+// Debug.LogError($"UnityEvo:【{package.PackageName}】加载ArtSceneData为空,无法继续执行后续流程,请检查!!!");
+// }
+// }
+//
+// public override UniTask OnEnterAsync(T param)
+// {
+// return UniTask.CompletedTask;
+// }
+//
+// public override UniTask OnEnterAsync(T1 param1, T2 param2)
+// {
+// return UniTask.CompletedTask;
+// }
+//
+// public override void OnUpdate()
+// {
+// base.OnUpdate();
+// }
+//
+//
+// public override async UniTask OnExitAsync()
+// {
+// await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(AppConfig.PackageDomainName);
+// AppConfig.PackageDomainName = "";
+// }
+//
+// #region 下载热更资源
+//
+// public async UniTask Download()
+// {
+// int downloadingMaxNum = 10;
+// int failedTryAgain = 3;
+// var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
+// var downloader = package.CreateResourceDownloader(downloadingMaxNum, failedTryAgain);
+//
+// //没有需要下载的资源
+// if (downloader.TotalDownloadCount == 0)
+// {
+// Debug.Log("UnityEvo:没有需要下载的资源,跳过更新");
+// return;
+// }
+//
+// //需要下载的文件总数和总大小
+// int totalDownloadCount = downloader.TotalDownloadCount;
+// long totalDownloadBytes = downloader.TotalDownloadBytes;
+// Debug.Log($"UnityEvo:需要下载的资源的个数【{totalDownloadCount}】,需要下载的资源的总大小{totalDownloadBytes / 1024} MB");
+// //===================================适应新版本YooAsset插件的修改===================================
+// //注册回调方法
+// downloader.DownloadErrorCallback = OnDownloadErrorFunction;
+// downloader.DownloadUpdateCallback = OnDownloadProgressUpdateFunction;
+// downloader.DownloadFinishCallback = OnDownloadOverFunction;
+// downloader.DownloadFileBeginCallback = OnStartDownloadFileFunction;
+// //===================================适应新版本YooAsset插件的修改===================================
+//
+// //开启下载
+// downloader.BeginDownload();
+// await downloader;
+//
+// //检测下载结果
+// if (downloader.Status == EOperationStatus.Succeed)
+// {
+// //下载成功
+// Debug.Log("UnityEvo:资源更新完成");
+// }
+// else
+// {
+// //下载失败
+// Debug.Log("UnityEvo:资源更新失败");
+// }
+// }
+//
+// //===================================适应新版本YooAsset插件的修改===================================
+// ///
+// /// 开始下载
+// ///
+// private void OnStartDownloadFileFunction(DownloadFileData downloadFileData)
+// {
+// Debug.Log(
+// $"UnityEvo:开始下载:文件名:{downloadFileData.FileName},文件大小:{downloadFileData.FileSize / 1024f / 1024f} MB");
+// }
+//
+// ///
+// /// 下载完成
+// ///
+// private void OnDownloadOverFunction(DownloaderFinishData downloaderFinishData)
+// {
+// Debug.Log("UnityEvo:下载" + (downloaderFinishData.Succeed ? "成功" : "失败"));
+// }
+//
+// ///
+// /// 更新中
+// ///
+// private void OnDownloadProgressUpdateFunction(DownloadUpdateData downloadUpdateData)
+// {
+// Debug.Log(
+// $"UnityEvo:文件总数:{downloadUpdateData.TotalDownloadCount},已下载文件数:{downloadUpdateData.CurrentDownloadCount},下载总大小:{downloadUpdateData.TotalDownloadBytes / 1024f / 1024f} MB,已下载大小{downloadUpdateData.CurrentDownloadBytes / 1024f / 1024f} MB");
+// }
+//
+// ///
+// /// 下载出错
+// ///
+// ///
+// private void OnDownloadErrorFunction(DownloadErrorData errorData)
+// {
+// Debug.Log($"UnityEvo:下载出错:包名:{errorData.PackageName} 文件名:{errorData.FileName},错误信息:{errorData.ErrorInfo}");
+// }
+// //===================================适应新版本YooAsset插件的修改===================================
+//
+// #endregion
+// }
+// }
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtResUpdateLocalState.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtResUpdateLocalState.cs
index 62fc195..a39a095 100644
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtResUpdateLocalState.cs
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtResUpdateLocalState.cs
@@ -1,147 +1,147 @@
-using System;
-using Cysharp.Threading.Tasks;
-using UnityEngine;
-using UnityEngine.Assertions;
-using YooAsset;
-
-namespace Stary.Evo
-{
- public class ArtResUpdateLocalState : AbstractFSMIStateAsync
- {
- public ArtResUpdateLocalState(IFsmSystemAsync system) : base(system)
- {
- }
-
-
- public override async UniTask OnEnterAsync()
- {
- //初始化读取资源配置表
- var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
-
-
- //更新失败
-
- Debug.Log($"UnityEvo:切换为加载本地缓存资源...");
- string packageVersion = "";
- // if (package.PackageName.Equals("Main"))
- // {
- // var operation = package.RequestPackageVersionAsync();
- // await operation;
- // if (operation.Status == EOperationStatus.Succeed)
- // {
- // //更新成功
- // packageVersion = operation.PackageVersion;
- // Debug.Log($"Unity:【Main】Request package Version : {packageVersion}");
- // }
- // else
- // {
- // //更新失败
- // Debug.LogError("Unity:【Main】" + operation.Error);
- // }
- // }
- //else
- {
- // 获取上次成功记录的版本
- packageVersion = PlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION", string.Empty);
- if (string.IsNullOrEmpty(packageVersion))
- {
- Debug.Log($"UnityEvo:没有找到本地版本记录,需要更新资源!");
- return;
- }
- }
-
-
- Debug.Log($"UnityEvo:获取资源版本 Version : 【{packageVersion}】");
- Debug.Log($"UnityEvo:开始加载本地资源...");
- // Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
-
-
- // 加载本地缓存的资源清单文件
- var updateManifestOp = package.UpdatePackageManifestAsync(packageVersion);
- await updateManifestOp;
- if (updateManifestOp.Status == EOperationStatus.Succeed)
- {
- //更新成功
- Debug.Log($"UnityEvo:更新本地资源清单 updateManifest : 【成功】");
- }
- else
- {
- //更新失败
- Debug.LogError($"UnityEvo:加载本地资源清单文件失败,需要更新资源!: 【{updateManifestOp.Error}】");
- return;
- }
-
- Assert.AreEqual(EOperationStatus.Succeed, updateManifestOp.Status);
-
-
- //4.检测补丁包
- await Download();
-
-
- //加载热更配置文件
- var loadArtSceneDataOp = package.LoadAssetAsync("Config_ArtSceneData");
- await loadArtSceneDataOp;
- ArtSceneData artSceneData = null;
- if (loadArtSceneDataOp.Status == EOperationStatus.Succeed)
- {
- //更新成功
- Debug.Log($"UnityEvo:加载热更配置文件 ArtSceneData : 【成功】");
- artSceneData = loadArtSceneDataOp.AssetObject as ArtSceneData;
- }
- else
- {
- Debug.LogError($"UnityEvo:加载热更配置文件 ArtSceneData : 【失败】");
- }
-
-
- if (artSceneData == null)
- {
- Debug.LogError($"UnityEvo:【{package.PackageName}】加载ArtSceneData为空,无法继续执行后续流程,请检查!!!");
- }
-
- }
-
- public override UniTask OnEnterAsync(T param)
- {
- return UniTask.CompletedTask;
- }
-
- public override UniTask OnEnterAsync(T1 param1, T2 param2)
- {
- return UniTask.CompletedTask;
- }
-
- public override void OnUpdate()
- {
- base.OnUpdate();
- }
-
-
- public override async UniTask OnExitAsync()
- {
- await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(AppConfig.PackageDomainName);
- AppConfig.PackageDomainName = "";
- }
-
- #region 下载热更资源
-
- public async UniTask Download()
- {
- int downloadingMaxNum = 1;
- int failedTryAgain = 1;
- var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
- var downloader = package.CreateResourceDownloader(downloadingMaxNum, failedTryAgain);
-
- // 在正常开始游戏之前,还需要验证本地清单内容的完整性。
- if (downloader.TotalDownloadCount > 0)
- {
- Debug.Log("UnityEvo:资源内容本地并不完整,需要更新资源!");
- return;
- }
- }
-
- #endregion
-
-
- }
-}
\ No newline at end of file
+// using System;
+// using Cysharp.Threading.Tasks;
+// using UnityEngine;
+// using UnityEngine.Assertions;
+// using YooAsset;
+//
+// namespace Stary.Evo
+// {
+// public class ArtResUpdateLocalState : AbstractFSMIStateAsync
+// {
+// public ArtResUpdateLocalState(IFsmSystemAsync system) : base(system)
+// {
+// }
+//
+//
+// public override async UniTask OnEnterAsync()
+// {
+// //初始化读取资源配置表
+// var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
+//
+//
+// //更新失败
+//
+// Debug.Log($"UnityEvo:切换为加载本地缓存资源...");
+// string packageVersion = "";
+// // if (package.PackageName.Equals("Main"))
+// // {
+// // var operation = package.RequestPackageVersionAsync();
+// // await operation;
+// // if (operation.Status == EOperationStatus.Succeed)
+// // {
+// // //更新成功
+// // packageVersion = operation.PackageVersion;
+// // Debug.Log($"Unity:【Main】Request package Version : {packageVersion}");
+// // }
+// // else
+// // {
+// // //更新失败
+// // Debug.LogError("Unity:【Main】" + operation.Error);
+// // }
+// // }
+// //else
+// {
+// // 获取上次成功记录的版本
+// packageVersion = PlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION", string.Empty);
+// if (string.IsNullOrEmpty(packageVersion))
+// {
+// Debug.Log($"UnityEvo:没有找到本地版本记录,需要更新资源!");
+// return;
+// }
+// }
+//
+//
+// Debug.Log($"UnityEvo:获取资源版本 Version : 【{packageVersion}】");
+// Debug.Log($"UnityEvo:开始加载本地资源...");
+// // Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
+//
+//
+// // 加载本地缓存的资源清单文件
+// var updateManifestOp = package.UpdatePackageManifestAsync(packageVersion);
+// await updateManifestOp;
+// if (updateManifestOp.Status == EOperationStatus.Succeed)
+// {
+// //更新成功
+// Debug.Log($"UnityEvo:更新本地资源清单 updateManifest : 【成功】");
+// }
+// else
+// {
+// //更新失败
+// Debug.LogError($"UnityEvo:加载本地资源清单文件失败,需要更新资源!: 【{updateManifestOp.Error}】");
+// return;
+// }
+//
+// Assert.AreEqual(EOperationStatus.Succeed, updateManifestOp.Status);
+//
+//
+// //4.检测补丁包
+// await Download();
+//
+//
+// //加载热更配置文件
+// var loadArtSceneDataOp = package.LoadAssetAsync("Config_ArtSceneData");
+// await loadArtSceneDataOp;
+// ArtSceneData artSceneData = null;
+// if (loadArtSceneDataOp.Status == EOperationStatus.Succeed)
+// {
+// //更新成功
+// Debug.Log($"UnityEvo:加载热更配置文件 ArtSceneData : 【成功】");
+// artSceneData = loadArtSceneDataOp.AssetObject as ArtSceneData;
+// }
+// else
+// {
+// Debug.LogError($"UnityEvo:加载热更配置文件 ArtSceneData : 【失败】");
+// }
+//
+//
+// if (artSceneData == null)
+// {
+// Debug.LogError($"UnityEvo:【{package.PackageName}】加载ArtSceneData为空,无法继续执行后续流程,请检查!!!");
+// }
+//
+// }
+//
+// public override UniTask OnEnterAsync(T param)
+// {
+// return UniTask.CompletedTask;
+// }
+//
+// public override UniTask OnEnterAsync(T1 param1, T2 param2)
+// {
+// return UniTask.CompletedTask;
+// }
+//
+// public override void OnUpdate()
+// {
+// base.OnUpdate();
+// }
+//
+//
+// public override async UniTask OnExitAsync()
+// {
+// await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(AppConfig.PackageDomainName);
+// AppConfig.PackageDomainName = "";
+// }
+//
+// #region 下载热更资源
+//
+// public async UniTask Download()
+// {
+// int downloadingMaxNum = 1;
+// int failedTryAgain = 1;
+// var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
+// var downloader = package.CreateResourceDownloader(downloadingMaxNum, failedTryAgain);
+//
+// // 在正常开始游戏之前,还需要验证本地清单内容的完整性。
+// if (downloader.TotalDownloadCount > 0)
+// {
+// Debug.Log("UnityEvo:资源内容本地并不完整,需要更新资源!");
+// return;
+// }
+// }
+//
+// #endregion
+//
+//
+// }
+// }
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtesStartState.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtesStartState.cs
index a889446..f12f0e7 100644
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtesStartState.cs
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/ArtLoad/ArtesStartState.cs
@@ -1,234 +1,234 @@
-using System;
-using System.IO;
-using Cysharp.Threading.Tasks;
-using Main;
-using Newtonsoft.Json;
-using UnityEditor;
-using UnityEngine;
-using UnityEngine.Assertions;
-using YooAsset;
-using Object = UnityEngine.Object;
-
-namespace Stary.Evo
-{
- public class ArtResStartState : AbstractFSMIStateAsync
- {
- public ArtResStartState(IFsmSystemAsync system) : base(system)
- {
- }
-
-
- public override async UniTask OnEnterAsync()
- {
- Debug.Log("UnityEvo:启动开始资源初始化...");
-
-
- //初始化读取资源配置表
- HotfixMainResDomain hotfixMainResDomain = Resources.Load("HotfixMainResDomain");
- if (hotfixMainResDomain != null)
- {
- AppConfig.IpConfig = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
- AppConfig.UserName = hotfixMainResDomain.hotfixMainResDomainEntity.username;
- AppConfig.PassWord = hotfixMainResDomain.hotfixMainResDomainEntity.password;
- AppConfig.ProductName =Application.identifier;
- AppConfig.MainDomainVersion = hotfixMainResDomain.hotfixMainResDomainEntity.mainDomainVersion;
- }
-
- Debug.Log($"UnityEvo:读取资源配置表成功...{AppConfig.IpConfig}{AppConfig.UserName}{AppConfig.PassWord}");
- // 初始化资源系统
- YooAssets.Initialize();
-
-
- //自定义网络请求器
- // 设置自定义请求委托
- //YooAssets.SetDownloadSystemUnityWebRequest(NasWebRequester);
-
-
- //初始化资源加载模块
- // 增加包存在性检查
- var package = YooAssets.TryGetPackage(AppConfig.PackageDomainName);
- if (package == null)
- {
- Debug.LogWarning($"UnityEvo:资源包 {AppConfig.PackageDomainName} 不存在,正在尝试创建...");
- package = YooAssets.CreatePackage(AppConfig.PackageDomainName);
- }
-
- YooAssets.SetDefaultPackage(package);
-
- // 初始化资源包
-#if EDITOR_SIMULATEMODE
- await EDITOR_SIMULATEMODE(package);
- //await FsmSystem.SetCurState(nameof(ResUpdateServerState));
- await FsmSystem.SetCurState(nameof(ArtResEditorSimulateState));
-#elif HOST_PLAYMODE
-
- //登录
- string url = AppConfig.IpConfig + "/Authentication/login";
- bool isLogin = await WebRequestSystem.Login(url, AppConfig.UserName, AppConfig.PassWord);
- if (isLogin)
- await HOST_PLAYMODE(package);
- else
- await Chche_PLAYMODE(package);
-
-
- await FsmSystem.SetCurState(nameof(ArtResUpdateLocalState));
-#endif
- }
-
- public override UniTask OnEnterAsync(T param)
- {
- return UniTask.CompletedTask;
- }
-
- public override UniTask OnEnterAsync(T1 param1, T2 param2)
- {
- return UniTask.CompletedTask;
- }
-
- public override void OnUpdate()
- {
- base.OnUpdate();
- }
-
-
- public override UniTask OnExitAsync()
- {
- return UniTask.CompletedTask;
- }
-
- private async UniTask EDITOR_SIMULATEMODE(ResourcePackage package)
- {
-
- var initParams=YooAssetFileSystem.EditorSimulateInitializeParameter(package.PackageName);
- var initialization = package.InitializeAsync(initParams);
- await initialization;
- if (initialization.Status == EOperationStatus.Succeed)
- {
- Assert.AreEqual(EOperationStatus.Succeed, initialization.Status);
- Debug.Log("UnityEvo:资源包初始化成功!");
- }
- else
- {
- Debug.LogError($"UnityEvo:资源包初始化失败:{initialization.Error}");
- }
-
- //运行模拟文件系统
-
- }
- private async UniTask Chche_PLAYMODE(ResourcePackage package)
- {
- Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
- var initParams=YooAssetFileSystem.HostInitializeParameter();
- var initOperation = package.InitializeAsync(initParams);
- await initOperation;
-
- var operation = package.RequestPackageVersionAsync();
- await operation;
- if (operation.Status == EOperationStatus.Succeed)
- {
- PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", operation.PackageVersion);
- Debug.Log("UnityEvo:从本地缓存中加载资源包,初始化获取版本号成功!");
- }else
- {
- Debug.LogError($"UnityEvo:从本地缓存中加载资源包,初始化获取版本号失败!");
- }
-
- if (initOperation.Status == EOperationStatus.Succeed)
- Debug.Log("UnityEvo:从本地缓存中资源包,初始化成功!");
- else
- Debug.LogError($"UnityEvo:从本地缓存中资源包,初始化失败:{initOperation.Error}");
- }
-
- public async UniTask HOST_PLAYMODE(ResourcePackage package)
- {
- // 新增平台判断代码
-#if UNITY_EDITOR
- BuildTarget buildTarget = UnityEditor.EditorUserBuildSettings.activeBuildTarget;
- AppConfig.Platform = buildTarget.ToString();
-#else
- AppConfig.Platform = Application.platform.ToString();
-#endif
- Debug.Log($"目标平台标识: {AppConfig.Platform}");
-
- // 请求资源版本
- string url = $"{AppConfig.IpConfig}/ResDomain/GetResDomainByDomain";
- var resDmainRequst = new ResDmainRequst()
- {
- ProductName = AppConfig.ProductName,
- DomainName = AppConfig.PackageDomainName,
- Platform = AppConfig.Platform,
- };
- //获取服务器版本
- var resDmainMessageEntity = await WebRequestSystem.Post(url, JsonConvert.SerializeObject(resDmainRequst));
- if (resDmainMessageEntity.code == 200)
- {
- ResDmainResponse resDmainResponse =
- JsonConvert.DeserializeObject(resDmainMessageEntity.data.ToString());
- //获取当前版本
- var oldVersion = PlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION");
- //版本不一致,开始下载
- if (resDmainResponse.PackageVersion != oldVersion)
- {
- await Download(resDmainResponse.DocumentFileId);
- PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION",
- resDmainResponse.PackageVersion);
- }
- else //版本一致,加载缓存资源
- {
- Debug.Log($"UnityEvo:资源版本一致,自动跳过更新...");
- }
- }
- else
- {
- Debug.LogError($"UnityEvo:获取资源版本失败: 【{resDmainMessageEntity.message}】");
- }
-
- var initParams=YooAssetFileSystem.HostInitializeParameter();
- // initParameters.CacheFileSystemParameters = cacheFileSystemParams;
-
- var initOperation = package.InitializeAsync(initParams);
-
- await initOperation;
-
- if (initOperation.Status == EOperationStatus.Succeed)
- Debug.Log("UnityEvo:从远程加载资源包,初始化成功!");
- else
- Debug.LogError($"UnityEvo:从远程加载资源包,初始化失败:{initOperation.Error}");
- }
-
- public async UniTask Download(string fileId)
- {
- // 在任意MonoBehaviour或DomainBase派生类中
- string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent",
- AppConfig.PackageDomainName);
- //string loadPath = $"{Application.persistentDataPath}/DownloadedContent/{AppConfig.PackageDomainName}";
- if (Directory.Exists(loadPath))
- {
- Directory.Delete(loadPath, true);
- // 等一帧,让系统真正释放句柄
- await UniTask.DelayFrame(1);
- }
- FsmLoadSystem loadSystem =FsmSystem as FsmLoadSystem;
- if (loadSystem.ProgressBarPanel == null)
- {
- loadSystem.ProgressBarPanel =Object.Instantiate(Resources.Load("ProgressBarPanel"),
- Camera.main.transform).GetOrAddComponent();
- }
- await ZipTool.DownloadAndUnzipAsync(fileId, loadPath, DownLoadProgress, UnzipProgress);
- }
-
- private void DownLoadProgress(float progress)
- {
- Debug.Log($"下载进度:{progress:P0}");
- FsmLoadSystem loadSystem =FsmSystem as FsmLoadSystem;
- loadSystem.ProgressBarPanel.SetProgressBarValue("下载中", progress);
- }
-
- private void UnzipProgress(float progress)
- {
- Debug.Log($"解压进度:{progress:P0}");
- FsmLoadSystem loadSystem =FsmSystem as FsmLoadSystem;
- loadSystem.ProgressBarPanel.SetProgressBarValue("解压中", progress);
- }
- }
-}
\ No newline at end of file
+// using System;
+// using System.IO;
+// using Cysharp.Threading.Tasks;
+// using Main;
+// using Newtonsoft.Json;
+// using UnityEditor;
+// using UnityEngine;
+// using UnityEngine.Assertions;
+// using YooAsset;
+// using Object = UnityEngine.Object;
+//
+// namespace Stary.Evo
+// {
+// public class ArtResStartState : AbstractFSMIStateAsync
+// {
+// public ArtResStartState(IFsmSystemAsync system) : base(system)
+// {
+// }
+//
+//
+// public override async UniTask OnEnterAsync()
+// {
+// Debug.Log("UnityEvo:启动开始资源初始化...");
+//
+//
+// //初始化读取资源配置表
+// HotfixMainResDomain hotfixMainResDomain = Resources.Load("HotfixMainResDomain");
+// if (hotfixMainResDomain != null)
+// {
+// AppConfig.IpConfig = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
+// AppConfig.UserName = hotfixMainResDomain.hotfixMainResDomainEntity.username;
+// AppConfig.PassWord = hotfixMainResDomain.hotfixMainResDomainEntity.password;
+// AppConfig.ProductName =Application.identifier;
+// AppConfig.MainDomainVersion = hotfixMainResDomain.hotfixMainResDomainEntity.mainDomainVersion;
+// }
+//
+// Debug.Log($"UnityEvo:读取资源配置表成功...{AppConfig.IpConfig}{AppConfig.UserName}{AppConfig.PassWord}");
+// // 初始化资源系统
+// YooAssets.Initialize();
+//
+//
+// //自定义网络请求器
+// // 设置自定义请求委托
+// //YooAssets.SetDownloadSystemUnityWebRequest(NasWebRequester);
+//
+//
+// //初始化资源加载模块
+// // 增加包存在性检查
+// var package = YooAssets.TryGetPackage(AppConfig.PackageDomainName);
+// if (package == null)
+// {
+// Debug.LogWarning($"UnityEvo:资源包 {AppConfig.PackageDomainName} 不存在,正在尝试创建...");
+// package = YooAssets.CreatePackage(AppConfig.PackageDomainName);
+// }
+//
+// YooAssets.SetDefaultPackage(package);
+//
+// // 初始化资源包
+// #if EDITOR_SIMULATEMODE
+// await EDITOR_SIMULATEMODE(package);
+// //await FsmSystem.SetCurState(nameof(ResUpdateServerState));
+// await FsmSystem.SetCurState(nameof(ArtResEditorSimulateState));
+// #elif HOST_PLAYMODE
+//
+// //登录
+// string url = AppConfig.IpConfig + "/Authentication/login";
+// bool isLogin = await WebRequestSystem.Login(url, AppConfig.UserName, AppConfig.PassWord);
+// if (isLogin)
+// await HOST_PLAYMODE(package);
+// else
+// await Chche_PLAYMODE(package);
+//
+//
+// await FsmSystem.SetCurState(nameof(ArtResUpdateLocalState));
+// #endif
+// }
+//
+// public override UniTask OnEnterAsync(T param)
+// {
+// return UniTask.CompletedTask;
+// }
+//
+// public override UniTask OnEnterAsync(T1 param1, T2 param2)
+// {
+// return UniTask.CompletedTask;
+// }
+//
+// public override void OnUpdate()
+// {
+// base.OnUpdate();
+// }
+//
+//
+// public override UniTask OnExitAsync()
+// {
+// return UniTask.CompletedTask;
+// }
+//
+// private async UniTask EDITOR_SIMULATEMODE(ResourcePackage package)
+// {
+//
+// var initParams=YooAssetFileSystem.EditorSimulateInitializeParameter(package.PackageName);
+// var initialization = package.InitializeAsync(initParams);
+// await initialization;
+// if (initialization.Status == EOperationStatus.Succeed)
+// {
+// Assert.AreEqual(EOperationStatus.Succeed, initialization.Status);
+// Debug.Log("UnityEvo:资源包初始化成功!");
+// }
+// else
+// {
+// Debug.LogError($"UnityEvo:资源包初始化失败:{initialization.Error}");
+// }
+//
+// //运行模拟文件系统
+//
+// }
+// private async UniTask Chche_PLAYMODE(ResourcePackage package)
+// {
+// Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
+// var initParams=YooAssetFileSystem.HostInitializeParameter();
+// var initOperation = package.InitializeAsync(initParams);
+// await initOperation;
+//
+// var operation = package.RequestPackageVersionAsync();
+// await operation;
+// if (operation.Status == EOperationStatus.Succeed)
+// {
+// PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", operation.PackageVersion);
+// Debug.Log("UnityEvo:从本地缓存中加载资源包,初始化获取版本号成功!");
+// }else
+// {
+// Debug.LogError($"UnityEvo:从本地缓存中加载资源包,初始化获取版本号失败!");
+// }
+//
+// if (initOperation.Status == EOperationStatus.Succeed)
+// Debug.Log("UnityEvo:从本地缓存中资源包,初始化成功!");
+// else
+// Debug.LogError($"UnityEvo:从本地缓存中资源包,初始化失败:{initOperation.Error}");
+// }
+//
+// public async UniTask HOST_PLAYMODE(ResourcePackage package)
+// {
+// // 新增平台判断代码
+// #if UNITY_EDITOR
+// BuildTarget buildTarget = UnityEditor.EditorUserBuildSettings.activeBuildTarget;
+// AppConfig.Platform = buildTarget.ToString();
+// #else
+// AppConfig.Platform = Application.platform.ToString();
+// #endif
+// Debug.Log($"目标平台标识: {AppConfig.Platform}");
+//
+// // 请求资源版本
+// string url = $"{AppConfig.IpConfig}/ResDomain/GetResDomainByDomain";
+// var resDmainRequst = new ResDmainRequst()
+// {
+// ProductName = AppConfig.ProductName,
+// DomainName = AppConfig.PackageDomainName,
+// Platform = AppConfig.Platform,
+// };
+// //获取服务器版本
+// var resDmainMessageEntity = await WebRequestSystem.Post(url, JsonConvert.SerializeObject(resDmainRequst));
+// if (resDmainMessageEntity.code == 200)
+// {
+// ResDmainResponse resDmainResponse =
+// JsonConvert.DeserializeObject(resDmainMessageEntity.data.ToString());
+// //获取当前版本
+// var oldVersion = PlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION");
+// //版本不一致,开始下载
+// if (resDmainResponse.PackageVersion != oldVersion)
+// {
+// await Download(resDmainResponse.DocumentFileId);
+// PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION",
+// resDmainResponse.PackageVersion);
+// }
+// else //版本一致,加载缓存资源
+// {
+// Debug.Log($"UnityEvo:资源版本一致,自动跳过更新...");
+// }
+// }
+// else
+// {
+// Debug.LogError($"UnityEvo:获取资源版本失败: 【{resDmainMessageEntity.message}】");
+// }
+//
+// var initParams=YooAssetFileSystem.HostInitializeParameter();
+// // initParameters.CacheFileSystemParameters = cacheFileSystemParams;
+//
+// var initOperation = package.InitializeAsync(initParams);
+//
+// await initOperation;
+//
+// if (initOperation.Status == EOperationStatus.Succeed)
+// Debug.Log("UnityEvo:从远程加载资源包,初始化成功!");
+// else
+// Debug.LogError($"UnityEvo:从远程加载资源包,初始化失败:{initOperation.Error}");
+// }
+//
+// public async UniTask Download(string fileId)
+// {
+// // 在任意MonoBehaviour或DomainBase派生类中
+// string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent",
+// AppConfig.PackageDomainName);
+// //string loadPath = $"{Application.persistentDataPath}/DownloadedContent/{AppConfig.PackageDomainName}";
+// if (Directory.Exists(loadPath))
+// {
+// Directory.Delete(loadPath, true);
+// // 等一帧,让系统真正释放句柄
+// await UniTask.DelayFrame(1);
+// }
+// FsmLoadSystem loadSystem =FsmSystem as FsmLoadSystem;
+// if (loadSystem.ProgressBarPanel == null)
+// {
+// loadSystem.ProgressBarPanel =Object.Instantiate(Resources.Load("ProgressBarPanel"),
+// Camera.main.transform).GetOrAddComponent();
+// }
+// await ZipTool.DownloadAndUnzipAsync(fileId, loadPath, DownLoadProgress, UnzipProgress);
+// }
+//
+// private void DownLoadProgress(float progress)
+// {
+// Debug.Log($"下载进度:{progress:P0}");
+// FsmLoadSystem loadSystem =FsmSystem as FsmLoadSystem;
+// loadSystem.ProgressBarPanel.SetProgressBarValue("下载中", progress);
+// }
+//
+// private void UnzipProgress(float progress)
+// {
+// Debug.Log($"解压进度:{progress:P0}");
+// FsmLoadSystem loadSystem =FsmSystem as FsmLoadSystem;
+// loadSystem.ProgressBarPanel.SetProgressBarValue("解压中", progress);
+// }
+// }
+// }
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Base/DomainBase.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Base/DomainBase.cs
index da6fbcc..949a574 100644
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Base/DomainBase.cs
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Base/DomainBase.cs
@@ -13,7 +13,7 @@ namespace Stary.Evo
public class DomainBase : MonoBehaviour
{
public string DomainName { get; set; }
-
+ public string DomainNameRaw { get; set; }
///
/// 触发Domain时,调用该方法
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/FsmLoadSystem.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/FsmLoadSystem.cs
index ed00f56..9e13841 100644
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/FsmLoadSystem.cs
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/FsmLoadSystem.cs
@@ -42,7 +42,7 @@ namespace Stary.Evo
public async UniTask ForceUnloadAllAssets(string packageName)
{
var package = YooAssets.TryGetPackage(packageName);
- if (package != null)
+ if (package != null&&package.InitializeStatus == EOperationStatus.Succeed)
{
var operation = package.UnloadAllAssetsAsync();
await operation;
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixState.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixDllState.cs
similarity index 97%
rename from Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixState.cs
rename to Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixDllState.cs
index 3873924..d28b6cc 100644
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixState.cs
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixDllState.cs
@@ -9,12 +9,11 @@ using YooAsset;
namespace Stary.Evo
{
- public class HotFixState : AbstractFSMIStateAsync
+ public class HotFixDllState : AbstractFSMIStateAsync
{
-
public string[] PatchedAOTAssemblyList =
{
- "System.Core.dll",
+ "System.Core.dll",
"UnityEngine.CoreModule.dll",
"mscorlib.dll",
"DOTween.dll",
@@ -25,7 +24,7 @@ namespace Stary.Evo
"mscorlib.dll"
};
- public HotFixState(IFsmSystemAsync system) : base(system)
+ public HotFixDllState(IFsmSystemAsync system) : base(system)
{
}
@@ -52,7 +51,7 @@ namespace Stary.Evo
if (assemblyType != null)
{
Debug.Log($"UnityEvo:热更程序集:{hotUpdateAssemblyName} 已经加载过了");
- FsmSystem.SetCurState(nameof(LoadResState), domainConfig, assemblyType);
+ FsmSystem.SetCurState(nameof(ResStartState), domainConfig, assemblyType);
return;
}
@@ -208,7 +207,7 @@ namespace Stary.Evo
Debug.Log("UnityEvo:dll:OnExit检查成功!!");
// AppConfig.SetDefaultHotfixType(type);
- FsmSystem.SetCurState(nameof(LoadResState), domainConfig, type);
+ FsmSystem.SetCurState(nameof(ResStartState), domainConfig, type);
// // 创建热更类实例
// DomainBase hotfixInstance = AppConfig.HOTFIXBASE.AddComponent(type) as DomainBase;
//
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixState.cs.meta b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixDllState.cs.meta
similarity index 100%
rename from Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixState.cs.meta
rename to Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixDllState.cs.meta
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixStartState.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixStartState.cs
new file mode 100644
index 0000000..9bf67e6
--- /dev/null
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixStartState.cs
@@ -0,0 +1,418 @@
+using System;
+using System.IO;
+using Cysharp.Threading.Tasks;
+using Main;
+using Newtonsoft.Json;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.Assertions;
+using YooAsset;
+using Object = UnityEngine.Object;
+
+namespace Stary.Evo
+{
+ public class HotFixStartState : AbstractFSMIStateAsync
+ {
+ public HotFixStartState(IFsmSystemAsync system) : base(system)
+ {
+ }
+
+
+ public override async UniTask OnEnterAsync()
+ {
+ Debug.Log("UnityEvo:启动开始资源初始化...");
+
+
+ // 初始化资源系统
+ YooAssets.Initialize();
+ //初始化资源加载模块
+ // 增加包存在性检查
+ var package = YooAssets.TryGetPackage(AppConfig.PackageDomainName);
+ if (package == null)
+ {
+ Debug.LogWarning($"UnityEvo:资源包 {AppConfig.PackageDomainName} 不存在,正在尝试创建...");
+ package = YooAssets.CreatePackage(AppConfig.PackageDomainName);
+ }
+
+ YooAssets.SetDefaultPackage(package);
+
+ var packageRawFile = YooAssets.TryGetPackage($"{AppConfig.PackageDomainName}_RawFile");
+ if (packageRawFile == null)
+ {
+ Debug.LogWarning($"UnityEvo:资源包 {AppConfig.PackageDomainName}_RawFile 不存在,正在尝试创建...");
+ packageRawFile = YooAssets.CreatePackage($"{AppConfig.PackageDomainName}_RawFile");
+ }
+
+ // 初始化资源包
+#if EDITOR_SIMULATEMODE
+ await EDITOR_SIMULATEMODE(package);
+ await FsmSystem.SetCurState(nameof(ResEditorSimulateState));
+#elif HOST_PLAYMODE
+ bool isInitSuccess = false;
+ //登录
+ if (((FsmLoadSystem)FsmSystem).IsLogin)
+ {
+ await GetServerVersion();
+ await HOST_PLAYMODE(package);
+ isInitSuccess = await HOST_PLAYMODE(packageRawFile);
+ }
+ else
+ {
+ await OFFLINE_PLAYMODE(package);
+ await ChChe_PLAYMODE(package);
+ await OFFLINE_PLAYMODE(packageRawFile);
+ isInitSuccess = await ChChe_PLAYMODE(packageRawFile);
+ }
+
+ await UpdateLocalPackage(package);
+ if (isInitSuccess)
+ await UpdateLocalPackage(packageRawFile);
+ await LoadHotfixSettings();
+ //await FsmSystem.SetCurState(nameof(ResUpdateLocalState));
+
+#elif WEB_PLAYMODE
+ // IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
+ // var webServerFileSystemParams = FileSystemParameters.CreateDefaultWebServerFileSystemParameters();
+ // var webRemoteFileSystemParams =
+ // FileSystemParameters.CreateDefaultWebRemoteFileSystemParameters(remoteServices); //支持跨域下载
+ //
+ // var initParameters = new WebPlayModeParameters();
+ // initParameters.WebServerFileSystemParameters = webServerFileSystemParams;
+ // initParameters.WebRemoteFileSystemParameters = webRemoteFileSystemParams;
+ //
+ // var initOperation = package.InitializeAsync(initParameters);
+ // await initOperation;
+ //
+ // if (initOperation.Status == EOperationStatus.Succeed)
+ // Debug.Log("UnityEvo:资源包初始化成功!");
+ // else
+ // Debug.LogError($"UnityEvo:资源包初始化失败:{initOperation.Error}");
+
+ Debug.LogError($"UnityEvo:暂不支持");
+#endif
+ }
+
+ public override UniTask OnEnterAsync(T param)
+ {
+ return UniTask.CompletedTask;
+ }
+
+ public override UniTask OnEnterAsync(T1 param1, T2 param2)
+ {
+ return UniTask.CompletedTask;
+ }
+
+ public override UniTask OnExitAsync()
+ {
+ return UniTask.CompletedTask;
+ }
+
+ #region PLAYMODE
+
+ private async UniTask EDITOR_SIMULATEMODE(ResourcePackage package)
+ {
+ var initParams = YooAssetFileSystem.EditorSimulateInitializeParameter(package.PackageName);
+ var initialization = package.InitializeAsync(initParams);
+ await initialization;
+ if (initialization.Status == EOperationStatus.Succeed)
+ {
+ Assert.AreEqual(EOperationStatus.Succeed, initialization.Status);
+ Debug.Log("UnityEvo:资源包初始化成功!");
+ }
+ else
+ {
+ Debug.LogError($"UnityEvo:资源包初始化失败:{initialization.Error}");
+ }
+ }
+
+ private async UniTask HOST_PLAYMODE(ResourcePackage package)
+ {
+ var initParams = YooAssetFileSystem.HostInitializeParameter(package.PackageName);
+ // initParameters.CacheFileSystemParameters = cacheFileSystemParams;
+
+ var initOperation = package.InitializeAsync(initParams);
+
+ await initOperation;
+
+ if (initOperation.Status == EOperationStatus.Succeed)
+ {
+ Debug.Log("UnityEvo:从远程加载资源包,初始化成功!");
+ return true;
+ }
+ else
+ {
+ Debug.LogError($"UnityEvo:从远程加载资源包,初始化失败:{initOperation.Error}");
+ return false;
+ }
+ }
+
+ private async UniTask OFFLINE_PLAYMODE(ResourcePackage package)
+ {
+ Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
+ CopyLocalFile(package.PackageName);
+ }
+
+ private async UniTask ChChe_PLAYMODE(ResourcePackage package)
+ {
+ //Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
+ var initParams = YooAssetFileSystem.HostInitializeParameter(package.PackageName);
+ var initOperation = package.InitializeAsync(initParams);
+ await initOperation;
+ if (initOperation.Status == EOperationStatus.Succeed)
+ {
+ Debug.Log("UnityEvo:从本地缓存中资源包,初始化成功!");
+ return true;
+ }
+ else
+ {
+ Debug.LogError($"UnityEvo:从本地缓存中资源包,初始化失败:{initOperation.Error}");
+ return false;
+ }
+
+
+ var operation = package.RequestPackageVersionAsync();
+ await operation;
+ if (operation.Status == EOperationStatus.Succeed)
+ {
+ CustomPlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", operation.PackageVersion);
+ Debug.Log("UnityEvo:从本地缓存中加载资源包,初始化获取版本号成功!");
+ }
+ else
+ {
+ Debug.LogError($"UnityEvo:从本地缓存中加载资源包,初始化获取版本号失败!");
+ }
+ }
+
+ #endregion
+
+ private void CopyLocalFile(string packageDomainName)
+ {
+#if UNITY_ANDROID
+ // 将StreamingAssets下指定的package拷贝到目标路径
+ string sourcePath = Path.Combine(Application.streamingAssetsPath,
+ YooAssetSettingsData.GetDefaultYooFolderName(), packageDomainName);
+ string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent",
+ packageDomainName);
+
+ // 创建目标目录(如果不存在)
+ if (!Directory.Exists(loadPath))
+ {
+ Directory.CreateDirectory(loadPath);
+ }
+ else
+ {
+ return;
+ }
+
+ // 检查源路径是否存在
+ if (Directory.Exists(sourcePath))
+ {
+ // 拷贝所有文件
+ string[] files = Directory.GetFiles(sourcePath, "*", SearchOption.AllDirectories);
+ foreach (string file in files)
+ {
+ // 计算目标文件路径
+ string relativePath = Path.GetRelativePath(sourcePath, file);
+ string destFile = Path.Combine(loadPath, relativePath);
+
+ // 创建目标子目录(如果不存在)
+ string destDir = Path.GetDirectoryName(destFile);
+ if (!Directory.Exists(destDir))
+ {
+ Directory.CreateDirectory(destDir);
+ }
+
+ // 拷贝文件
+ File.Copy(file, destFile, true);
+ }
+
+ Debug.Log($"UnityEvo:成功将StreamingAssets下的{packageDomainName}包拷贝到{loadPath}");
+ }
+ else
+ {
+ Debug.LogError($"UnityEvo:StreamingAssets下的{packageDomainName}包不存在");
+ }
+#endif
+ }
+
+ private async UniTask GetServerVersion()
+ {
+ // 新增平台判断代码
+#if UNITY_EDITOR
+ BuildTarget buildTarget = UnityEditor.EditorUserBuildSettings.activeBuildTarget;
+ AppConfig.Platform = buildTarget.ToString();
+#else
+ AppConfig.Platform = Application.platform.ToString();
+#endif
+ Debug.Log($"目标平台标识: {AppConfig.Platform}");
+
+ // 请求资源版本
+ string url = $"{AppConfig.IpConfig}/ResDomain/GetResDomainByDomain";
+ var resDmainRequst = new ResDmainRequst()
+ {
+ ProductName = AppConfig.ProductName,
+ DomainName = AppConfig.PackageDomainName,
+ Platform = AppConfig.Platform,
+ };
+ //获取服务器版本
+ var resDmainMessageEntity = await WebRequestSystem.Post(url, JsonConvert.SerializeObject(resDmainRequst));
+ if (resDmainMessageEntity.code == 200)
+ {
+ ResDmainResponse resDmainResponse =
+ JsonConvert.DeserializeObject(resDmainMessageEntity.data.ToString());
+ //获取当前版本
+ var oldVersion = CustomPlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION");
+ //版本不一致,开始下载
+ if (resDmainResponse.PackageVersion != oldVersion)
+ {
+ await Download(resDmainResponse.DocumentFileId);
+ CustomPlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION",
+ resDmainResponse.PackageVersion);
+ }
+ else //版本一致,加载缓存资源
+ {
+ Debug.Log($"UnityEvo:当前版本{oldVersion}资源版本一致,自动跳过更新...");
+ }
+ }
+ else
+ {
+ Debug.LogError($"UnityEvo:获取资源版本失败: 【{resDmainMessageEntity.message}】");
+ }
+ }
+
+ private async UniTask UpdateLocalPackage(ResourcePackage package)
+ {
+ //更新失败
+
+ Debug.Log($"UnityEvo:开始加载本地缓存资源...");
+
+ // 获取上次成功记录的版本
+ string packageVersion =
+ CustomPlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION", string.Empty);
+ if (string.IsNullOrEmpty(packageVersion))
+ {
+ Debug.Log($"UnityEvo:{package.PackageName}没有找到本地版本记录,需要更新资源!");
+ return;
+ }
+
+ Debug.Log($"UnityEvo:获取资源版本 Version : 【{packageVersion}】");
+ // Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
+
+
+ // 加载本地缓存的资源清单文件
+ var updateManifestOp = package.UpdatePackageManifestAsync(packageVersion, 10);
+ await updateManifestOp;
+ if (updateManifestOp.Status == EOperationStatus.Succeed)
+ {
+ //更新成功
+ Debug.Log($"UnityEvo:更新本地资源清单 updateManifest : 【成功】");
+ }
+ else
+ {
+ //更新失败
+ Debug.LogError($"UnityEvo:加载本地资源清单文件失败,需要更新资源!: 【{updateManifestOp.Error}】");
+ return;
+ }
+
+ Assert.AreEqual(EOperationStatus.Succeed, updateManifestOp.Status);
+ }
+
+ private async UniTask LoadHotfixSettings()
+ {
+ //初始化读取资源配置表
+ var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
+ if (HybridClREntrance.Global.stage == StageType.Developer)
+ {
+ //加载热更配置文件
+ var loadHotfixSettingsOp = package.LoadAssetAsync("Config_DomainConfig");
+ await loadHotfixSettingsOp;
+ DomainConfig domainConfig = null;
+ if (loadHotfixSettingsOp.Status == EOperationStatus.Succeed)
+ {
+ //更新成功
+ Debug.Log($"UnityEvo:加载热更配置文件 DomainConfig : 【成功】");
+ domainConfig = loadHotfixSettingsOp.AssetObject as DomainConfig;
+ }
+ else
+ {
+ Debug.LogError($"UnityEvo:加载热更配置文件 DomainConfig : 【失败】");
+ }
+
+
+ if (domainConfig == null)
+ {
+ Debug.LogError($"UnityEvo:【{package.PackageName}】加载DomainConfig为空,无法继续执行后续流程,请检查!!!");
+ }
+
+ FsmSystem.SetCurState(nameof(HotFixDllState), domainConfig);
+ }
+ else if (HybridClREntrance.Global.stage == StageType.Originality)
+ {
+ //加载热更配置文件
+ var loadArtSceneDataOp = package.LoadAssetAsync("Config_ArtSceneData");
+ await loadArtSceneDataOp;
+ ArtSceneData artSceneData = null;
+ if (loadArtSceneDataOp.Status == EOperationStatus.Succeed)
+ {
+ //更新成功
+ Debug.Log($"UnityEvo:加载热更配置文件 ArtSceneData : 【成功】");
+ artSceneData = loadArtSceneDataOp.AssetObject as ArtSceneData;
+ await FsmSystem.SetCurState(nameof(ResStartState), null);
+ }
+ else
+ {
+ Debug.LogError($"UnityEvo:加载热更配置文件 ArtSceneData : 【失败】");
+ }
+
+
+ if (artSceneData == null)
+ {
+ Debug.LogError($"UnityEvo:【{package.PackageName}】加载ArtSceneData为空,无法继续执行后续流程,请检查!!!");
+ }
+ }
+ }
+
+ #region 下载模块
+
+ public async UniTask Download(string fileId)
+ {
+ // 在任意MonoBehaviour或DomainBase派生类中
+ //string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent", AppConfig.PackageDomainName);
+ string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent");
+ //string loadPath = $"{Application.persistentDataPath}/DownloadedContent/{AppConfig.PackageDomainName}";
+ if (Directory.Exists(loadPath))
+ {
+ Directory.Delete(loadPath, true);
+ // 等一帧,让系统真正释放句柄
+ await UniTask.DelayFrame(1);
+ }
+
+ FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
+ if (loadSystem != null && loadSystem.ProgressBarPanel == null)
+ {
+ loadSystem.ProgressBarPanel = Object.Instantiate(Resources.Load("ProgressBarPanel"),
+ Camera.main.transform).GetOrAddComponent();
+ }
+
+ await ZipTool.DownloadAndUnzipAsync(fileId, loadPath, DownLoadProgress, UnzipProgress);
+ }
+
+ private void DownLoadProgress(float progress)
+ {
+ Debug.Log($"下载进度:{progress:P0}");
+ FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
+ if (loadSystem != null)
+ loadSystem.ProgressBarPanel.SetProgressBarValue("下载中", progress);
+ }
+
+ private void UnzipProgress(float progress)
+ {
+ Debug.Log($"解压进度:{progress:P0}");
+ FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
+ if (loadSystem != null)
+ loadSystem.ProgressBarPanel.SetProgressBarValue("解压中", progress);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixStartState.cs.meta b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixStartState.cs.meta
new file mode 100644
index 0000000..95ca751
--- /dev/null
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/HotFixStartState.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4d028a909b542584e8c5f91c11deba28
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/LoadResState.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/LoadResState.cs
deleted file mode 100644
index aae59f4..0000000
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/LoadResState.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-using System;
-using Cysharp.Threading.Tasks;
-
-#if Immersal
-using Immersal.AR;
-#endif
-using Stary.Evo;
-using Stary.Evo.InformationSave;
-using UnityEngine;
-using UnityEngine.SceneManagement;
-using YooAsset;
-
-namespace Stary.Evo
-{
- public class LoadResState : AbstractFSMIStateAsync
- {
- private DomainConfig.LoadResType loadResType;
- public GameObject mainPrefab;
- private DomainConfig domainConfig;
-
- private string _sceneName;
-
- public LoadResState(IFsmSystemAsync system) : base(system)
- {
- }
-
-
- public override UniTask OnEnterAsync()
- {
- return UniTask.CompletedTask;
- }
-
- public override UniTask OnEnterAsync(T param)
- {
- return UniTask.CompletedTask;
- }
-
- public override async UniTask OnEnterAsync(T1 param1, T2 param2)
- {
- Debug.Log("加载资源...");
- domainConfig = param1 as DomainConfig;
- loadResType = domainConfig.loadResType;
- Type type = param2 as Type;
- var package = YooAssets.GetPackage(domainConfig.domain);
- switch (loadResType)
- {
- case DomainConfig.LoadResType.Prefab:
-
- await LoadDomainPrefab(package);
-
- break;
- case DomainConfig.LoadResType.Scene:
-
- var sceneMode = domainConfig.loadSceneMode;
- var physicsMode = LocalPhysicsMode.None;
- SceneHandle handle = package.LoadSceneAsync(domainConfig.sceneIdentifier, sceneMode, physicsMode);
- await handle;
-
- Scene targetScene = SceneManager.GetSceneByName(handle.SceneName);
- // targetScene.name = domainConfig.mainScene;
- // 设置为 active scene 或者后续 Move 到该 scene
- SceneManager.SetActiveScene(targetScene);
- _sceneName = targetScene.name;
- mainPrefab = GameObject.Find(domainConfig.mainPrefab);
- if (mainPrefab == null)
- {
- await LoadDomainPrefab(package);
- }
-
- break;
- }
-
- if (domainConfig.domain != "Main")
- {
- LocalTransformInfo info = mainPrefab.GetOrAddComponent();
- FsmLoadSystem fsmLoadSystem = FsmSystem as FsmLoadSystem;
-
- if (info._list.Count >= 2)
- {
- if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.PointCloud)
- {
- info.Switch(1);
- }
- else if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.VIOICE)
- {
- info.Switch(0);
- }
- else if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.ImageTracked)
- {
- info.transform.position = fsmLoadSystem.GetTransformCtor().position;
- info.transform.rotation = Quaternion.Euler(fsmLoadSystem.GetTransformCtor().rotation);
- info.transform.localScale = fsmLoadSystem.GetTransformCtor().scale;
- }
- else
- {
- info.Switch(0);
- }
- }
- else
- {
- Debug.LogError($"UnityEvo:{mainPrefab.name}的TransformInfo长度小于2,无法继续运行,请排查");
- }
- }
-
- if (mainPrefab != null)
- {
- DomainBase hotfixInstance = mainPrefab.GetComponent(type) as DomainBase;
- if (hotfixInstance == null)
- {
- hotfixInstance = mainPrefab.AddComponent(type) as DomainBase;
- }
-
- hotfixInstance.DomainName = domainConfig.domain;
- if (hotfixInstance == null)
- {
- Debug.LogError($"热更类{type.Name}实例创建失败!必须继承MonoBehaviour");
- return;
- }
-
-
- // 原有调用逻辑修改为使用实例
- hotfixInstance.OnEnter("");
- hotfixInstance.OnEnterAsync("");
- }
- }
-
- public override void OnUpdate()
- {
- base.OnUpdate();
- }
-
- private async UniTask LoadDomainPrefab(ResourcePackage package)
- {
- // 加载热更资源
- var loadOperation = package.LoadAssetAsync(domainConfig.mainPrefab);
-
- await loadOperation;
- if (loadOperation.Status == EOperationStatus.Succeed)
- {
-#if Immersal
- ARSpace arSpace = GameObject.FindObjectOfType();
- if (arSpace != null)
- {
- Debug.Log("UnityEvo:找到ARSpace,开始加载点云运行环境...");
- mainPrefab = loadOperation.InstantiateSync(arSpace.transform);
- } else
- {
- Debug.Log("UnityEvo:未找到ARSpace,开始加载普通运行环境,通过语音唤醒...");
- mainPrefab = loadOperation.InstantiateSync();
- }
-#elif NotPointClond
- mainPrefab = loadOperation.InstantiateSync();
-#endif
- if (domainConfig.domain == "Main")
- AppConfig.SetDefaultMainInstance(mainPrefab);
- }
- }
-
- public override async UniTask OnExitAsync()
- {
- Debug.Log("UnityEvo:Domain退出...");
- if (domainConfig.domain != "Main")
- {
- DomainBase domainBase = mainPrefab.GetOrAddComponent();
- if (domainBase == null)
- {
- Debug.LogError($"UnityEvo:{mainPrefab.name}的DomainBase为空,无法退出,请排查");
- }
- else
- {
- domainBase.OnExit();
- await domainBase.OnExitAsync();
- }
- if (domainBase != null)
- {
- GameObject.Destroy(domainBase.gameObject);
-
- await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(domainBase.DomainName);
- }
- if (loadResType == DomainConfig.LoadResType.Scene)
- {
- await SceneManager.UnloadSceneAsync(_sceneName);
- }
-
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/LoadResState.cs.meta b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/LoadResState.cs.meta
deleted file mode 100644
index 70f5020..0000000
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/LoadResState.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: f689e40cd4654793a8f1d3ce69ba3532
-timeCreated: 1741165763
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResEditorSimulateState.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResEditorSimulateState.cs
index d8d05f0..b991b1a 100644
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResEditorSimulateState.cs
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResEditorSimulateState.cs
@@ -26,14 +26,14 @@ namespace Stary.Evo
{
//更新成功
packageVersion = requetVersionOp.PackageVersion;
- PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", packageVersion);
+ CustomPlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", packageVersion);
Debug.Log($"UnityEvo:获取资源版本 Version : 【{packageVersion}】");
Debug.Log($"UnityEvo:开始加载服务器资源...");
}
else
{
Debug.LogError($"UnityEvo:获取资源版本失败: 【{requetVersionOp.Error}】");
- FsmSystem.SetCurState(nameof(ResUpdateLocalState));
+ //FsmSystem.SetCurState(nameof(ResUpdateLocalState));
return;
}
@@ -60,29 +60,55 @@ namespace Stary.Evo
//4.下载补丁包
await Download();
-
- //加载热更配置文件
- var loadHotfixSettingsOp = package.LoadAssetAsync("Config_DomainConfig");
- await loadHotfixSettingsOp;
- DomainConfig domainConfig = null;
- if (loadHotfixSettingsOp.Status == EOperationStatus.Succeed)
+ if (HybridClREntrance.Global.stage == StageType.Developer)
{
- //更新成功
- Debug.Log($"UnityEvo:加载热更配置文件 loadHotfixSettings : 【成功】");
- domainConfig = loadHotfixSettingsOp.AssetObject as DomainConfig;
+ //加载热更配置文件
+ var loadHotfixSettingsOp = package.LoadAssetAsync("Config_DomainConfig");
+ await loadHotfixSettingsOp;
+ DomainConfig domainConfig = null;
+ if (loadHotfixSettingsOp.Status == EOperationStatus.Succeed)
+ {
+ //更新成功
+ Debug.Log($"UnityEvo:加载热更配置文件 loadHotfixSettings : 【成功】");
+ domainConfig = loadHotfixSettingsOp.AssetObject as DomainConfig;
+ }
+ else
+ {
+ Debug.LogError($"UnityEvo:加载热更配置文件 loadHotfixSettings : 【失败】");
+ }
+
+
+ if (domainConfig == null)
+ {
+ Debug.LogError($"UnityEvo:【{package.PackageName}】加载DomainConfig为空,无法继续执行后续流程,请检查!!!");
+ }
+
+ FsmSystem.SetCurState(nameof(HotFixDllState), domainConfig);
}
- else
+ else if (HybridClREntrance.Global.stage == StageType.Originality)
{
- Debug.LogError($"UnityEvo:加载热更配置文件 loadHotfixSettings : 【失败】");
+ //加载热更配置文件
+ var loadArtSceneDataOp = package.LoadAssetAsync("Config_ArtSceneData");
+ await loadArtSceneDataOp;
+ ArtSceneData artSceneData = null;
+ if (loadArtSceneDataOp.Status == EOperationStatus.Succeed)
+ {
+ //更新成功
+ Debug.Log($"UnityEvo:加载热更配置文件 ArtSceneData : 【成功】");
+ artSceneData = loadArtSceneDataOp.AssetObject as ArtSceneData;
+ await FsmSystem.SetCurState(nameof(ResStartState), null);
+ }
+ else
+ {
+ Debug.LogError($"UnityEvo:加载热更配置文件 ArtSceneData : 【失败】");
+ }
+
+
+ if (artSceneData == null)
+ {
+ Debug.LogError($"UnityEvo:【{package.PackageName}】加载ArtSceneData为空,无法继续执行后续流程,请检查!!!");
+ }
}
-
-
- if (domainConfig == null)
- {
- Debug.LogError($"UnityEvo:【{package.PackageName}】加载DomainConfig为空,无法继续执行后续流程,请检查!!!");
- }
-
- FsmSystem.SetCurState(nameof(HotFixState), domainConfig);
}
public override UniTask OnEnterAsync(T param)
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResStartState.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResStartState.cs
index 3e4a6a3..5fb7cee 100644
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResStartState.cs
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResStartState.cs
@@ -1,81 +1,33 @@
using System;
-using System.IO;
using Cysharp.Threading.Tasks;
-using Main;
-using Newtonsoft.Json;
-using UnityEditor;
+
+#if Immersal
+using Immersal.AR;
+#endif
+using Stary.Evo;
+using Stary.Evo.InformationSave;
using UnityEngine;
-using UnityEngine.Assertions;
+using UnityEngine.SceneManagement;
using YooAsset;
-using Object = UnityEngine.Object;
namespace Stary.Evo
{
public class ResStartState : AbstractFSMIStateAsync
{
+ private DomainConfig.LoadResType loadResType;
+ public GameObject mainPrefab;
+ private DomainConfig domainConfig;
+
+ private string _sceneName;
+
public ResStartState(IFsmSystemAsync system) : base(system)
{
}
- public override async UniTask OnEnterAsync()
+ public override UniTask OnEnterAsync()
{
- Debug.Log("UnityEvo:启动开始资源初始化...");
-
-
- // 初始化资源系统
- YooAssets.Initialize();
- //初始化资源加载模块
- // 增加包存在性检查
- var package = YooAssets.TryGetPackage(AppConfig.PackageDomainName);
- if (package == null)
- {
- Debug.LogWarning($"UnityEvo:资源包 {AppConfig.PackageDomainName} 不存在,正在尝试创建...");
- package = YooAssets.CreatePackage(AppConfig.PackageDomainName);
- }
-
- YooAssets.SetDefaultPackage(package);
-
- // 初始化资源包
-#if EDITOR_SIMULATEMODE
- await EDITOR_SIMULATEMODE(package);
- await FsmSystem.SetCurState(nameof(ResEditorSimulateState));
-#elif OFFLINE_PLAYMODE
- await OFFLINE_PLAYMODE(package);
- await FsmSystem.SetCurState(nameof(ResUpdateLocalState));
-#elif HOST_PLAYMODE
- //登录
- if (((FsmLoadSystem)FsmSystem).IsLogin)
- await HOST_PLAYMODE(package);
- else
- {
- await OFFLINE_PLAYMODE(package);
- await ChChe_PLAYMODE(package);
- }
-
-
- await FsmSystem.SetCurState(nameof(ResUpdateLocalState));
-
-#elif WEB_PLAYMODE
- // IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
- // var webServerFileSystemParams = FileSystemParameters.CreateDefaultWebServerFileSystemParameters();
- // var webRemoteFileSystemParams =
- // FileSystemParameters.CreateDefaultWebRemoteFileSystemParameters(remoteServices); //支持跨域下载
- //
- // var initParameters = new WebPlayModeParameters();
- // initParameters.WebServerFileSystemParameters = webServerFileSystemParams;
- // initParameters.WebRemoteFileSystemParameters = webRemoteFileSystemParams;
- //
- // var initOperation = package.InitializeAsync(initParameters);
- // await initOperation;
- //
- // if (initOperation.Status == EOperationStatus.Succeed)
- // Debug.Log("UnityEvo:资源包初始化成功!");
- // else
- // Debug.LogError($"UnityEvo:资源包初始化失败:{initOperation.Error}");
-
- Debug.LogError($"UnityEvo:暂不支持");
-#endif
+ return UniTask.CompletedTask;
}
public override UniTask OnEnterAsync(T param)
@@ -83,233 +35,162 @@ namespace Stary.Evo
return UniTask.CompletedTask;
}
- public override UniTask OnEnterAsync(T1 param1, T2 param2)
+ public override async UniTask OnEnterAsync(T1 param1, T2 param2)
{
- return UniTask.CompletedTask;
- }
-
- public override void OnUpdate()
- {
- base.OnUpdate();
- }
-
-
- public override UniTask OnExitAsync()
- {
- return UniTask.CompletedTask;
- }
-
- private async UniTask EDITOR_SIMULATEMODE(ResourcePackage package)
- {
- var initParams = YooAssetFileSystem.EditorSimulateInitializeParameter(package.PackageName);
- var initialization = package.InitializeAsync(initParams);
- await initialization;
- if (initialization.Status == EOperationStatus.Succeed)
- {
- Assert.AreEqual(EOperationStatus.Succeed, initialization.Status);
- Debug.Log("UnityEvo:资源包初始化成功!");
- }
- else
- {
- Debug.LogError($"UnityEvo:资源包初始化失败:{initialization.Error}");
- }
- }
-
- private async UniTask ChChe_PLAYMODE(ResourcePackage package)
- {
- //Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
- var initParams = YooAssetFileSystem.HostInitializeParameter();
- var initOperation = package.InitializeAsync(initParams);
- await initOperation;
- if (initOperation.Status == EOperationStatus.Succeed)
- Debug.Log("UnityEvo:从本地缓存中资源包,初始化成功!");
- else
- {
- Debug.LogError($"UnityEvo:从本地缓存中资源包,初始化失败:{initOperation.Error}");
- }
-
-
- var operation = package.RequestPackageVersionAsync();
- await operation;
- if (operation.Status == EOperationStatus.Succeed)
- {
- PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", operation.PackageVersion);
- Debug.Log("UnityEvo:从本地缓存中加载资源包,初始化获取版本号成功!");
- }
- else
- {
- Debug.LogError($"UnityEvo:从本地缓存中加载资源包,初始化获取版本号失败!");
- }
- }
-
- private async UniTask OFFLINE_PLAYMODE(ResourcePackage package)
- {
- Debug.Log("UnityEvo:网络连接不通畅,切换缓存加载!");
- CopyLocalFile();
- // var initParams = YooAssetFileSystem.OfflineInitializeParameter();
- // var initOperation = package.InitializeAsync(initParams);
- // await initOperation;
- //
- // var operation = package.RequestPackageVersionAsync();
- // await operation;
- // if (operation.Status == EOperationStatus.Succeed)
- // {
- // PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION", operation.PackageVersion);
- // Debug.Log("UnityEvo:从本地StreamingAssets加载资源包,初始化获取版本号成功!");
- // }
- // else
- // {
- // Debug.LogError($"UnityEvo:从本地StreamingAssets加载资源包,初始化获取版本号失败!");
- // }
- //
- // if (initOperation.Status == EOperationStatus.Succeed)
- // Debug.Log("UnityEvo:从本地StreamingAssets加载资源包,初始化成功!");
- // else
- // Debug.LogError($"UnityEvo:从本地StreamingAssets加载资源包,初始化失败:{initOperation.Error}");
- }
-
- private void CopyLocalFile()
- {
-#if UNITY_ANDROID
- // 将StreamingAssets下指定的package拷贝到目标路径
- string sourcePath = Path.Combine(Application.streamingAssetsPath,
- YooAssetSettingsData.GetDefaultYooFolderName(), AppConfig.PackageDomainName);
- string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent",
- AppConfig.PackageDomainName);
-
- // 创建目标目录(如果不存在)
- if (!Directory.Exists(loadPath))
- {
- Directory.CreateDirectory(loadPath);
- }
- else
- {
+ if (HybridClREntrance.Global.stage == StageType.Originality)
return;
- }
-
- // 检查源路径是否存在
- if (Directory.Exists(sourcePath))
+ domainConfig = param1 as DomainConfig;
+ loadResType = domainConfig.loadResType;
+ Type type = param2 as Type;
+ var package = YooAssets.GetPackage(domainConfig.domain);
+ switch (loadResType)
{
- // 拷贝所有文件
- string[] files = Directory.GetFiles(sourcePath, "*", SearchOption.AllDirectories);
- foreach (string file in files)
- {
- // 计算目标文件路径
- string relativePath = Path.GetRelativePath(sourcePath, file);
- string destFile = Path.Combine(loadPath, relativePath);
+ case DomainConfig.LoadResType.Prefab:
- // 创建目标子目录(如果不存在)
- string destDir = Path.GetDirectoryName(destFile);
- if (!Directory.Exists(destDir))
+ await LoadDomainPrefab(package);
+
+ break;
+ case DomainConfig.LoadResType.Scene:
+
+ var sceneMode = domainConfig.loadSceneMode;
+ var physicsMode = LocalPhysicsMode.None;
+ SceneHandle handle = package.LoadSceneAsync(domainConfig.sceneIdentifier, sceneMode, physicsMode);
+ await handle;
+
+ Scene targetScene = SceneManager.GetSceneByName(handle.SceneName);
+ // targetScene.name = domainConfig.mainScene;
+ // 设置为 active scene 或者后续 Move 到该 scene
+ SceneManager.SetActiveScene(targetScene);
+ _sceneName = targetScene.name;
+ mainPrefab = GameObject.Find(domainConfig.mainPrefab);
+ if (mainPrefab == null)
{
- Directory.CreateDirectory(destDir);
+ await LoadDomainPrefab(package);
}
- // 拷贝文件
- File.Copy(file, destFile, true);
- }
-
- Debug.Log($"UnityEvo:成功将StreamingAssets下的{AppConfig.PackageDomainName}包拷贝到{loadPath}");
+ break;
}
- else
- {
- Debug.LogError($"UnityEvo:StreamingAssets下的{AppConfig.PackageDomainName}包不存在");
- }
-#endif
- }
- public async UniTask HOST_PLAYMODE(ResourcePackage package)
- {
- // 新增平台判断代码
-#if UNITY_EDITOR
- BuildTarget buildTarget = UnityEditor.EditorUserBuildSettings.activeBuildTarget;
- AppConfig.Platform = buildTarget.ToString();
-#else
- AppConfig.Platform = Application.platform.ToString();
-#endif
- Debug.Log($"目标平台标识: {AppConfig.Platform}");
+ if (domainConfig.domain != "Main")
+ {
+ LocalTransformInfo info = mainPrefab.GetOrAddComponent();
+ FsmLoadSystem fsmLoadSystem = FsmSystem as FsmLoadSystem;
- // 请求资源版本
- string url = $"{AppConfig.IpConfig}/ResDomain/GetResDomainByDomain";
- var resDmainRequst = new ResDmainRequst()
- {
- ProductName = AppConfig.ProductName,
- DomainName = AppConfig.PackageDomainName,
- Platform = AppConfig.Platform,
- };
- //获取服务器版本
- var resDmainMessageEntity = await WebRequestSystem.Post(url, JsonConvert.SerializeObject(resDmainRequst));
- if (resDmainMessageEntity.code == 200)
- {
- ResDmainResponse resDmainResponse =
- JsonConvert.DeserializeObject(resDmainMessageEntity.data.ToString());
- //获取当前版本
- var oldVersion = PlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION");
- //版本不一致,开始下载
- if (resDmainResponse.PackageVersion != oldVersion)
+ if (info._list.Count >= 2)
{
- await Download(resDmainResponse.DocumentFileId);
- PlayerPrefs.SetString($"{AppConfig.PackageDomainName}_GAME_VERSION",
- resDmainResponse.PackageVersion);
+ if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.PointCloud)
+ {
+ info.Switch(1);
+ }
+ else if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.VIOICE)
+ {
+ info.Switch(0);
+ }
+ else if (fsmLoadSystem.GetOpenDomainType() == OpenDomainType.ImageTracked)
+ {
+ info.transform.position = fsmLoadSystem.GetTransformCtor().position;
+ info.transform.rotation = Quaternion.Euler(fsmLoadSystem.GetTransformCtor().rotation);
+ info.transform.localScale = fsmLoadSystem.GetTransformCtor().scale;
+ }
+ else
+ {
+ info.Switch(0);
+ }
}
- else //版本一致,加载缓存资源
+ else
{
- Debug.Log($"UnityEvo:资源版本一致,自动跳过更新...");
+ Debug.LogError($"UnityEvo:{mainPrefab.name}的TransformInfo长度小于2,无法继续运行,请排查");
}
}
- else
+
+ if (mainPrefab != null)
{
- Debug.LogError($"UnityEvo:获取资源版本失败: 【{resDmainMessageEntity.message}】");
+ DomainBase hotfixInstance = mainPrefab.GetComponent(type) as DomainBase;
+ if (hotfixInstance == null)
+ {
+ hotfixInstance = mainPrefab.AddComponent(type) as DomainBase;
+ }
+
+ if (hotfixInstance == null)
+ {
+ Debug.LogError($"热更类{type.Name}实例创建失败!必须继承MonoBehaviour");
+ return;
+ }
+
+ hotfixInstance.DomainName = domainConfig.domain;
+ hotfixInstance.DomainNameRaw = $"{domainConfig.domain}_RawFile";
+
+
+ // 原有调用逻辑修改为使用实例
+ hotfixInstance.OnEnter("");
+ hotfixInstance.OnEnterAsync("");
}
-
- var initParams = YooAssetFileSystem.HostInitializeParameter();
- // initParameters.CacheFileSystemParameters = cacheFileSystemParams;
-
- var initOperation = package.InitializeAsync(initParams);
-
- await initOperation;
-
- if (initOperation.Status == EOperationStatus.Succeed)
- Debug.Log("UnityEvo:从远程加载资源包,初始化成功!");
- else
- Debug.LogError($"UnityEvo:从远程加载资源包,初始化失败:{initOperation.Error}");
}
- public async UniTask Download(string fileId)
+ private async UniTask LoadDomainPrefab(ResourcePackage package)
{
- // 在任意MonoBehaviour或DomainBase派生类中
- string loadPath = Path.Combine(Application.temporaryCachePath, "DownloadedContent",
- AppConfig.PackageDomainName);
- //string loadPath = $"{Application.persistentDataPath}/DownloadedContent/{AppConfig.PackageDomainName}";
- if (Directory.Exists(loadPath))
- {
- Directory.Delete(loadPath, true);
- // 等一帧,让系统真正释放句柄
- await UniTask.DelayFrame(1);
- }
+ // 加载热更资源
+ var loadOperation = package.LoadAssetAsync(domainConfig.mainPrefab);
- FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
- if (loadSystem.ProgressBarPanel == null)
+ await loadOperation;
+ if (loadOperation.Status == EOperationStatus.Succeed)
{
- loadSystem.ProgressBarPanel = Object.Instantiate(Resources.Load("ProgressBarPanel"),
- Camera.main.transform).GetOrAddComponent();
+#if Immersal
+ ARSpace arSpace = GameObject.FindObjectOfType();
+ if (arSpace != null)
+ {
+ Debug.Log("UnityEvo:找到ARSpace,开始加载点云运行环境...");
+ mainPrefab = loadOperation.InstantiateSync(arSpace.transform);
+ } else
+ {
+ Debug.Log("UnityEvo:未找到ARSpace,开始加载普通运行环境,通过语音唤醒...");
+ mainPrefab = loadOperation.InstantiateSync();
+ }
+#elif NotPointClond
+ mainPrefab = loadOperation.InstantiateSync();
+#endif
+ if (domainConfig.domain == "Main")
+ AppConfig.SetDefaultMainInstance(mainPrefab);
}
-
- await ZipTool.DownloadAndUnzipAsync(fileId, loadPath, DownLoadProgress, UnzipProgress);
}
- private void DownLoadProgress(float progress)
+ public override async UniTask OnExitAsync()
{
- Debug.Log($"下载进度:{progress:P0}");
- FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
- loadSystem.ProgressBarPanel.SetProgressBarValue("下载中", progress);
- }
+ Debug.Log("UnityEvo:Domain退出...");
+ if (HybridClREntrance.Global.stage == StageType.Developer)
+ {
+ if (domainConfig.domain != "Main")
+ {
+ DomainBase domainBase = mainPrefab.GetOrAddComponent();
+ if (domainBase == null)
+ {
+ Debug.LogError($"UnityEvo:{mainPrefab.name}的DomainBase为空,无法退出,请排查");
+ }
+ else
+ {
+ domainBase.OnExit();
+ await domainBase.OnExitAsync();
+ }
- private void UnzipProgress(float progress)
- {
- Debug.Log($"解压进度:{progress:P0}");
- FsmLoadSystem loadSystem = FsmSystem as FsmLoadSystem;
- loadSystem.ProgressBarPanel.SetProgressBarValue("解压中", progress);
+ if (domainBase != null)
+ {
+ GameObject.Destroy(domainBase.gameObject);
+
+ await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(domainBase.DomainName);
+ await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(domainBase.DomainNameRaw);
+ }
+
+ if (loadResType == DomainConfig.LoadResType.Scene)
+ {
+ await SceneManager.UnloadSceneAsync(_sceneName);
+ }
+ }
+ }
+ else if (HybridClREntrance.Global.stage == StageType.Originality)
+ {
+ await ((FsmLoadSystem)FsmSystem).ForceUnloadAllAssets(AppConfig.PackageDomainName);
+ AppConfig.PackageDomainName = "";
+ }
}
}
}
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResStartState.cs.meta b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResStartState.cs.meta
index 9ac9b55..70f5020 100644
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResStartState.cs.meta
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResStartState.cs.meta
@@ -1,3 +1,3 @@
fileFormatVersion: 2
-guid: 2462c737fc9c4b53b35557f8a6aac453
-timeCreated: 1741165298
\ No newline at end of file
+guid: f689e40cd4654793a8f1d3ce69ba3532
+timeCreated: 1741165763
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResUpdateLocalState.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResUpdateLocalState.cs
deleted file mode 100644
index 0751970..0000000
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResUpdateLocalState.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-using Cysharp.Threading.Tasks;
-using UnityEngine;
-using UnityEngine.Assertions;
-using YooAsset;
-
-namespace Stary.Evo
-{
- public class ResUpdateLocalState : AbstractFSMIStateAsync
- {
- public ResUpdateLocalState(IFsmSystemAsync system) : base(system)
- {
- }
-
-
- public override async UniTask OnEnterAsync()
- {
- //初始化读取资源配置表
- var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
-
-
- //更新失败
-
- Debug.Log($"UnityEvo:开始加载本地缓存资源...");
-
- // 获取上次成功记录的版本
- string packageVersion = PlayerPrefs.GetString($"{AppConfig.PackageDomainName}_GAME_VERSION", string.Empty);
- if (string.IsNullOrEmpty(packageVersion))
- {
- Debug.Log($"UnityEvo:没有找到本地版本记录,需要更新资源!");
- return;
- }
-
- Debug.Log($"UnityEvo:获取资源版本 Version : 【{packageVersion}】");
- // Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
-
-
- // 加载本地缓存的资源清单文件
- var updateManifestOp = package.UpdatePackageManifestAsync(packageVersion);
- await updateManifestOp;
- if (updateManifestOp.Status == EOperationStatus.Succeed)
- {
- //更新成功
- Debug.Log($"UnityEvo:更新本地资源清单 updateManifest : 【成功】");
- }
- else
- {
- //更新失败
- Debug.LogError($"UnityEvo:加载本地资源清单文件失败,需要更新资源!: 【{updateManifestOp.Error}】");
- return;
- }
-
- Assert.AreEqual(EOperationStatus.Succeed, updateManifestOp.Status);
-
-
- //4.下载补丁包
- //await Download();
-
-
- //加载热更配置文件
- var loadHotfixSettingsOp = package.LoadAssetAsync("Config_DomainConfig");
- await loadHotfixSettingsOp;
- DomainConfig domainConfig = null;
- if (loadHotfixSettingsOp.Status == EOperationStatus.Succeed)
- {
- //更新成功
- Debug.Log($"UnityEvo:加载热更配置文件 DomainConfig : 【成功】");
- domainConfig = loadHotfixSettingsOp.AssetObject as DomainConfig;
- }
- else
- {
- Debug.LogError($"UnityEvo:加载热更配置文件 DomainConfig : 【失败】");
- }
-
-
- if (domainConfig == null)
- {
- Debug.LogError($"UnityEvo:【{package.PackageName}】加载DomainConfig为空,无法继续执行后续流程,请检查!!!");
- }
-
- FsmSystem.SetCurState(nameof(HotFixState), domainConfig);
- }
-
- public override UniTask OnEnterAsync(T param)
- {
- return UniTask.CompletedTask;
- }
-
- public override UniTask OnEnterAsync(T1 param1, T2 param2)
- {
- return UniTask.CompletedTask;
- }
-
- public override void OnUpdate()
- {
- base.OnUpdate();
- }
-
-
- public override UniTask OnExitAsync()
- {
- return UniTask.CompletedTask;
- }
-
- #region 下载热更资源
-
- public async UniTask Download()
- {
- int downloadingMaxNum = 1;
- int failedTryAgain = 1;
- var package = YooAssets.GetPackage(AppConfig.PackageDomainName);
- var downloader = package.CreateResourceDownloader(downloadingMaxNum, failedTryAgain);
-
- // 在正常开始游戏之前,还需要验证本地清单内容的完整性。
- if (downloader.TotalDownloadCount > 0)
- {
- Debug.Log("UnityEvo:资源内容本地并不完整,需要更新资源!");
- return;
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResUpdateLocalState.cs.meta b/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResUpdateLocalState.cs.meta
deleted file mode 100644
index 7cfcdb9..0000000
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/Fsm/ResUpdateLocalState.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: eca158039896455dba3ded1eb703a5da
-timeCreated: 1742291100
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/HybridLoad/HybridClREntrance.cs b/Assets/00.StaryEvoTools/Runtime/HybridLoad/HybridClREntrance.cs
index 7b99ee5..9644443 100644
--- a/Assets/00.StaryEvoTools/Runtime/HybridLoad/HybridClREntrance.cs
+++ b/Assets/00.StaryEvoTools/Runtime/HybridLoad/HybridClREntrance.cs
@@ -9,8 +9,7 @@ namespace Stary.Evo
public StageType stage;
public string domain;
- private FsmLoadSystem _devLoadSystem;
- private FsmLoadSystem _originalityLoadSystem;
+ private FsmLoadSystem _loadSystem;
///
@@ -31,14 +30,12 @@ namespace Stary.Evo
return;
}
- _devLoadSystem = new FsmLoadSystem();
+ _loadSystem = new FsmLoadSystem();
// 初始化日志
- _devLoadSystem.AddState(new ResStartState(_devLoadSystem));
- _devLoadSystem.AddState(new ResEditorSimulateState(_devLoadSystem));
- _devLoadSystem.AddState(new ResUpdateLocalState(_devLoadSystem));
- _devLoadSystem.AddState(new HotFixState(_devLoadSystem));
- _devLoadSystem.AddState(new LoadResState(_devLoadSystem));
- //_fsmSystem.AddState(new LoadResMainState(_fsmSystem));
+ _loadSystem.AddState(new HotFixStartState(_loadSystem));
+ _loadSystem.AddState(new ResEditorSimulateState(_loadSystem));
+ _loadSystem.AddState(new HotFixDllState(_loadSystem));
+ _loadSystem.AddState(new ResStartState(_loadSystem));
//初始化读取资源配置表
HotfixMainResDomain hotfixMainResDomain = Resources.Load("HotfixMainResDomain");
@@ -54,7 +51,7 @@ namespace Stary.Evo
Debug.Log($"UnityEvo:读取资源配置表成功...{AppConfig.IpConfig}{AppConfig.UserName}{AppConfig.PassWord}");
//登录
string url = AppConfig.IpConfig + "/Authentication/login";
- _devLoadSystem.IsLogin = await WebRequestSystem.Login(url, AppConfig.UserName, AppConfig.PassWord);
+ _loadSystem.IsLogin = await WebRequestSystem.Login(url, AppConfig.UserName, AppConfig.PassWord);
}
private void Start()
@@ -75,45 +72,30 @@ namespace Stary.Evo
AppConfig.PackageDomainName = "Main";
}
- _devLoadSystem.SetCurState(nameof(ResStartState));
+ _loadSystem.SetCurState(nameof(HotFixStartState));
}
private void Update()
{
- if (_devLoadSystem.CurState != null)
- _devLoadSystem.CurState.OnUpdate();
+ if (_loadSystem.CurState != null)
+ _loadSystem.CurState.OnUpdate();
}
public async Task OpenDomain()
{
AppConfig.PackageDomainName = domain;
- if (stage == StageType.Developer)
- {
- await _devLoadSystem.SetCurState(nameof(ResStartState));
- }
- else if (stage == StageType.Originality)
- {
- if (_originalityLoadSystem == null)
- {
- _originalityLoadSystem = new FsmLoadSystem();
- _originalityLoadSystem.AddState(new ArtResStartState(_originalityLoadSystem));
- _originalityLoadSystem.AddState(new ArtResUpdateLocalState(_originalityLoadSystem));
- _originalityLoadSystem.AddState(new ArtResEditorSimulateState(_originalityLoadSystem));
- }
-
- await _originalityLoadSystem.SetCurState(nameof(ArtResStartState));
- }
+ await _loadSystem.SetCurState(nameof(HotFixStartState));
}
public async void OpenDomain(string domain, OpenDomainType openDomainType)
{
this.domain = domain;
- _devLoadSystem.SetOpenDomainType(openDomainType);
+ _loadSystem.SetOpenDomainType(openDomainType);
if (this.domain != AppConfig.PackageDomainName)
{
AppConfig.PackageDomainName = domain;
- await _devLoadSystem.SetCurState(nameof(ResStartState));
+ await _loadSystem.SetCurState(nameof(HotFixStartState));
}
else
{
@@ -124,12 +106,12 @@ namespace Stary.Evo
public void OpenDomain(string domain, TransformCtor transformCtor)
{
this.domain = domain;
- _devLoadSystem.SetOpenDomainType(OpenDomainType.ImageTracked);
- _devLoadSystem.SetTransformCtor(transformCtor);
+ _loadSystem.SetOpenDomainType(OpenDomainType.ImageTracked);
+ _loadSystem.SetTransformCtor(transformCtor);
if (this.domain != AppConfig.PackageDomainName)
{
AppConfig.PackageDomainName = domain;
- _devLoadSystem.SetCurState(nameof(ResStartState));
+ _loadSystem.SetCurState(nameof(HotFixStartState));
}
else
{
@@ -140,12 +122,12 @@ namespace Stary.Evo
public void OpenDomain(string domain, Transform transform)
{
this.domain = domain;
- _devLoadSystem.SetOpenDomainType(OpenDomainType.ImageTracked);
- _devLoadSystem.SetTransformCtor(transform);
+ _loadSystem.SetOpenDomainType(OpenDomainType.ImageTracked);
+ _loadSystem.SetTransformCtor(transform);
if (this.domain != AppConfig.PackageDomainName)
{
AppConfig.PackageDomainName = domain;
- _devLoadSystem.SetCurState(nameof(ResStartState));
+ _loadSystem.SetCurState(nameof(HotFixStartState));
}
else
{
@@ -155,10 +137,8 @@ namespace Stary.Evo
public void CloseDomain()
{
- if (_devLoadSystem != null)
- _devLoadSystem.SetCurState(nameof(DefaultStateAsync));
- if (_originalityLoadSystem != null)
- _originalityLoadSystem.SetCurState(nameof(DefaultStateAsync));
+ if (_loadSystem != null)
+ _loadSystem.SetCurState(nameof(DefaultStateAsync));
}
}
diff --git a/Assets/00.StaryEvoTools/Runtime/Tools/YooAssetFileSystem.cs b/Assets/00.StaryEvoTools/Runtime/Tools/YooAssetFileSystem.cs
index 4c88002..bc18121 100644
--- a/Assets/00.StaryEvoTools/Runtime/Tools/YooAssetFileSystem.cs
+++ b/Assets/00.StaryEvoTools/Runtime/Tools/YooAssetFileSystem.cs
@@ -15,12 +15,12 @@ namespace Stary.Evo
return initParameters;
}
- public static InitializeParameters HostInitializeParameter()
+ public static InitializeParameters HostInitializeParameter(string packageName)
{
var initParameters = new OfflinePlayModeParameters();
var buildinFileSystemParams = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(null,
- $"{Application.temporaryCachePath}/DownloadedContent/{AppConfig.PackageDomainName}");
- Debug.Log($"UnityEvo:Host InitializeParameterPath: 【{Application.temporaryCachePath}/DownloadedContent/{AppConfig.PackageDomainName}】");
+ $"{Application.temporaryCachePath}/DownloadedContent/{packageName}");
+ Debug.Log($"UnityEvo:Host InitializeParameterPath: 【{Application.temporaryCachePath}/DownloadedContent/{packageName}】");
buildinFileSystemParams.AddParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, true);
buildinFileSystemParams.AddParameter(FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST, true);
initParameters.BuildinFileSystemParameters = buildinFileSystemParams;
diff --git a/Assets/00.StaryEvoTools/Runtime/Tools/YooAssetRawFileExtension.cs b/Assets/00.StaryEvoTools/Runtime/Tools/YooAssetRawFileExtension.cs
new file mode 100644
index 0000000..7e2d554
--- /dev/null
+++ b/Assets/00.StaryEvoTools/Runtime/Tools/YooAssetRawFileExtension.cs
@@ -0,0 +1,19 @@
+using YooAsset;
+
+namespace Stary.Evo
+{
+ public static class YooAssetRaw
+ {
+ ///
+ /// 获取原始文件路径
+ ///
+ ///
+ ///
+ public static RawFileHandle LoadRawFileAsync(string rawFilePath)
+ {
+ var package = YooAssets.TryGetPackage($"{AppConfig.PackageDomainName}_RawFile");
+ var handle = package.LoadRawFileAsync(rawFilePath);
+ return handle;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/Runtime/Tools/YooAssetRawFileExtension.cs.meta b/Assets/00.StaryEvoTools/Runtime/Tools/YooAssetRawFileExtension.cs.meta
new file mode 100644
index 0000000..716857f
--- /dev/null
+++ b/Assets/00.StaryEvoTools/Runtime/Tools/YooAssetRawFileExtension.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 36487317401342f9a337736581d9c751
+timeCreated: 1767773460
\ No newline at end of file
diff --git a/Assets/00.StaryEvoTools/package.json b/Assets/00.StaryEvoTools/package.json
index 35d6c2d..d15e04f 100644
--- a/Assets/00.StaryEvoTools/package.json
+++ b/Assets/00.StaryEvoTools/package.json
@@ -1,6 +1,6 @@
{
"name": "com.staryevo.tools",
- "version": "1.3.1",
+ "version": "1.3.3",
"displayName": "00.StaryEvo.Tools",
"description": "This is an Framework package(后台服务器版本,端口9527)",
"unity": "2021.3",