Compare commits

...

29 Commits

Author SHA1 Message Date
ALEXTANG
1d56437d9f Update Utility.Http.cs 2023-10-30 11:15:52 +08:00
ALEXTANG
69db1ff977 修正音频模块音频代理类赋值问题
#54 修正音频模块音频代理类赋值问题
2023-10-30 10:40:22 +08:00
ALEXTANG
48887b1aee 框架支持Shudown不关闭游戏重启
框架支持Shudown不关闭游戏重启
2023-10-27 13:18:12 +08:00
ALEXTANG
381ea8bb8d 增加支持ComponentAutoBindTool自动绑定UI元素组件。
增加支持ComponentAutoBindTool自动绑定UI元素组件。
2023-10-27 10:48:21 +08:00
ALEXTANG
7401edac15 移除UIElement代码绑定工具,为后续AutoBind代码绑定工具做准备
移除UIElement代码绑定工具,为后续AutoBind代码绑定工具做准备
2023-10-27 00:13:04 +08:00
ALEXTANG
b1c7f30be9 ErrorLogger屏幕显示开启与DebugModule关联。
ErrorLogger屏幕显示开启与DebugModule关联。
2023-10-26 23:45:26 +08:00
ALEXTANG
cfaf82a623 释放资源判断资源是否有效
释放资源判断资源是否有效
2023-10-26 14:07:38 +08:00
ALEXTANG
6992d12c6c 修复循环列表主动GetItemByIndex和GetItemList的问题
修复循环列表主动GetItemByIndex和GetItemList的问题
2023-10-26 13:12:35 +08:00
ALEXTANG
119d9683ad Merge pull request #53 from AlanWeekend/main
修复UIListBase和UILoopListWidget赋值问题
2023-10-26 12:49:00 +08:00
ALEXTANG
9478868513 修正HttpDispose
修正HttpDispose
2023-10-26 12:28:06 +08:00
ALEXTANG
6ed32082e1 修正HttpDispose
修正HttpDispose
2023-10-26 11:43:32 +08:00
ALEXTANG
6ee515e8c5 增加局部单位事件分发器的封装。
增加局部单位事件分发器的封装。
2023-10-26 10:28:05 +08:00
ALEXTANG
b839afa76a 释放资源判断资源是否有效、支持YooAssets日志重定向
释放资源判断资源是否有效、支持YooAssets日志重定向
2023-10-26 00:22:02 +08:00
Weekend
d9605b348a 修复UILoopListWidget赋值问题 2023-10-25 22:34:02 +08:00
Weekend
dfef83919c 修复UIListBase和UIUILoopListWidget赋值问题 2023-10-25 22:18:57 +08:00
ALEXTANG
f5f983f220 移除资源模块加载场景,加载场景统一走场景管理模块。增加场景加载进度回调。
移除资源模块加载场景,加载场景统一走场景管理模块。增加场景加载进度回调。
2023-10-23 17:01:06 +08:00
ALEXTANG
d61b1206ee 通过CommandLineReader可以不前台开启Unity实现静默打包,详见CommandLineReader.cs example1
通过CommandLineReader可以不前台开启Unity实现静默打包,详见CommandLineReader.cs example1
2023-10-23 15:22:34 +08:00
ALEXTANG
3650ba1a8b 更新转表bat自动拷贝ConfigSystem
更新转表bat自动拷贝ConfigSystem
2023-10-23 13:00:40 +08:00
ALEXTANG
8f14a4d2cb 日志重定向相关的实用函数。
日志重定向相关的实用函数。
2023-10-23 11:41:44 +08:00
ALEXTANG
dc22e595c9 拓展支持AssetInspector,支持更多文件类型在Inspector显示
拓展支持AssetInspector,支持更多文件类型在Inspector显示
2023-10-23 11:41:33 +08:00
ALEXTANG
0e70f7d446 日志重定向相关的实用函数。
日志重定向相关的实用函数。
2023-10-23 11:27:06 +08:00
ALEXTANG
039569b2d4 提交配置表加载模板
提交配置表加载模板
2023-10-23 10:15:11 +08:00
ALEXTANG
ea38004ba2 luban-next支持懒加载 感谢半仙儿提供支持
luban-next支持懒加载 感谢半仙儿提供支持
2023-10-20 16:24:00 +08:00
ALEXTANG
cc97c0583a 升级luban-next
升级luban-next
2023-10-20 11:53:29 +08:00
ALEXTANG
887094a4b1 升级luban-next
升级luban-next
2023-10-20 11:38:51 +08:00
ALEXTANG
0d09a7e73b 增加场景管理模块。
增加场景管理模块。
2023-10-18 16:42:44 +08:00
ALEXTANG
d8f8514f9d WebGL下不对YooAssets.Destroy();
WebGL下不对YooAssets.Destroy();
2023-10-18 11:23:20 +08:00
ALEXTANG
f2f6b2422f 资源模块优化、UI模块优化,增加接口参数是否使用缓存资源操作句柄。
资源模块优化、UI模块优化,增加接口参数是否使用缓存资源操作句柄、如果需要则不会淘汰缓存队列中的资源清单。
2023-10-18 10:30:12 +08:00
ALEXTANG
3a9cad9397 Update ResourceManager.cs 2023-10-16 16:38:13 +08:00
125 changed files with 4771 additions and 2289 deletions

View File

@@ -1,61 +0,0 @@
using Bright.Serialization;
using GameBase;
using GameConfig;
using TEngine;
using UnityEngine;
/// <summary>
/// 配置加载器。
/// </summary>
public class ConfigSystem : Singleton<ConfigSystem>
{
private bool _init = false;
private Tables _tables;
public Tables Tables
{
get
{
if (!_init)
{
Load();
}
return _tables;
}
}
/// <summary>
/// 加载配置。
/// </summary>
public void Load()
{
_tables = new Tables(LoadIdxByteBuf, LoadByteBuf);
_init = true;
}
/// <summary>
/// 加载二进制配置。
/// </summary>
/// <param name="file">FileName</param>
/// <returns>ByteBuf</returns>
private ByteBuf LoadByteBuf(string file)
{
var textAssets = GameModule.Resource.LoadAsset<TextAsset>(file);
byte[] ret = textAssets.bytes;
return new ByteBuf(ret);
}
/// <summary>
/// 加载懒加载Index。
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
private ByteBuf LoadIdxByteBuf(string file)
{
var textAssets = GameModule.Resource.LoadAsset<TextAsset>($"Idx_{file}");
byte[] ret = textAssets.bytes;
return new ByteBuf(ret);
}
}

View File

@@ -1,87 +0,0 @@
using Bright.Serialization;
using System.Collections.Generic;
{{
name = x.name
parent_def_type = x.parent_def_type
export_fields = x.export_fields
hierarchy_export_fields = x.hierarchy_export_fields
}}
namespace {{x.namespace_with_top_module}}
{
{{~if x.comment != '' ~}}
/// <summary>
/// {{x.escape_comment}}
/// </summary>
{{~end~}}
public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {{x.parent}} {{else}} Bright.Config.BeanBase {{end}}
{
public {{name}}(ByteBuf _buf) {{if parent_def_type}} : base(_buf) {{end}}
{
{{~ for field in export_fields ~}}
{{cs_deserialize '_buf' field.convention_name field.ctype}}
{{~if field.index_field~}}
foreach(var _v in {{field.convention_name}})
{
{{field.convention_name}}_Index.Add(_v.{{field.index_field.convention_name}}, _v);
}
{{~end~}}
{{~end~}}
PostInit();
}
public static {{name}} Deserialize{{name}}(ByteBuf _buf)
{
{{~if x.is_abstract_type~}}
switch (_buf.ReadInt())
{
{{~for child in x.hierarchy_not_abstract_children~}}
case {{child.full_name}}.__ID__: return new {{child.full_name}}(_buf);
{{~end~}}
default: throw new SerializationException();
}
{{~else~}}
return new {{x.full_name}}(_buf);
{{~end~}}
}
{{~ for field in export_fields ~}}
{{~if field.comment != '' ~}}
/// <summary>
/// {{field.escape_comment}}
/// </summary>
{{~end~}}
public {{cs_define_type field.ctype}} {{field.convention_name}} { get; private set; }
{{~if field.index_field~}}
public readonly Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}> {{field.convention_name}}_Index = new Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}>();
{{~end~}}
{{~if field.gen_ref~}}
public {{field.cs_ref_validator_define}}
{{~end~}}
{{~if (gen_datetime_mills field.ctype) ~}}
public long {{field.convention_name}}_Millis => {{field.convention_name}} * 1000L;
{{~end~}}
{{~if field.gen_text_key~}}
public {{cs_define_text_key_field field}} { get; }
{{~end~}}
{{~end~}}
{{~if !x.is_abstract_type~}}
public const int __ID__ = {{x.id}};
public override int GetTypeId() => __ID__;
{{~end~}}
public override string ToString()
{
return "{{full_name}}{ "
{{~for field in hierarchy_export_fields ~}}
+ "{{field.convention_name}}:" + {{cs_to_string field.convention_name field.ctype}} + ","
{{~end~}}
+ "}";
}
partial void PostInit();
}
}

View File

@@ -1,413 +0,0 @@
using Bright.Serialization;
using System.Collections.Generic;
using System.Linq;
namespace {{x.namespace_with_top_module}}
{
{{
name = x.name
key_type = x.key_ttype
key_type1 = x.key_ttype1
key_type2 = x.key_ttype2
value_type = x.value_ttype
}}
{{~if x.comment != '' ~}}
/// <summary>
/// {{x.escape_comment}}
/// </summary>
{{~end~}}
public partial class {{name}}
{
public static {{name}} Instance { get; private set; }
{{~if x.is_map_table ~}}
private bool _readAll = false;
private Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> _dataMap;
private List<{{cs_define_type value_type}}> _dataList;
public Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> DataMap
{
get
{
if(!_readAll)
{
ReadAll();
_readAll = true;
}
return _dataMap;
}
}
public List<{{cs_define_type value_type}}> DataList
{
get
{
if(!_readAll)
{
ReadAll();
_readAll = true;
}
return _dataList;
}
}
private Dictionary<{{cs_define_type key_type}},int> _indexMap;
public List<{{cs_define_type key_type}}> Indexes;
private System.Func<ByteBuf> _dataLoader;
private void ReadAll()
{
_dataList.Clear();
foreach(var index in Indexes)
{
var v = Get(index);
_dataMap[index] = v;
_dataList.Add(v);
}
}
public {{name}}(ByteBuf _buf, string _tbName, System.Func<string, ByteBuf> _loader)
{
Instance = this;
_dataMap = new Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}>();
_dataList = new List<{{cs_define_type value_type}}>();
_indexMap = new Dictionary<{{cs_define_type key_type}}, int>();
_dataLoader = new System.Func<ByteBuf>(() => _loader(_tbName));
for (int n = _buf.ReadSize(); n > 0; --n)
{
{{cs_define_type key_type}} key;
{{cs_deserialize '_buf' 'key' key_type}}
int index = _buf.ReadInt();
_indexMap[key] = index;
}
Indexes = _indexMap.Keys.ToList();
PostInit();
}
{{~if value_type.is_dynamic~}}
public T GetOrDefaultAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}}
{
if(_indexMap.TryGetValue(key,out var _))
{
return (T)Get(key);
}
return default(T);
}
public T GetAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => (T)Get(key);
{{~end~}}
public {{cs_define_type value_type}} this[{{cs_define_type key_type}} key] => Get(key);
public {{cs_define_type value_type}} Get({{cs_define_type key_type}} key)
{
{{cs_define_type value_type}} _v;
if(_dataMap.TryGetValue(key, out _v))
{
return _v;
}
ResetByteBuf(_indexMap[key]);
{{cs_deserialize '_buf' '_v' value_type}}
_dataMap[_v.{{x.index_field.convention_name}}] = _v;
_v.Resolve(tables);
if(_indexMap.Count == _dataMap.Count)
{
_buf = null;
}
return _v;
}
public {{cs_define_type value_type}} GetOrDefault({{cs_define_type key_type}} key)
{
if(_indexMap.TryGetValue(key,out var _))
{
return Get(key);
}
return null;
}
{{~else if x.is_list_table ~}}
private bool _readAllList = false;
private List<{{cs_define_type value_type}}> _dataList;
public List<{{cs_define_type value_type}}> DataList
{
get
{
if(!_readAllList)
{
ReadAllList();
_readAllList = true;
}
return _dataList;
}
}
private System.Func<ByteBuf> _dataLoader;
{{~if x.is_union_index~}}
private bool _readAll;
private {{cs_table_union_map_type_name x}} _dataMapUnion;
public {{cs_table_union_map_type_name x}} DataMapUnion
{
get
{
if(!_readAll)
{
ReadAll();
_readAll = true;
}
return _dataMapUnion;
}
}
private void ReadAll()
{
foreach(var index in Indexes)
{
var ({{cs_table_get_param_name_list x}}) = index;
var v = Get({{cs_table_get_param_name_list x}});
_dataMapUnion[({{cs_table_get_param_name_list x}})] = v;
}
}
private void ReadAllList()
{
_dataList.Clear();
foreach(var index in Indexes)
{
var ({{cs_table_get_param_name_list x}}) = index;
var v = Get({{cs_table_get_param_name_list x}});
_dataList.Add(v);
}
}
private Dictionary<({{cs_table_get_param_def_list x}}),int> _indexMap;
public List<({{cs_table_get_param_def_list x}})> Indexes;
{{~else if !x.index_list.empty?~}}
{{~for idx in x.index_list~}}
private bool _readAll{{idx.index_field.convention_name}} = false;
private Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> _dataMap_{{idx.index_field.name}};
public Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> DataMap_{{idx.index_field.name}}
{
get
{
if(!_readAll{{idx.index_field.convention_name}})
{
ReadAll{{idx.index_field.convention_name}}();
_readAll{{idx.index_field.convention_name}} = true;
}
return _dataMap_{{idx.index_field.name}};
}
}
{{~if for.first ~}}
private void ReadAllList()
{
_dataList.Clear();
foreach(var index in Indexes_{{idx.index_field.name}})
{
var v = GetBy{{idx.index_field.convention_name}}(index);
_dataList.Add(v);
}
}
{{~end~}}
private void ReadAll{{idx.index_field.convention_name}}()
{
foreach(var index in Indexes_{{idx.index_field.name}})
{
var v = GetBy{{idx.index_field.convention_name}}(index);
_dataMap_{{idx.index_field.name}}[index] = v;
}
}
private Dictionary<{{cs_define_type idx.type}},int> _indexMap_{{idx.index_field.name}};
public List<{{cs_define_type idx.type}}> Indexes_{{idx.index_field.name}};
{{~end~}}
{{~else~}}
private bool _readAll = false;
private Dictionary<int,int> _indexMap;
public List<int> Indexes;
private Dictionary<int, {{cs_define_type value_type}}> _dataMap;
private Dictionary<int, {{cs_define_type value_type}}> DataMap
{
get
{
if(!_readAll)
{
ReadAllList();
}
return _dataMap;
}
}
private void ReadAllList()
{
_dataList.Clear();
foreach(var index in Indexes)
{
var v = Get(index);
_dataList.Add(v);
}
}
{{~end~}}
public {{name}}(ByteBuf _buf, string _tbName, System.Func<string, ByteBuf> _loader)
{
Instance = this;
_dataList = new List<{{cs_define_type value_type}}>();
_dataLoader = new System.Func<ByteBuf>(()=> _loader(_tbName));
{{~if x.is_union_index~}}
_dataMapUnion = new {{cs_table_union_map_type_name x}}();
_indexMap = new Dictionary<({{cs_table_get_param_def_list x}}),int>();
{{key_value ='('}}
for (int i = _buf.ReadSize(); i > 0; i--)
{
{{~for idx in x.index_list~}}
{{field_name = 'key'+for.index}}
{{cs_define_type idx.type}} {{field_name}};
{{cs_deserialize '_buf' field_name idx.type}}
{{~if for.last~}}
{{key_value=key_value+field_name+')'}}
{{~else~}}
{{key_value=key_value+field_name+', '}}
{{~end~}}
{{~end~}}
_indexMap.Add({{key_value}}, _buf.ReadInt());
}
Indexes = _indexMap.Keys.ToList();
{{~else if !x.index_list.empty?~}}
{{~for idx in x.index_list~}}
_dataMap_{{idx.index_field.name}} = new Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}>();
_indexMap_{{idx.index_field.name}} = new Dictionary<{{cs_define_type idx.type}},int>();
{{~end~}}
int size = _buf.ReadSize();
for(int i = 0; i < size; i++)
{
{{~for idx in x.index_list~}}
{{cs_define_type idx.type}} key_{{idx.index_field.name}};
{{cs_deserialize '_buf' 'key_'+idx.index_field.name idx.type}}
{{~end~}}
int index = _buf.ReadInt();
{{~for idx in x.index_list~}}
_indexMap_{{idx.index_field.name}}.Add(key_{{idx.index_field.name}},index);
{{~end~}}
}
{{~for idx in x.index_list~}}
Indexes_{{idx.index_field.name}} = _indexMap_{{idx.index_field.name}}.Keys.ToList();
{{~end~}}
{{~else~}}
_indexMap = new Dictionary<int,int>();
_dataMap = new Dictionary<int, {{cs_define_type value_type}}>();
int size = _buf.ReadSize();
for(int i = 0; i < size; i++)
{
_indexMap.Add(i,_buf.ReadInt());
}
Indexes = _indexMap.Keys.ToList();
{{~end~}}
}
{{~if x.is_union_index~}}
public {{cs_define_type value_type}} Get({{cs_table_get_param_def_list x}})
{
{{cs_define_type value_type}} __v;
if(_dataMapUnion.TryGetValue(({{cs_table_get_param_name_list x}}), out __v))
{
return __v;
}
ResetByteBuf(_indexMap[({{cs_table_get_param_name_list x}})]);
{{cs_deserialize '_buf' '__v' value_type}}
_dataList.Add(__v);
_dataMapUnion.Add(({{cs_table_get_param_name_list x}}), __v);
__v.Resolve(tables);
if(_indexMap.Count == _dataMapUnion.Count)
{
_buf = null;
}
return __v;
}
{{~else if !x.index_list.empty? ~}}
{{~for idx in x.index_list~}}
public {{cs_define_type value_type}} GetBy{{idx.index_field.convention_name}}({{cs_define_type idx.type}} key)
{
if(_dataMap_{{idx.index_field.name}}.TryGetValue(key,out var value))
{
return value;
}
int index = _indexMap_{{idx.index_field.name}}[key];
ResetByteBuf(index);
{{cs_define_type value_type}} _v;
{{cs_deserialize '_buf' '_v' value_type}}
_dataMap_{{idx.index_field.name}}[key] = _v;
_v.Resolve(tables);
return _v;
}
{{~end~}}
{{~else if x.index_list.empty? ~}}
public {{cs_define_type value_type}} this[int index] => Get(index);
public {{cs_define_type value_type}} Get(int index)
{
{{cs_define_type value_type}} _v;
if(_dataMap.TryGetValue(index, out _v))
{
return _v;
}
ResetByteBuf(_indexMap[index]);
{{cs_deserialize '_buf' '_v' value_type}}
_dataMap[index] = _v;
_v.Resolve(tables);
if(_indexMap.Count == _dataMap.Count)
{
_buf = null;
}
return _v;
}
{{~end~}}
{{~else~}}
private {{cs_define_type value_type}} _data;
public {{name}} (ByteBuf _buf, string _tbName, System.Func<string, ByteBuf> _loader)
{
Instance = this;
ByteBuf _dataBuf = _loader(_tbName);
int n = _buf.ReadSize();
int m = _dataBuf.ReadSize();
if (n != 1 || m != 1) throw new SerializationException("table mode=one, but size != 1");
{{cs_deserialize '_dataBuf' '_data' value_type}}
}
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
{{~if field.comment != '' ~}}
/// <summary>
/// {{field.escape_comment}}
/// </summary>
{{~end~}}
public {{cs_define_type field.ctype}} {{field.convention_name}} => _data.{{field.convention_name}};
{{~if field.gen_ref~}}
public {{cs_define_type field.ref_type}} {{field.convention_name}}_Ref => _data.{{field.convention_name}}_Ref;
{{~end~}}
{{~end~}}
{{~end~}}
{{~if x.is_map_table||x.is_list_table ~}}
private void ResetByteBuf(int readerInex = 0)
{
if( _buf == null)
{
if (_buf == null)
{
_buf = _dataLoader();
}
}
_buf.ReaderIndex = readerInex;
}
{{~end~}}
{{~if x.mode != 'ONE'~}}
private ByteBuf _buf = null;
private Dictionary<string, object> tables;
{{~end~}}
public void CacheTables(Dictionary<string, object> _tables)
{
{{~if x.mode == 'ONE'~}}
_data.Resolve(_tables);
{{~else~}}
tables = _tables;
{{~end~}}
}
partial void PostInit();
}
}

View File

@@ -1,40 +0,0 @@
using Bright.Serialization;
{{
name = x.name
namespace = x.namespace
tables = x.tables
}}
namespace {{namespace}}
{
public partial class {{name}}
{
{{~for table in tables ~}}
{{~if table.comment != '' ~}}
/// <summary>
/// {{table.escape_comment}}
/// </summary>
{{~end~}}
public {{table.full_name}} {{table.name}} {get; }
{{~end~}}
public {{name}}(System.Func<string, ByteBuf> idxLoader,System.Func<string, ByteBuf> dataLoader)
{
var tables = new System.Collections.Generic.Dictionary<string, object>();
{{~for table in tables ~}}
{{table.name}} = new {{table.full_name}}(idxLoader("{{table.output_data_file}}"),"{{table.output_data_file}}",dataLoader);
tables.Add("{{table.full_name}}", {{table.name}});
{{~end~}}
PostInit();
{{~for table in tables ~}}
{{table.name}}.CacheTables(tables);
{{~end~}}
}
partial void PostInit();
}
}

View File

@@ -1,95 +0,0 @@
using System.Collections.Generic;
using System.Threading;
using Bright.Serialization;
using Cysharp.Threading.Tasks;
using GameBase;
using GameConfig;
using TEngine;
using UnityEngine;
/// <summary>
/// 配置加载器
/// </summary>
public class ConfigSystem : Singleton<ConfigSystem>
{
private bool _init = false;
private Tables _tables;
public Tables Tables
{
get
{
if (!_init)
{
#if !UNITY_WEBGL
_init = true;
#endif
Log.Error("Config not loaded. You need Take LoadAsync at first.");
}
return _tables;
}
}
private readonly Dictionary<string, TextAsset> _configs = new Dictionary<string, TextAsset>();
/// <summary>
/// 异步加载配置。
/// </summary>
public async UniTask LoadAsync()
{
_tables = new Tables();
await _tables.LoadAsync(LoadByteBufAsync);
_init = true;
}
/// <summary>
/// 异步加载二进制配置。
/// </summary>
/// <param name="file">FileName</param>
/// <returns>ByteBuf</returns>
private async UniTask<ByteBuf> LoadByteBufAsync(string file)
{
#if false
GameTickWatcher gameTickWatcher = new GameTickWatcher();
#endif
byte[] ret;
var location = file;
if (_configs.TryGetValue(location, out var config))
{
ret = config.bytes;
}
else
{
var textAssets = await GameModule.Resource.LoadAssetAsync<TextAsset>(location, CancellationToken.None);
ret = textAssets.bytes;
RegisterTextAssets(file, textAssets);
}
#if false
Log.Warning($"LoadByteBuf {file} used time {gameTickWatcher.ElapseTime()}");
#endif
return new ByteBuf(ret);
}
/// <summary>
/// 注册配置资源。
/// </summary>
/// <param name="key">资源Key。</param>
/// <param name="value">资源实例。</param>
/// <returns>注册成功。</returns>
private bool RegisterTextAssets(string key, TextAsset value)
{
if (string.IsNullOrEmpty(key))
{
return false;
}
if (value == null)
{
return false;
}
_configs[key] = value;
return true;
}
}

View File

@@ -1,115 +0,0 @@
using Bright.Serialization;
using System.Collections.Generic;
{{
name = x.name
parent_def_type = x.parent_def_type
export_fields = x.export_fields
hierarchy_export_fields = x.hierarchy_export_fields
}}
{{cs_start_name_space_grace x.namespace_with_top_module}}
{{~if x.comment != '' ~}}
/// <summary>
/// {{x.escape_comment}}
/// </summary>
{{~end~}}
public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {{x.parent}} {{else}} Bright.Config.BeanBase {{end}}
{
public {{name}}(ByteBuf _buf) {{if parent_def_type}} : base(_buf) {{end}}
{
{{~ for field in export_fields ~}}
{{cs_deserialize '_buf' field.convention_name field.ctype}}
{{~if field.index_field~}}
foreach(var _v in {{field.convention_name}})
{
{{field.convention_name}}_Index.Add(_v.{{field.index_field.convention_name}}, _v);
}
{{~end~}}
{{~end~}}
PostInit();
}
public static {{name}} Deserialize{{name}}(ByteBuf _buf)
{
{{~if x.is_abstract_type~}}
switch (_buf.ReadInt())
{
{{~for child in x.hierarchy_not_abstract_children~}}
case {{child.full_name}}.__ID__: return new {{child.full_name}}(_buf);
{{~end~}}
default: throw new SerializationException();
}
{{~else~}}
return new {{x.full_name}}(_buf);
{{~end~}}
}
{{~ for field in export_fields ~}}
{{~if field.comment != '' ~}}
/// <summary>
/// {{field.escape_comment}}
/// </summary>
{{~end~}}
public {{cs_define_type field.ctype}} {{field.convention_name}} { get; private set; }
{{~if field.index_field~}}
public readonly Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}> {{field.convention_name}}_Index = new Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}>();
{{~end~}}
{{~if field.gen_ref~}}
public {{field.cs_ref_validator_define}}
{{~end~}}
{{~if (gen_datetime_mills field.ctype) ~}}
public long {{field.convention_name}}_Millis => {{field.convention_name}} * 1000L;
{{~end~}}
{{~if field.gen_text_key~}}
public {{cs_define_text_key_field field}} { get; }
{{~end~}}
{{~end~}}
{{~if !x.is_abstract_type~}}
public const int __ID__ = {{x.id}};
public override int GetTypeId() => __ID__;
{{~end~}}
public {{x.cs_method_modifier}} void Resolve(Dictionary<string, object> _tables)
{
{{~if parent_def_type~}}
base.Resolve(_tables);
{{~end~}}
{{~ for field in export_fields ~}}
{{~if field.gen_ref~}}
{{cs_ref_validator_resolve field}}
{{~else if field.has_recursive_ref~}}
{{cs_recursive_resolve field '_tables'}}
{{~end~}}
{{~end~}}
PostResolve();
}
public {{x.cs_method_modifier}} void TranslateText(System.Func<string, string, string> translator)
{
{{~if parent_def_type~}}
base.TranslateText(translator);
{{~end~}}
{{~ for field in export_fields ~}}
{{~if field.gen_text_key~}}
{{cs_translate_text field 'translator'}}
{{~else if field.has_recursive_text~}}
{{cs_recursive_translate_text field 'translator'}}
{{~end~}}
{{~end~}}
}
public override string ToString()
{
return "{{full_name}}{ "
{{~for field in hierarchy_export_fields ~}}
+ "{{field.convention_name}}:" + {{cs_to_string field.convention_name field.ctype}} + ","
{{~end~}}
+ "}";
}
partial void PostInit();
partial void PostResolve();
}
{{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@@ -1,173 +0,0 @@
using Bright.Serialization;
using System.Collections.Generic;
{{cs_start_name_space_grace x.namespace_with_top_module}}
{{
name = x.name
key_type = x.key_ttype
key_type1 = x.key_ttype1
key_type2 = x.key_ttype2
value_type = x.value_ttype
}}
{{~if x.comment != '' ~}}
/// <summary>
/// {{x.escape_comment}}
/// </summary>
{{~end~}}
public partial class {{name}}
{
{{~if x.is_map_table ~}}
private readonly Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> _dataMap;
private readonly List<{{cs_define_type value_type}}> _dataList;
public {{name}}(ByteBuf _buf)
{
_dataMap = new Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}>();
_dataList = new List<{{cs_define_type value_type}}>();
for(int n = _buf.ReadSize() ; n > 0 ; --n)
{
{{cs_define_type value_type}} _v;
{{cs_deserialize '_buf' '_v' value_type}}
_dataList.Add(_v);
_dataMap.Add(_v.{{x.index_field.convention_name}}, _v);
}
PostInit();
}
public Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> DataMap => _dataMap;
public List<{{cs_define_type value_type}}> DataList => _dataList;
{{~if value_type.is_dynamic~}}
public T GetOrDefaultAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => _dataMap.TryGetValue(key, out var v) ? (T)v : null;
public T GetAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => (T)_dataMap[key];
{{~end~}}
public {{cs_define_type value_type}} GetOrDefault({{cs_define_type key_type}} key) => _dataMap.TryGetValue(key, out var v) ? v : null;
public {{cs_define_type value_type}} Get({{cs_define_type key_type}} key) => _dataMap[key];
public {{cs_define_type value_type}} this[{{cs_define_type key_type}} key] => _dataMap[key];
public void Resolve(Dictionary<string, object> _tables)
{
foreach(var v in _dataList)
{
v.Resolve(_tables);
}
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
foreach(var v in _dataList)
{
v.TranslateText(translator);
}
}
{{~else if x.is_list_table ~}}
private readonly List<{{cs_define_type value_type}}> _dataList;
{{~if x.is_union_index~}}
private {{cs_table_union_map_type_name x}} _dataMapUnion;
{{~else if !x.index_list.empty?~}}
{{~for idx in x.index_list~}}
private Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> _dataMap_{{idx.index_field.name}};
{{~end~}}
{{~end~}}
public {{name}}(ByteBuf _buf)
{
_dataList = new List<{{cs_define_type value_type}}>();
for(int n = _buf.ReadSize() ; n > 0 ; --n)
{
{{cs_define_type value_type}} _v;
{{cs_deserialize '_buf' '_v' value_type}}
_dataList.Add(_v);
}
{{~if x.is_union_index~}}
_dataMapUnion = new {{cs_table_union_map_type_name x}}();
foreach(var _v in _dataList)
{
_dataMapUnion.Add(({{cs_table_key_list x "_v"}}), _v);
}
{{~else if !x.index_list.empty?~}}
{{~for idx in x.index_list~}}
_dataMap_{{idx.index_field.name}} = new Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}>();
{{~end~}}
foreach(var _v in _dataList)
{
{{~for idx in x.index_list~}}
_dataMap_{{idx.index_field.name}}.Add(_v.{{idx.index_field.convention_name}}, _v);
{{~end~}}
}
{{~end~}}
PostInit();
}
public List<{{cs_define_type value_type}}> DataList => _dataList;
{{~if x.is_union_index~}}
public {{cs_define_type value_type}} Get({{cs_table_get_param_def_list x}}) => _dataMapUnion.TryGetValue(({{cs_table_get_param_name_list x}}), out {{cs_define_type value_type}} __v) ? __v : null;
{{~else if !x.index_list.empty? ~}}
{{~for idx in x.index_list~}}
public {{cs_define_type value_type}} GetBy{{idx.index_field.convention_name}}({{cs_define_type idx.type}} key) => _dataMap_{{idx.index_field.name}}.TryGetValue(key, out {{cs_define_type value_type}} __v) ? __v : null;
{{~end~}}
{{~end~}}
public void Resolve(Dictionary<string, object> _tables)
{
foreach(var v in _dataList)
{
v.Resolve(_tables);
}
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
foreach(var v in _dataList)
{
v.TranslateText(translator);
}
}
{{~else~}}
private readonly {{cs_define_type value_type}} _data;
public {{name}}(ByteBuf _buf)
{
int n = _buf.ReadSize();
if (n != 1) throw new SerializationException("table mode=one, but size != 1");
{{cs_deserialize '_buf' '_data' value_type}}
PostInit();
}
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
{{~if field.comment != '' ~}}
/// <summary>
/// {{field.escape_comment}}
/// </summary>
{{~end~}}
public {{cs_define_type field.ctype}} {{field.convention_name}} => _data.{{field.convention_name}};
{{~end~}}
public void Resolve(Dictionary<string, object> _tables)
{
_data.Resolve(_tables);
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
_data.TranslateText(translator);
}
{{~end~}}
partial void PostInit();
partial void PostResolve();
}
{{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@@ -1,53 +0,0 @@
using Bright.Serialization;
using Cysharp.Threading.Tasks;
using System.Collections.Generic;
{{
name = x.name
namespace = x.namespace
tables = x.tables
}}
namespace {{namespace}}
{
public sealed class {{name}}
{
{{~for table in tables ~}}
{{~if table.comment != '' ~}}
/// <summary>
/// {{table.escape_comment}}
/// </summary>
{{~end~}}
public {{table.full_name}} {{table.name}} {get; private set; }
{{~end~}}
public {{name}}() { }
public async UniTask LoadAsync(System.Func<string, UniTask<ByteBuf>> loader)
{
var tables = new System.Collections.Generic.Dictionary<string, object>();
List<UniTask> list = new List<UniTask>();
{{~for table in tables ~}}
list.Add(UniTask.Create(async () =>
{
{{table.name}} = new {{table.full_name}}(await loader("{{table.output_data_file}}"));
tables.Add("{{table.full_name}}", {{table.name}});
}));
{{~end~}}
await UniTask.WhenAll(list);
{{~for table in tables ~}}
{{table.name}}.Resolve(tables);
{{~end~}}
}
public void TranslateText(System.Func<string, string, string> translator)
{
{{~for table in tables ~}}
{{table.name}}.TranslateText(translator);
{{~end~}}
}
}
}

View File

@@ -1,115 +0,0 @@
using Bright.Serialization;
using System.Collections.Generic;
{{
name = x.name
parent_def_type = x.parent_def_type
export_fields = x.export_fields
hierarchy_export_fields = x.hierarchy_export_fields
}}
{{cs_start_name_space_grace x.namespace_with_top_module}}
{{~if x.comment != '' ~}}
/// <summary>
/// {{x.escape_comment}}
/// </summary>
{{~end~}}
public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {{x.parent}} {{else}} Bright.Config.BeanBase {{end}}
{
public {{name}}(ByteBuf _buf) {{if parent_def_type}} : base(_buf) {{end}}
{
{{~ for field in export_fields ~}}
{{cs_deserialize '_buf' field.convention_name field.ctype}}
{{~if field.index_field~}}
foreach(var _v in {{field.convention_name}})
{
{{field.convention_name}}_Index.Add(_v.{{field.index_field.convention_name}}, _v);
}
{{~end~}}
{{~end~}}
PostInit();
}
public static {{name}} Deserialize{{name}}(ByteBuf _buf)
{
{{~if x.is_abstract_type~}}
switch (_buf.ReadInt())
{
{{~for child in x.hierarchy_not_abstract_children~}}
case {{child.full_name}}.__ID__: return new {{child.full_name}}(_buf);
{{~end~}}
default: throw new SerializationException();
}
{{~else~}}
return new {{x.full_name}}(_buf);
{{~end~}}
}
{{~ for field in export_fields ~}}
{{~if field.comment != '' ~}}
/// <summary>
/// {{field.escape_comment}}
/// </summary>
{{~end~}}
public {{cs_define_type field.ctype}} {{field.convention_name}} { get; private set; }
{{~if field.index_field~}}
public readonly Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}> {{field.convention_name}}_Index = new Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}>();
{{~end~}}
{{~if field.gen_ref~}}
public {{field.cs_ref_validator_define}}
{{~end~}}
{{~if (gen_datetime_mills field.ctype) ~}}
public long {{field.convention_name}}_Millis => {{field.convention_name}} * 1000L;
{{~end~}}
{{~if field.gen_text_key~}}
public {{cs_define_text_key_field field}} { get; }
{{~end~}}
{{~end~}}
{{~if !x.is_abstract_type~}}
public const int __ID__ = {{x.id}};
public override int GetTypeId() => __ID__;
{{~end~}}
public {{x.cs_method_modifier}} void Resolve(Dictionary<string, object> _tables)
{
{{~if parent_def_type~}}
base.Resolve(_tables);
{{~end~}}
{{~ for field in export_fields ~}}
{{~if field.gen_ref~}}
{{cs_ref_validator_resolve field}}
{{~else if field.has_recursive_ref~}}
{{cs_recursive_resolve field '_tables'}}
{{~end~}}
{{~end~}}
PostResolve();
}
public {{x.cs_method_modifier}} void TranslateText(System.Func<string, string, string> translator)
{
{{~if parent_def_type~}}
base.TranslateText(translator);
{{~end~}}
{{~ for field in export_fields ~}}
{{~if field.gen_text_key~}}
{{cs_translate_text field 'translator'}}
{{~else if field.has_recursive_text~}}
{{cs_recursive_translate_text field 'translator'}}
{{~end~}}
{{~end~}}
}
public override string ToString()
{
return "{{full_name}}{ "
{{~for field in hierarchy_export_fields ~}}
+ "{{field.convention_name}}:" + {{cs_to_string field.convention_name field.ctype}} + ","
{{~end~}}
+ "}";
}
partial void PostInit();
partial void PostResolve();
}
{{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@@ -1,173 +0,0 @@
using Bright.Serialization;
using System.Collections.Generic;
{{cs_start_name_space_grace x.namespace_with_top_module}}
{{
name = x.name
key_type = x.key_ttype
key_type1 = x.key_ttype1
key_type2 = x.key_ttype2
value_type = x.value_ttype
}}
{{~if x.comment != '' ~}}
/// <summary>
/// {{x.escape_comment}}
/// </summary>
{{~end~}}
public partial class {{name}}
{
{{~if x.is_map_table ~}}
private readonly Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> _dataMap;
private readonly List<{{cs_define_type value_type}}> _dataList;
public {{name}}(ByteBuf _buf)
{
_dataMap = new Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}>();
_dataList = new List<{{cs_define_type value_type}}>();
for(int n = _buf.ReadSize() ; n > 0 ; --n)
{
{{cs_define_type value_type}} _v;
{{cs_deserialize '_buf' '_v' value_type}}
_dataList.Add(_v);
_dataMap.Add(_v.{{x.index_field.convention_name}}, _v);
}
PostInit();
}
public Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> DataMap => _dataMap;
public List<{{cs_define_type value_type}}> DataList => _dataList;
{{~if value_type.is_dynamic~}}
public T GetOrDefaultAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => _dataMap.TryGetValue(key, out var v) ? (T)v : null;
public T GetAs<T>({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => (T)_dataMap[key];
{{~end~}}
public {{cs_define_type value_type}} GetOrDefault({{cs_define_type key_type}} key) => _dataMap.TryGetValue(key, out var v) ? v : null;
public {{cs_define_type value_type}} Get({{cs_define_type key_type}} key) => _dataMap[key];
public {{cs_define_type value_type}} this[{{cs_define_type key_type}} key] => _dataMap[key];
public void Resolve(Dictionary<string, object> _tables)
{
foreach(var v in _dataList)
{
v.Resolve(_tables);
}
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
foreach(var v in _dataList)
{
v.TranslateText(translator);
}
}
{{~else if x.is_list_table ~}}
private readonly List<{{cs_define_type value_type}}> _dataList;
{{~if x.is_union_index~}}
private {{cs_table_union_map_type_name x}} _dataMapUnion;
{{~else if !x.index_list.empty?~}}
{{~for idx in x.index_list~}}
private Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> _dataMap_{{idx.index_field.name}};
{{~end~}}
{{~end~}}
public {{name}}(ByteBuf _buf)
{
_dataList = new List<{{cs_define_type value_type}}>();
for(int n = _buf.ReadSize() ; n > 0 ; --n)
{
{{cs_define_type value_type}} _v;
{{cs_deserialize '_buf' '_v' value_type}}
_dataList.Add(_v);
}
{{~if x.is_union_index~}}
_dataMapUnion = new {{cs_table_union_map_type_name x}}();
foreach(var _v in _dataList)
{
_dataMapUnion.Add(({{cs_table_key_list x "_v"}}), _v);
}
{{~else if !x.index_list.empty?~}}
{{~for idx in x.index_list~}}
_dataMap_{{idx.index_field.name}} = new Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}>();
{{~end~}}
foreach(var _v in _dataList)
{
{{~for idx in x.index_list~}}
_dataMap_{{idx.index_field.name}}.Add(_v.{{idx.index_field.convention_name}}, _v);
{{~end~}}
}
{{~end~}}
PostInit();
}
public List<{{cs_define_type value_type}}> DataList => _dataList;
{{~if x.is_union_index~}}
public {{cs_define_type value_type}} Get({{cs_table_get_param_def_list x}}) => _dataMapUnion.TryGetValue(({{cs_table_get_param_name_list x}}), out {{cs_define_type value_type}} __v) ? __v : null;
{{~else if !x.index_list.empty? ~}}
{{~for idx in x.index_list~}}
public {{cs_define_type value_type}} GetBy{{idx.index_field.convention_name}}({{cs_define_type idx.type}} key) => _dataMap_{{idx.index_field.name}}.TryGetValue(key, out {{cs_define_type value_type}} __v) ? __v : null;
{{~end~}}
{{~end~}}
public void Resolve(Dictionary<string, object> _tables)
{
foreach(var v in _dataList)
{
v.Resolve(_tables);
}
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
foreach(var v in _dataList)
{
v.TranslateText(translator);
}
}
{{~else~}}
private readonly {{cs_define_type value_type}} _data;
public {{name}}(ByteBuf _buf)
{
int n = _buf.ReadSize();
if (n != 1) throw new SerializationException("table mode=one, but size != 1");
{{cs_deserialize '_buf' '_data' value_type}}
PostInit();
}
{{~ for field in value_type.bean.hierarchy_export_fields ~}}
{{~if field.comment != '' ~}}
/// <summary>
/// {{field.escape_comment}}
/// </summary>
{{~end~}}
public {{cs_define_type field.ctype}} {{field.convention_name}} => _data.{{field.convention_name}};
{{~end~}}
public void Resolve(Dictionary<string, object> _tables)
{
_data.Resolve(_tables);
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
_data.TranslateText(translator);
}
{{~end~}}
partial void PostInit();
partial void PostResolve();
}
{{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@@ -1,46 +0,0 @@
using Bright.Serialization;
using System.Threading.Tasks;
{{
name = x.name
namespace = x.namespace
tables = x.tables
}}
namespace {{namespace}}
{
public sealed class {{name}}
{
{{~for table in tables ~}}
{{~if table.comment != '' ~}}
/// <summary>
/// {{table.escape_comment}}
/// </summary>
{{~end~}}
public {{table.full_name}} {{table.name}} {get; private set; }
{{~end~}}
public {{name}}() { }
public async Task LoadAsync(System.Func<string, Task<ByteBuf>> loader)
{
var tables = new System.Collections.Generic.Dictionary<string, object>();
{{~for table in tables ~}}
{{table.name}} = new {{table.full_name}}(await loader("{{table.output_data_file}}"));
tables.Add("{{table.full_name}}", {{table.name}});
{{~end~}}
{{~for table in tables ~}}
{{table.name}}.Resolve(tables);
{{~end~}}
}
public void TranslateText(System.Func<string, string, string> translator)
{
{{~for table in tables ~}}
{{table.name}}.TranslateText(translator);
{{~end~}}
}
}
}

View File

@@ -1,36 +0,0 @@
<module name="Battle">
<enum name="ActorAttrDataType">
<var name="None" alias="无效数据" value="0"/>
<var name="MaxHp" alias="最大血量" value="1"/>
<var name="Attack" alias="攻击力" value="2"/>
<var name="PhyDamage" alias="物理伤害" value="3"/>
<var name="PhyDef" alias="物理防御" value="4"/>
<var name="MagicDamage" alias="法术伤害" value="5"/>
<var name="MagicDef" alias="法术防御" value="6"/>
<var name="MoveSpeed" alias="移动速度" value="7"/>
<var name="AttackSpeed" alias="攻击速度" value="8"/>
<var name="Hit" alias="命中率" value="9"/>
<var name="Dodge" alias="闪避率" value="10"/>
<var name="CriticalAtkRatio" alias="暴击率" value="11"/>
<var name="SanValue" alias="San值(疯狂值)" value="12"/>
<var name="MaxMp" alias="最大MP" value="13"/>
<var name="PhyDamageRatio" alias="物理伤害倍率" value="14"/>
<var name="MagicDamageRatio" alias="魔法伤害倍率" value="15"/>
<var name="CriticalRatio" alias="暴击倍率" value="16"/>
<var name="CriticalReduce" alias="暴击减免" value="17"/>
</enum>
<enum name="ActorAttrAddType">
<var name="NONE" alias="无效数据" value="0"/>
<var name="ABSOLUTE_VAL" alias="加法计算" value="1"/>
<var name="SUM_PERCENT_VAL" alias="多个项结果累加,然后对加法做乘法" value="2"/>
<var name="MUL_PERCENT_VAL" alias="每一项都是对最终结果做乘法" value="3"/>
</enum>
<bean name="ResAttrImpactData" sep="," parent="">
<var name="DataType" type="ActorAttrDataType"/>
<var name="AddType" type="ActorAttrAddType"/>
<var name="Value" type="float"/>
</bean>
</module>

View File

@@ -1,68 +0,0 @@
<module name="Battle">
<enum name="BuffTimeType">
<var name="BUFF_TIME_DURING" alias="指定持续时间" value="0"/>
<var name="BUFF_TIME_INFINIT" alias="无尽时间" value="1"/>
</enum>
<enum name="BuffReplaceType">
<var name="BUFF_REPLACE_INSTEAD" alias="更新时间范围" value="0"/>
<var name="BUFF_REPLACE_FORBIT" alias="不允许叠加" value="1"/>
<var name="BUFF_REPLACE_ADD_TIME" alias="累加时间范围" value="2"/>
<var name="BUFF_REPLACE_ADD_ATTR" alias="叠加数值" value="3"/>
<var name="BUFF_REPLACE_TYPE_COUNT" alias="叠加种类" value="4"/>
</enum>
<enum name="BuffStateID">
<var name="BUFF_STATE_NONE" alias="无状态" value="0"/>
<var name="BUFF_STATE_STUN" alias="眩晕状态" value="1"/>
<var name="BUFF_STATE_UNDEAD" alias="无敌状态" value="2"/>
<var name="BUFF_STATE_INVISIBLE" alias="隐身状态" value="3"/>
<var name="BUFF_STATE_BIGGER" alias="体形变大" value="4"/>
<var name="BUFF_STATE_NO_MOVE" alias="定身,不能移动" value="5"/>
<var name="BUFF_STATE_NO_SKILL" alias="沉默,不能放技能" value="6"/>
<var name="BUFF_STATE_SLEEP" alias="昏睡" value="7"/>
<var name="BUFF_STATE_FORCE_COLLIDER" alias="强制开启阻挡" value="8"/>
<var name="BUFF_STATE_IGNORE_COLLIDER" alias="无视阻挡" value="9"/>
<var name="BUFF_STATE_MAX" alias="最大状态" value="10"/>
</enum>
<enum name="BuffResultType">
<var name="BUFF_RESULT_NONE" alias="无" value="0"/>
<var name="BUFF_RESULT_PHY_ATK_UP" alias="物理攻击提升" value="1"/>
<var name="BUFF_RESULT_PHY_ATK_DOWN" alias="物理攻击降低" value="2"/>
<var name="BUFF_RESULT_PHY_DEF_UP" alias="物理防御提升" value="3"/>
<var name="BUFF_RESULT_PHY_DEF_DOWN" alias="物理防御降低" value="4"/>
<var name="BUFF_RESULT_PHY_HIT_UP" alias="物理命中提升" value="5"/>
<var name="BUFF_RESULT_PHY_HIT_DOWN" alias="物理命中降低" value="6"/>
<var name="BUFF_RESULT_PHY_LOSE_HP" alias="物理持续掉血" value="7"/>
<var name="BUFF_RESULT_MAG_ATK_UP" alias="法术攻击提升" value="8"/>
<var name="BUFF_RESULT_MAG_ATK_DOWN" alias="法术攻击降低" value="9"/>
<var name="BUFF_RESULT_MAG_DEF_UP" alias="法术防御提升" value="10"/>
<var name="BUFF_RESULT_MAG_DEF_DOWN" alias="法术防御降低" value="11"/>
<var name="BUFF_RESULT_MAG_HIT_UP" alias="法术命中提升" value="12"/>
<var name="BUFF_RESULT_MAG_HIT_DOWN" alias="法术命中降低" value="13"/>
<var name="BUFF_RESULT_MAG_LOSE_HP" alias="法术持续掉血" value="14"/>
<var name="BUFF_RESULT_CIRT_UP" alias="暴击率提升" value="15"/>
<var name="BUFF_RESULT_CIRT_DOWN" alias="暴击率降低" value="16"/>
<var name="BUFF_RESULT_CIRT_VALUE_UP" alias="暴击倍率提升" value="17"/>
<var name="BUFF_RESULT_CIRT_VALUE_DOWN" alias="暴击倍率降低" value="18"/>
<var name="BUFF_RESULT_MOVE_SPEED_UP" alias="移速提升" value="19"/>
<var name="BUFF_RESULT_MOVE_SPEED_DOWN" alias="移速降低" value="20"/>
</enum>
<bean name="BuffTriggleState" sep="," parent="">
<var name="StateID" type="BuffStateID"/>
<var name="StateParam" type="float"/>
</bean>
<bean name="BuffDotTickConfig" sep="," parent="">
<!-- 触发间隔,如果为0, 则只加一次 -->
<var name="TickTime" type="float"/>
<!-- 1增加buff的时候立刻触发,否则等待TickTime后再触发 -->
<var name="TickWhenAdd" type="int"/>
</bean>
</module>

View File

@@ -1,25 +0,0 @@
<module name="Battle">
<enum name="SkillMagicType"> 技能元素类型
<var name="SKILL_TYPE_NONE" alias="无类型" value="0"/>
<var name="SKILL_TYPE_DMG_PHY" alias="物理伤害属性" value="1"/>
<var name="SKILL_TYPE_DMG_MAGIC" alias="魔法伤害属性" value="2"/>
</enum>
<enum name="SkillAttrDamageType"> 伤害类型
<var name="ATTR_TYPE_NONE" alias="无数值" value="0"/>
<var name="ATTR_TYPE_DMG_WEAPON" alias="按释放者的伤害类型*X%+固定值计算,目标有防御计算" value="1"/>
<var name="ATTR_TYPE_DMG_NO_DEFEND" alias="按释放者的伤害类型*X%+固定值计算(无视目标的防御)" value="2"/>
<var name="ATTR_TYPE_DMG_TARGET_HP_NO_DEFEND" alias="按受击者的气血上限*X%+固定值计算(无视目标的防御)" value="3"/>
<var name="ATTR_TYPE_HP_AS_ATK" alias="按释放者的攻击类型*X%+固定值计算,恢复当前生命" value="4"/>
<var name="ATTR_TYPE_HP_RATIO" alias="按受击者的HP上限*X%+固定值计算,恢复当前生命" value="5"/>
</enum>
<bean name="SkillAttrDamageData" sep="," parent="">
<var name="MagicType" type="SkillMagicType"/>
<var name="AttrType" type="SkillAttrDamageType"/>
<var name="Param1" type="float"/>
<var name="Param2" type="float"/>
<var name="Param3" type="float"/>
<var name="MaxLimit" type="float"/>
</bean>
</module>

View File

@@ -1,23 +0,0 @@
<root>
<topmodule name="GameConfig"/>
<externalselector name="unity"/>
<patch name="cn"/>
<patch name="en"/>
<group name="c,client" default="1"/> client
<group name="s,server" default="1"/> server
<group name="e" default="1"/> editor
<import name="."/>
<importexcel name="__tables__.xlsx" type="table"/> 相对data目录
<importexcel name="__enums__.xlsx" type="enum"/>相对data目录
<importexcel name="__beans__.xlsx" type="bean"/>相对data目录
<service name="server" manager="Tables" group="s"/>
<service name="client" manager="Tables" group="c"/>
<service name="all" manager="Tables" group="c,s,e"/>
</root>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
using Bright.Serialization;
using Luban;
using GameBase;
using GameConfig;
using TEngine;
@@ -21,6 +21,7 @@ public class ConfigSystem : Singleton<ConfigSystem>
{
Load();
}
return _tables;
}
}

View File

@@ -0,0 +1,55 @@
using Luban;
{{namespace_with_grace_begin __namespace}}
public partial class {{__name}}
{
#region The Tables
{{~for table in __tables ~}}
{{~if table.comment != '' ~}}
/// <summary>
/// {{escape_comment table.comment}}
/// </summary>
{{~end~}}
private {{table.full_name}} m_{{table.name}};
public {{table.full_name}} {{format_property_name __code_style table.name}}
{
get
{
if (m_{{table.name}} == null)
{
m_{{table.name}} = new {{table.full_name}}(defaultLoader("{{table.output_data_file}}"));
m_{{table.name}}.ResolveRef(this);
}
return m_{{table.name}};
}
set
{
m_{{table.name}} = value;
m_{{table.name}}.ResolveRef(this);
}
}
{{~end~}}
#endregion
System.Func<string, ByteBuf> defaultLoader;
public {{__name}}(System.Func<string, ByteBuf> loader)
{
SetDefaultLoader(loader);
Init();
}
public void SetDefaultLoader(System.Func<string, ByteBuf> loader)
{
defaultLoader = null;
defaultLoader = loader;
}
//public partial void Init();
public void Init(){}
}
{{namespace_with_grace_end __namespace}}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,17 @@
<module name="">
<bean name="vector2" valueType="1" sep=",">
<var name="x" type="float"/>
<var name="y" type="float"/>
</bean>
<bean name="vector3" valueType="1" sep=",">
<var name="x" type="float"/>
<var name="y" type="float"/>
<var name="z" type="float"/>
</bean>
<bean name="vector4" valueType="1" sep=",">
<var name="x" type="float"/>
<var name="y" type="float"/>
<var name="z" type="float"/>
<var name="w" type="float"/>
</bean>
</module>

View File

@@ -0,0 +1,17 @@
set WORKSPACE=../..
set LUBAN_DLL=%WORKSPACE%\Tools\Luban\Luban.dll
set CONF_ROOT=.
set DATA_OUTPATH=%WORKSPACE%/UnityProject/Assets/AssetRaw/Configs/bytes/
set CODE_OUTPATH=%WORKSPACE%/UnityProject/Assets/GameScripts/HotFix/GameProto/GameConfig/
xcopy /s /e /i /y "%CONF_ROOT%\CustomTemplate\ConfigSystem.cs" "%WORKSPACE%\UnityProject\Assets\GameScripts\HotFix\GameProto\ConfigSystem.cs"
dotnet %LUBAN_DLL% ^
-t client ^
-c cs-bin ^
-d bin^
--conf %CONF_ROOT%\luban.conf ^
-x outputCodeDir=%CODE_OUTPATH% ^
-x outputDataDir=%DATA_OUTPATH%
pause

View File

@@ -0,0 +1,18 @@
set WORKSPACE=../..
set LUBAN_DLL=%WORKSPACE%\Tools\Luban\Luban.dll
set CONF_ROOT=.
set DATA_OUTPATH=%WORKSPACE%/UnityProject/Assets/AssetRaw/Configs/bytes/
set CODE_OUTPATH=%WORKSPACE%/UnityProject/Assets/GameScripts/HotFix/GameProto/GameConfig/
xcopy /s /e /i /y "%CONF_ROOT%\CustomTemplate\ConfigSystem.cs" "%WORKSPACE%\UnityProject\Assets\GameScripts\HotFix\GameProto\ConfigSystem.cs"
dotnet %LUBAN_DLL% ^
-t client ^
-c cs-bin ^
-d bin^
--conf %CONF_ROOT%\luban.conf ^
--customTemplateDir %CONF_ROOT%\CustomTemplate\CustomTemplate_Client_LazyLoad ^
-x outputCodeDir=%CODE_OUTPATH% ^
-x outputDataDir=%DATA_OUTPATH%
pause

View File

@@ -0,0 +1,15 @@
set WORKSPACE=../../
set LUBAN_DLL=%WORKSPACE%/Tools/Luban/Luban.dll
set CONF_ROOT=.
set DATA_OUTPATH=%WORKSPACE%/Server/GameConfig
set CODE_OUTPATH=%WORKSPACE%/Server/Hotfix/Config/GameConfig
dotnet %LUBAN_DLL% ^
-t server^
-c cs-bin ^
-d bin^
--conf %CONF_ROOT%\luban.conf ^
-x outputCodeDir=%CODE_OUTPATH% ^
-x outputDataDir=%DATA_OUTPATH%
pause

View File

@@ -0,0 +1,22 @@
{
"groups":
[
{"names":["c"], "default":true},
{"names":["s"], "default":true},
{"names":["e"], "default":true}
],
"schemaFiles":
[
{"fileName":"Defines", "type":""},
{"fileName":"Datas/__tables__.xlsx", "type":"table"},
{"fileName":"Datas/__beans__.xlsx", "type":"bean"},
{"fileName":"Datas/__enums__.xlsx", "type":"enum"}
],
"dataDir": "Datas",
"targets":
[
{"name":"server", "manager":"Tables", "groups":["s"], "topModule":"GameConfig"},
{"name":"client", "manager":"Tables", "groups":["c"], "topModule":"GameConfig"},
{"name":"all", "manager":"Tables", "groups":["c,s,e"], "topModule":"GameConfig"}
]
}

View File

@@ -1,21 +0,0 @@
cd /d %~dp0
set WORKSPACE=..
set GEN_CLIENT=%WORKSPACE%\Tools\Luban.ClientServer\Luban.ClientServer.exe
set CONF_ROOT=%WORKSPACE%\Configs
set DATA_OUTPUT=%ROOT_PATH%..\GenerateDatas
set CUSTOM_TEMP=%WORKSPACE%\Configs\CustomTemplate\CustomTemplate_Client
xcopy %CUSTOM_TEMP%\ConfigSystem.cs %WORKSPACE%\UnityProject\Assets\GameScripts\HotFix\GameProto\ConfigSystem.cs /s /e /i /y
%GEN_CLIENT% -j cfg --^
-d %CONF_ROOT%\Defines\__root__.xml ^
--input_data_dir %CONF_ROOT%\Excels^
--output_code_dir %WORKSPACE%/UnityProject/Assets/GameScripts/HotFix/GameProto/GameConfig ^
--output_data_dir %WORKSPACE%/UnityProject/Assets/AssetRaw/Configs/bytes/ ^
--gen_types code_cs_unity_bin,data_bin ^
-s client
echo ======== 生成配置文件结束 ========
pause

View File

@@ -1,40 +0,0 @@
cd /d %~dp0
set WORKSPACE=..
set GEN_CLIENT=%WORKSPACE%\Tools\Luban.ClientServer\Luban.ClientServer.exe
set CONF_ROOT=%WORKSPACE%\Configs
set DATA_OUTPUT=%ROOT_PATH%..\GenerateDatas
set CUSTOM_TEMP=%WORKSPACE%\Configs\CustomTemplate\CustomTemplate_Client_LazyLoad
xcopy %CUSTOM_TEMP%\ConfigSystem.cs %WORKSPACE%\UnityProject\Assets\GameScripts\HotFix\GameProto\ConfigSystem.cs /s /e /i /y
%GEN_CLIENT% --template_search_path %CONF_ROOT%\CustomTemplate\CustomTemplate_Client_LazyLoad -j cfg --^
-d %CONF_ROOT%\Defines\__root__.xml ^
--input_data_dir %CONF_ROOT%\Excels^
--output_code_dir %WORKSPACE%/UnityProject/Assets/GameScripts/HotFix/GameProto/GameConfig ^
--output_data_dir %WORKSPACE%/UnityProject/Assets/AssetRaw/Configs/bytes/ ^
--gen_types data_bin ^
-s client
%GEN_CLIENT% --template_search_path %CONF_ROOT%\CustomTemplate\CustomTemplate_Client_LazyLoad -j cfg --^
-d %CONF_ROOT%\Defines\__root__.xml ^
--input_data_dir %CONF_ROOT%\Excels^
--output_code_dir %WORKSPACE%/UnityProject/Assets/GameScripts/HotFix/GameProto/GameConfig ^
--output_data_dir ..\GenerateDatas\bidx ^
--gen_types code_cs_unity_bin,data_bidx ^
-s client
echo ======== 生成配置文件结束 ========
set WORKSPACE=..
set "prefix=Idx_"
for %%a in (%DATA_OUTPUT%\bidx\*) do (
ren "%%a" "Idx_%%~nxa"
)
echo ======== 所有文件已添加前缀 ========
xcopy %DATA_OUTPUT%\bidx\ %WORKSPACE%\UnityProject\Assets\AssetRaw\Configs\bidx\ /s /e /i /y
pause

View File

@@ -1,21 +0,0 @@
cd /d %~dp0
set WORKSPACE=..
set GEN_CLIENT=%WORKSPACE%\Tools\Luban.ClientServer\Luban.ClientServer.exe
set CONF_ROOT=%WORKSPACE%\Configs
set DATA_OUTPUT=%ROOT_PATH%..\GenerateDatas
set CUSTOM_TEMP=%WORKSPACE%\Configs\CustomTemplate\CustomTemplate_Client_UniTask
xcopy %CUSTOM_TEMP%\ConfigSystem.cs %WORKSPACE%\UnityProject\Assets\GameScripts\HotFix\GameProto\ConfigSystem.cs /s /e /i /y
%GEN_CLIENT% --template_search_path %CONF_ROOT%\CustomTemplate\CustomTemplate_Client_UniTask -j cfg --^
-d %CONF_ROOT%\Defines\__root__.xml ^
--input_data_dir %CONF_ROOT%\Excels^
--output_code_dir %WORKSPACE%/UnityProject/Assets/GameScripts/HotFix/GameProto/GameConfig ^
--output_data_dir %WORKSPACE%/UnityProject/Assets/AssetRaw/Configs/bytes/ ^
--gen_types code_cs_unity_bin,data_bin ^
-s client
echo ======== 生成配置文件结束 ========
pause

View File

@@ -1,18 +0,0 @@
cd /d %~dp0
set WORKSPACE=..
set GEN_CLIENT=%WORKSPACE%\Tools\Luban.ClientServer\Luban.ClientServer.exe
set CONF_ROOT=%WORKSPACE%\Configs
set DATA_OUTPUT=%ROOT_PATH%..\GenerateDatas
%GEN_CLIENT% --template_search_path %CONF_ROOT%\CustomTemplate\CustomTemplate_Server_Task -j cfg --^
-d %CONF_ROOT%\Defines\__root__.xml ^
--input_data_dir %CONF_ROOT%\Excels^
--output_code_dir %WORKSPACE%/DotNet/Logic/src/Config/GameConfig ^
--output_data_dir ..\DotNet\Config\GameConfig ^
--gen_types code_cs_bin,data_bin ^
-s server
echo ======== 生成配置文件结束 ========
pause

View File

@@ -1 +0,0 @@
目前使用luban-classic请自行导入

1
Tools/Luban/about.txt Normal file
View File

@@ -0,0 +1 @@
使用luban-next, 请前往Tools/build-luban编译或者自行导入

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using TEngine;
using UnityEngine;
namespace GameLogic
@@ -17,7 +18,7 @@ namespace GameLogic
/// <summary>
/// Item字典
/// </summary>
private Dictionary<int, TItem> m_itemCache = new Dictionary<int, TItem>();
private GameFrameworkDictionary<int, TItem> m_itemCache = new GameFrameworkDictionary<int, TItem>();
/// <summary>
/// 计算偏差后的ItemList
@@ -163,9 +164,19 @@ namespace GameLogic
m_items.Clear();
for (int i = 0; i < m_itemCache.Count; i++)
{
m_items.Add(m_itemCache[i]);
m_items.Add(m_itemCache.GetValueByIndex(i));
}
return m_items;
}
/// <summary>
/// 获取Item。
/// </summary>
/// <param name="index">索引。</param>
/// <returns>TItem。</returns>
public TItem GetItemByIndex(int index)
{
return m_itemCache.GetValueByIndex(index);
}
}
}

View File

@@ -8,7 +8,7 @@ namespace GameLogic
{
public LoopListView LoopRectView { private set; get; }
private Dictionary<int, T> m_itemCache = new Dictionary<int, T>();
private GameFrameworkDictionary<int, T> m_itemCache = new GameFrameworkDictionary<int, T>();
public override void BindMemberProperty()
{
@@ -71,9 +71,8 @@ namespace GameLogic
List<T> list = new List<T>();
for (int i = 0; i < m_itemCache.Count; i++)
{
list.Add(m_itemCache[i]);
list.Add(m_itemCache.GetValueByIndex(i));
}
return list;
}
@@ -85,11 +84,11 @@ namespace GameLogic
/// <summary>
/// 获取Item。
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
/// <param name="index">索引。</param>
/// <returns>TItem。</returns>
public T GetItemByIndex(int index)
{
return m_itemCache[index];
return m_itemCache.GetValueByIndex(index);
}
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using TEngine;
using UnityEngine;
namespace GameLogic
@@ -16,8 +17,9 @@ namespace GameLogic
/// <summary>
/// Item字典
/// <remarks>Key => GameObjectHashCode | Value => TItem.</remarks>
/// </summary>
private Dictionary<int, TItem> m_itemCache = new Dictionary<int, TItem>();
private GameFrameworkDictionary<int, TItem> m_itemCache = new GameFrameworkDictionary<int, TItem>();
/// <summary>
/// 计算偏差后的ItemList
@@ -161,7 +163,7 @@ namespace GameLogic
m_items.Clear();
for (int i = 0; i < m_itemCache.Count; i++)
{
m_items.Add(m_itemCache[i]);
m_items.Add(m_itemCache.GetValueByIndex(i));
}
return m_items;
}
@@ -174,5 +176,15 @@ namespace GameLogic
{
return LoopRectView.GetItemStartIndex();
}
/// <summary>
/// 获取Item。
/// </summary>
/// <param name="index">索引。</param>
/// <returns>TItem。</returns>
public TItem GetItemByIndex(int index)
{
return m_itemCache.GetValueByIndex(index);
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 49afb8bbdbfbf014baadbaed2e2bebee
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
namespace Luban
{
public abstract class BeanBase
{
public abstract int GetTypeId();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 893ae545d065e534bbb7ec9df68e48fe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4e75cc385e3ba2a4a928b3beb7f69b13
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,7 @@
namespace Luban
{
public interface ITypeId
{
int GetTypeId();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 09af473d0f77f7f43ba793fc8c3996a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using System.Collections.Generic;
using System.Text;
namespace Luban
{
public static class StringUtil
{
public static string ToStr(object o)
{
return ToStr(o, new StringBuilder());
}
public static string ToStr(object o, StringBuilder sb)
{
foreach (var p in o.GetType().GetFields())
{
sb.Append($"{p.Name} = {p.GetValue(o)},");
}
foreach (var p in o.GetType().GetProperties())
{
sb.Append($"{p.Name} = {p.GetValue(o)},");
}
return sb.ToString();
}
public static string ArrayToString<T>(T[] arr)
{
return "[" + string.Join(",", arr) + "]";
}
public static string CollectionToString<T>(IEnumerable<T> arr)
{
return "[" + string.Join(",", arr) + "]";
}
public static string CollectionToString<TK, TV>(IDictionary<TK, TV> dic)
{
var sb = new StringBuilder('{');
foreach (var e in dic)
{
sb.Append(e.Key).Append(':');
sb.Append(e.Value).Append(',');
}
sb.Append('}');
return sb.ToString();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 353da197a63f6004ba2cbd8751e717bf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -812,7 +812,6 @@ GameObject:
- component: {fileID: 4070374929253206932}
- component: {fileID: 4872533144352319846}
- component: {fileID: 3352775805385032060}
- component: {fileID: 3859027068210555860}
m_Layer: 5
m_Name: UILoadTip
m_TagString: Untagged
@@ -880,31 +879,6 @@ MonoBehaviour:
m_BlockingMask:
serializedVersion: 2
m_Bits: 55
--- !u!114 &3859027068210555860
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7666412045263395013}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bcd11033283847ee8f7c71eedd9a4771, type: 3}
m_Name:
m_EditorClassIdentifier:
elements:
m_keys:
- m_btnUpdate
- m_btnIgnore
- m_textInfo
- m_textTittle
- m_btnPackage
m_values:
- {fileID: 2745714441875214452}
- {fileID: 467775921333773033}
- {fileID: 3862717357071106210}
- {fileID: 9127528276671758327}
- {fileID: 1387175525974173601}
--- !u!1 &8012535748721374403
GameObject:
m_ObjectHideFlags: 0

View File

@@ -773,7 +773,6 @@ GameObject:
- component: {fileID: 1633508802563447727}
- component: {fileID: 5827342734203288403}
- component: {fileID: 4835021223508371640}
- component: {fileID: 903919243524269039}
m_Layer: 5
m_Name: UILoadUpdate
m_TagString: Untagged
@@ -843,33 +842,6 @@ MonoBehaviour:
m_BlockingMask:
serializedVersion: 2
m_Bits: 55
--- !u!114 &903919243524269039
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9130266365217219149}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bcd11033283847ee8f7c71eedd9a4771, type: 3}
m_Name:
m_EditorClassIdentifier:
elements:
m_keys:
- m_imgBackGround
- m_scrollbarProgress
- m_textDesc
- m_btnClear
- m_textAppid
- m_textResid
m_values:
- {fileID: 4652061626151979521}
- {fileID: 2347891492826839465}
- {fileID: 8666815445422661327}
- {fileID: 4232232858152633415}
- {fileID: 3038352660368000718}
- {fileID: 8143980099109665604}
--- !u!1 &9157096376857424144
GameObject:
m_ObjectHideFlags: 0

View File

@@ -20,26 +20,22 @@ namespace GameMain
public MessageShowType ShowType = MessageShowType.None;
#region
private Button m_btnPackage;
private Text m_textTittle;
private Text m_textInfo;
private Button m_btnIgnore;
private Button m_btnUpdate;
public override void ScriptGenerator()
{
CheckUIElement();
m_btnPackage = FChild<Button>("m_btnPackage");
m_textTittle = FChild<Text>("m_textTittle");
m_textInfo = FChild<Text>("m_textInfo");
m_btnIgnore = FChild<Button>("m_btnIgnore");
m_btnUpdate = FChild<Button>("m_btnUpdate");
m_btnPackage = FindChildComponent<Button>("BgImage/m_btnPackage");
m_textTittle = FindChildComponent<Text>("BgImage/m_textTittle");
m_textInfo = FindChildComponent<Text>("BgImage/m_textInfo");
m_btnIgnore = FindChildComponent<Button>("BgImage/Group/m_btnIgnore");
m_btnUpdate = FindChildComponent<Button>("BgImage/Group/m_btnUpdate");
m_btnPackage.onClick.AddListener(OnClickPackageBtn);
m_btnIgnore.onClick.AddListener(OnClickIgnoreBtn);
m_btnUpdate.onClick.AddListener(OnClickUpdateBtn);
}
#endregion
#region

View File

@@ -8,22 +8,22 @@ namespace GameMain
[Window(UILayer.UI, fromResources: true, location: "AssetLoad/UILoadUpdate",fullScreen:true)]
public class UILoadUpdate : UIWindow
{
private Scrollbar m_scrollbarProgress;
#region
private Image m_imgBackGround;
private Scrollbar m_scrollbarProgress;
private Text m_textDesc;
private Button m_btnClear;
private Text m_textAppid;
private Text m_textResid;
public override void ScriptGenerator()
{
CheckUIElement();
m_imgBackGround = FChild<Image>("m_imgBackGround");
m_scrollbarProgress = FChild<Scrollbar>("m_scrollbarProgress");
m_textDesc = FChild<Text>("m_textDesc");
m_btnClear = FChild<Button>("m_btnClear");
m_textAppid = FChild<Text>("m_textAppid");
m_textResid = FChild<Text>("m_textResid");
m_imgBackGround = FindChildComponent<Image>("m_imgBackGround");
m_textDesc = FindChildComponent<Text>("m_textDesc");
m_btnClear = FindChildComponent<Button>("TopNode/m_btnClear");
m_textAppid = FindChildComponent<Text>("TopNode/m_textAppid");
m_textResid = FindChildComponent<Text>("TopNode/m_textResid");
m_scrollbarProgress = FindChildComponent<Scrollbar>("m_scrollbarProgress");
m_btnClear.onClick.AddListener(OnClickClearBtn);
}
#endregion
@@ -118,12 +118,12 @@ namespace GameMain
m_scrollbarProgress.size = progress;
}
protected override void Close()
public override void OnDestroy()
{
base.OnDestroy();
OnStop(null);
LoadUpdateLogic.Instance.DownloadCompleteAction -= DownLoad_Complete_Action;
LoadUpdateLogic.Instance.DownProgressAction -= DownLoad_Progress_Action;
base.Close();
}
}
}

View File

@@ -123,6 +123,50 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &450845952
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 450845953}
- component: {fileID: 450845954}
m_Layer: 0
m_Name: Scene
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &450845953
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 450845952}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 709048975}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &450845954
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 450845952}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 86342cc6845c403da1a3f6db507fae9d, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &553327090
GameObject:
m_ObjectHideFlags: 0
@@ -405,6 +449,7 @@ Transform:
- {fileID: 1666908677}
- {fileID: 1863338241}
- {fileID: 914171638}
- {fileID: 450845953}
- {fileID: 1047779124}
m_Father: {fileID: 1195690679}
m_RootOrder: 0
@@ -768,6 +813,7 @@ MonoBehaviour:
milliseconds: 30
downloadingMaxNum: 3
failedTryAgain: 3
adaptiveReplacementCacheCapacity: 32
--- !u!1 &1047779123
GameObject:
m_ObjectHideFlags: 0
@@ -798,7 +844,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 709048975}
m_RootOrder: 10
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1047779125
MonoBehaviour:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1d6f43591dfb9c54fbbebda60c1210fa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using UnityEngine;
using UnityEditor;
using System.IO;
[CanEditMultipleObjects, CustomEditor(typeof(DefaultAsset), false)]
public class DefaultAssetInspector : Editor
{
private const int MaxColum = 10240;
private GUIStyle _textStyle;
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (_textStyle == null)
{
_textStyle = "ScriptText";
}
bool enabled = GUI.enabled;
GUI.enabled = true;
string assetPath = AssetDatabase.GetAssetPath(target);
if (assetPath.EndsWith(".lua") ||
assetPath.EndsWith(".properties") ||
assetPath.EndsWith(".gradle")
)
{
string luaFile = File.ReadAllText(assetPath);
string text;
if (targets.Length > 1)
{
text = Path.GetFileName(assetPath);
}
else
{
text = luaFile;
if (text.Length > MaxColum)
{
text = text.Substring(0, MaxColum) + "...\n\n<...etc...>";
}
}
Rect rect = GUILayoutUtility.GetRect(new GUIContent(text), _textStyle);
rect.x = 0f;
rect.y -= 3f;
rect.width = EditorGUIUtility.currentViewWidth + 1f;
GUI.Box(rect, text, _textStyle);
}
GUI.enabled = enabled;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 83f53d2e775d0ff449616ff946f1be55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
using UnityEngine;
using UnityEditor;
using System.IO;
[CanEditMultipleObjects, CustomEditor(typeof(TextAsset))]
public class TextAssetInspector : Editor
{
private const int MaxColum = 10240;
private GUIStyle _textStyle;
public override void OnInspectorGUI()
{
if (_textStyle == null)
{
_textStyle = "ScriptText";
}
bool enabled = GUI.enabled;
GUI.enabled = true;
string assetPath = AssetDatabase.GetAssetPath(target);
if (assetPath.EndsWith(".md")
|| assetPath.EndsWith(".xml")
|| assetPath.EndsWith(".txt")
|| assetPath.EndsWith(".html")
|| assetPath.EndsWith(".csv")
)
{
string luaFile = File.ReadAllText(assetPath);
string text;
if (base.targets.Length > 1)
{
text = Path.GetFileName(assetPath);
}
else
{
text = luaFile;
if (text.Length > MaxColum)
{
text = text.Substring(0, MaxColum) + "...\n\n<...etc...>";
}
}
Rect rect = GUILayoutUtility.GetRect(new GUIContent(text), _textStyle);
rect.x = 0f;
rect.y -= 3f;
rect.width = EditorGUIUtility.currentViewWidth + 1f;
GUI.Box(rect, text, _textStyle);
}
GUI.enabled = enabled;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ad0327765273616459117746a53a35e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: defa3b5ccfc64b0392d67db95b3c528d
timeCreated: 1698043573

View File

@@ -0,0 +1,64 @@
using UnityEditor;
using UnityEngine;
using YooAsset.Editor;
namespace TEngine
{
/// <summary>
/// 打包工具类。
/// <remarks>通过CommandLineReader可以不前台开启Unity实现静默打包详见CommandLineReader.cs example1</remarks>
/// </summary>
public static class ReleaseTools
{
public static void BuildPackage()
{
string outputRoot = CommandLineReader.GetCustomArgument("outputRoot");
BuildTarget target = BuildTarget.StandaloneWindows64;
BuildInternal(target,outputRoot);
Debug.LogWarning($"Start BuildPackage BuildTarget:{target} outputPath:{outputRoot}");
}
private static void BuildInternal(BuildTarget buildTarget,string outputRoot)
{
Debug.Log($"开始构建 : {buildTarget}");
// 构建参数
BuildParameters buildParameters = new BuildParameters();
buildParameters.StreamingAssetsRoot = AssetBundleBuilderHelper.GetDefaultStreamingAssetsRoot();
buildParameters.BuildOutputRoot = outputRoot;//AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
buildParameters.BuildTarget = buildTarget;
buildParameters.BuildPipeline = EBuildPipeline.BuiltinBuildPipeline;
buildParameters.BuildMode = EBuildMode.ForceRebuild;
buildParameters.PackageName = "DefaultPackage";
buildParameters.PackageVersion = "1.0";
buildParameters.VerifyBuildingResult = true;
buildParameters.SharedPackRule = new ZeroRedundancySharedPackRule();
buildParameters.CompressOption = ECompressOption.LZ4;
buildParameters.OutputNameStyle = EOutputNameStyle.HashName;
buildParameters.CopyBuildinFileOption = ECopyBuildinFileOption.None;
// 执行构建
AssetBundleBuilder builder = new AssetBundleBuilder();
var buildResult = builder.Run(buildParameters);
if (buildResult.Success)
{
Debug.Log($"构建成功 : {buildResult.OutputPackageDirectory}");
}
else
{
Debug.LogError($"构建失败 : {buildResult.ErrorInfo}");
}
}
// 从构建命令里获取参数示例
private static string GetBuildPackageName()
{
foreach (string arg in System.Environment.GetCommandLineArgs())
{
if (arg.StartsWith("buildPackage"))
return arg.Split("="[0])[1];
}
return string.Empty;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 336706b48f93452ea43f7272872e5451
timeCreated: 1698043593

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bf1e53a3963b4dbf8c5f139ee8d80c3d
timeCreated: 1698301726

View File

@@ -0,0 +1,45 @@
using Sirenix.OdinInspector;
using UnityEngine;
using UnityEditor;
/// <summary>
/// 自动绑定全局设置
/// </summary>
public class AutoBindGlobalSetting : ScriptableObject
{
[FolderPath]
[LabelText("默认组件代码保存路径")]
[SerializeField]
private string m_CodePath;
[LabelText("绑定代码命名空间")]
[SerializeField]
private string m_Namespace;
[LabelText("子组件名称(不会往下继续遍历)")]
[SerializeField]
private string m_WidgetName = "m_item";
public string CodePath => m_CodePath;
public string Namespace => m_Namespace;
public string WidgetName => m_WidgetName;
[MenuItem("TEngine/CreateAutoBindGlobalSetting")]
private static void CreateAutoBindGlobalSetting()
{
string[] paths = AssetDatabase.FindAssets("t:AutoBindGlobalSetting");
if (paths.Length >= 1)
{
string path = AssetDatabase.GUIDToAssetPath(paths[0]);
EditorUtility.DisplayDialog("警告", $"已存在AutoBindGlobalSetting路径:{path}", "确认");
return;
}
AutoBindGlobalSetting setting = CreateInstance<AutoBindGlobalSetting>();
AssetDatabase.CreateAsset(setting, "Assets/TEngine/ResRaw/AutoBindGlobalSetting.asset");
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3dac541dae7b4c4d8b5497057739cfb0
timeCreated: 1698304721

View File

@@ -0,0 +1,12 @@
using Sirenix.OdinInspector.Editor;
using UnityEditor;
[CustomEditor(typeof(AutoBindGlobalSetting))]
public class AutoBindGlobalSettingInspector : OdinEditor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.ApplyModifiedProperties();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 020e5781e8c44c90bfbdf2cb12441e79
timeCreated: 1698304745

View File

@@ -0,0 +1,534 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
using BindData = ComponentAutoBindTool.BindData;
using System.Reflection;
using System.IO;
[CustomEditor(typeof(ComponentAutoBindTool))]
public class ComponentAutoBindToolInspector : Editor
{
private ComponentAutoBindTool m_Target;
private SerializedProperty m_BindDatas;
private SerializedProperty m_BindComs;
private List<BindData> m_TempList = new List<BindData>();
private List<string> m_TempFiledNames = new List<string>();
private List<string> m_TempComponentTypeNames = new List<string>();
private string[] s_AssemblyNames = { "Assembly-CSharp", "TEngine.Runtime" };
private string[] m_HelperTypeNames;
private string m_HelperTypeName;
private int m_HelperTypeNameIndex;
private AutoBindGlobalSetting m_Setting;
private SerializedProperty m_Namespace;
private SerializedProperty m_ClassName;
private SerializedProperty m_CodePath;
private SerializedProperty m_IsWidget;
private void OnEnable()
{
m_Target = (ComponentAutoBindTool)target;
m_BindDatas = serializedObject.FindProperty("BindDatas");
m_BindComs = serializedObject.FindProperty("bindComponents");
m_HelperTypeNames = GetTypeNames(typeof(IAutoBindRuleHelper), s_AssemblyNames);
string[] paths = AssetDatabase.FindAssets("t:AutoBindGlobalSetting");
if (paths.Length == 0)
{
Debug.LogError("不存在AutoBindGlobalSetting");
return;
}
if (paths.Length > 1)
{
Debug.LogError("AutoBindGlobalSetting数量大于1");
return;
}
string path = AssetDatabase.GUIDToAssetPath(paths[0]);
m_Setting = AssetDatabase.LoadAssetAtPath<AutoBindGlobalSetting>(path);
m_Namespace = serializedObject.FindProperty("m_Namespace");
m_ClassName = serializedObject.FindProperty("m_ClassName");
m_CodePath = serializedObject.FindProperty("m_CodePath");
m_IsWidget = serializedObject.FindProperty("m_IsWidget");
m_Namespace.stringValue = string.IsNullOrEmpty(m_Namespace.stringValue) ? m_Setting.Namespace : m_Namespace.stringValue;
m_ClassName.stringValue = string.IsNullOrEmpty(m_ClassName.stringValue) ? m_Target.gameObject.name : m_ClassName.stringValue;
m_CodePath.stringValue = string.IsNullOrEmpty(m_CodePath.stringValue) ? m_Setting.CodePath : m_CodePath.stringValue;
serializedObject.ApplyModifiedProperties();
}
public override void OnInspectorGUI()
{
serializedObject.Update();
DrawTopButton();
DrawHelperSelect();
DrawSetting();
DrawKvData();
serializedObject.ApplyModifiedProperties();
}
/// <summary>
/// 绘制顶部按钮
/// </summary>
private void DrawTopButton()
{
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("排序"))
{
Sort();
}
if (GUILayout.Button("全部删除"))
{
RemoveAll();
}
if (GUILayout.Button("删除空引用"))
{
RemoveNull();
}
if (GUILayout.Button("自动绑定组件"))
{
AutoBindComponent();
}
if (GUILayout.Button("生成绑定代码"))
{
GenAutoBindCode();
}
EditorGUILayout.EndHorizontal();
}
/// <summary>
/// 排序
/// </summary>
private void Sort()
{
m_TempList.Clear();
foreach (BindData data in m_Target.BindDatas)
{
m_TempList.Add(new BindData(data.Name, data.BindCom, data.IsGameObject));
}
m_TempList.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.Ordinal));
m_BindDatas.ClearArray();
foreach (BindData data in m_TempList)
{
AddBindData(data.Name, data.BindCom, data.IsGameObject);
}
SyncBindComs();
}
/// <summary>
/// 全部删除
/// </summary>
private void RemoveAll()
{
m_BindDatas.ClearArray();
SyncBindComs();
}
/// <summary>
/// 删除空引用
/// </summary>
private void RemoveNull()
{
for (int i = m_BindDatas.arraySize - 1; i >= 0; i--)
{
SerializedProperty element = m_BindDatas.GetArrayElementAtIndex(i).FindPropertyRelative("BindCom");
if (element.objectReferenceValue == null)
{
m_BindDatas.DeleteArrayElementAtIndex(i);
}
}
SyncBindComs();
}
/// <summary>
/// 自动绑定组件
/// </summary>
private void AutoBindComponent()
{
m_BindDatas.ClearArray();
var transform = m_Target.transform;
Ergodic(transform, transform);
SyncBindComs();
}
private void Ergodic(Transform rootTransform, Transform currentTransform)
{
for (int i = 0; i < currentTransform.childCount; ++i)
{
Transform child = currentTransform.GetChild(i);
m_TempFiledNames.Clear();
m_TempComponentTypeNames.Clear();
if (m_Target.RuleHelper.IsValidBind(child, m_TempFiledNames, m_TempComponentTypeNames))
{
for (int index = 0; index < m_TempFiledNames.Count; index++)
{
string componentName = m_TempComponentTypeNames[index];
bool isGameObject = componentName.Equals("GameObject");
componentName = isGameObject ? "Transform" : componentName;
Component com = child.GetComponent(componentName);
if (com == null)
{
Debug.LogError($"{child.name}上不存在{componentName}的组件");
}
else
{
AddBindData(m_TempFiledNames[index], child.GetComponent(componentName), isGameObject);
}
}
}
if (!child.name.StartsWith(m_Setting.WidgetName))
{
Ergodic(rootTransform, child);
}
}
}
/// <summary>
/// 绘制辅助器选择框
/// </summary>
private void DrawHelperSelect()
{
m_HelperTypeName = m_HelperTypeNames[0];
if (m_Target.RuleHelper != null)
{
m_HelperTypeName = m_Target.RuleHelper.GetType().Name;
for (int i = 0; i < m_HelperTypeNames.Length; i++)
{
if (m_HelperTypeName == m_HelperTypeNames[i])
{
m_HelperTypeNameIndex = i;
}
}
}
else
{
IAutoBindRuleHelper helper = (IAutoBindRuleHelper)CreateHelperInstance(m_HelperTypeName, s_AssemblyNames);
m_Target.RuleHelper = helper;
}
foreach (GameObject go in Selection.gameObjects)
{
ComponentAutoBindTool autoBindTool = go.GetComponent<ComponentAutoBindTool>();
if (autoBindTool.RuleHelper == null)
{
IAutoBindRuleHelper helper = (IAutoBindRuleHelper)CreateHelperInstance(m_HelperTypeName, s_AssemblyNames);
autoBindTool.RuleHelper = helper;
}
}
int selectedIndex = EditorGUILayout.Popup("AutoBindRuleHelper", m_HelperTypeNameIndex, m_HelperTypeNames);
if (selectedIndex != m_HelperTypeNameIndex)
{
m_HelperTypeNameIndex = selectedIndex;
m_HelperTypeName = m_HelperTypeNames[selectedIndex];
IAutoBindRuleHelper helper = (IAutoBindRuleHelper)CreateHelperInstance(m_HelperTypeName, s_AssemblyNames);
m_Target.RuleHelper = helper;
}
}
/// <summary>
/// 绘制设置项
/// </summary>
private void DrawSetting()
{
EditorGUILayout.BeginHorizontal();
m_Namespace.stringValue = EditorGUILayout.TextField(new GUIContent("命名空间:"), m_Namespace.stringValue);
if (GUILayout.Button("默认设置"))
{
m_Namespace.stringValue = m_Setting.Namespace;
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
m_ClassName.stringValue = EditorGUILayout.TextField(new GUIContent("类名:"), m_ClassName.stringValue);
if (GUILayout.Button("物体名"))
{
m_ClassName.stringValue = m_Target.gameObject.name;
}
EditorGUILayout.EndHorizontal();
bool isWidget = EditorGUILayout.Toggle("是否是组件", m_IsWidget.boolValue);
if (isWidget != m_IsWidget.boolValue)
{
m_IsWidget.boolValue = isWidget;
}
EditorGUILayout.LabelField("代码保存路径:");
EditorGUILayout.LabelField(m_CodePath.stringValue);
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("选择路径"))
{
string temp = m_CodePath.stringValue;
m_CodePath.stringValue = EditorUtility.OpenFolderPanel("选择代码保存路径", Application.dataPath, "");
if (string.IsNullOrEmpty(m_CodePath.stringValue))
{
m_CodePath.stringValue = temp;
}
}
if (GUILayout.Button("默认设置"))
{
m_CodePath.stringValue = m_Setting.CodePath;
}
EditorGUILayout.EndHorizontal();
}
/// <summary>
/// 绘制键值对数据
/// </summary>
private void DrawKvData()
{
//绘制key value数据
int needDeleteIndex = -1;
EditorGUILayout.BeginVertical();
SerializedProperty property;
for (int i = 0; i < m_BindDatas.arraySize; i++)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField($"[{i}]", GUILayout.Width(25));
property = m_BindDatas.GetArrayElementAtIndex(i).FindPropertyRelative("Name");
property.stringValue = EditorGUILayout.TextField(property.stringValue, GUILayout.Width(150));
property = m_BindDatas.GetArrayElementAtIndex(i).FindPropertyRelative("BindCom");
property.objectReferenceValue = EditorGUILayout.ObjectField(property.objectReferenceValue, typeof(Component), true);
if (GUILayout.Button("X"))
{
//将元素下标添加进删除list
needDeleteIndex = i;
}
EditorGUILayout.EndHorizontal();
}
//删除data
if (needDeleteIndex != -1)
{
m_BindDatas.DeleteArrayElementAtIndex(needDeleteIndex);
SyncBindComs();
}
EditorGUILayout.EndVertical();
}
/// <summary>
/// 添加绑定数据
/// </summary>
private void AddBindData(string name, Component bindCom, bool isGameObject = false)
{
int index = m_BindDatas.arraySize;
m_BindDatas.InsertArrayElementAtIndex(index);
SerializedProperty element = m_BindDatas.GetArrayElementAtIndex(index);
element.FindPropertyRelative("Name").stringValue = name;
element.FindPropertyRelative("BindCom").objectReferenceValue = bindCom;
element.FindPropertyRelative("IsGameObject").boolValue = isGameObject;
}
/// <summary>
/// 同步绑定数据
/// </summary>
private void SyncBindComs()
{
m_BindComs.ClearArray();
for (int i = 0; i < m_BindDatas.arraySize; i++)
{
SerializedProperty property = m_BindDatas.GetArrayElementAtIndex(i).FindPropertyRelative("BindCom");
m_BindComs.InsertArrayElementAtIndex(i);
m_BindComs.GetArrayElementAtIndex(i).objectReferenceValue = property.objectReferenceValue;
}
}
/// <summary>
/// 获取指定基类在指定程序集中的所有子类名称
/// </summary>
private string[] GetTypeNames(Type typeBase, string[] assemblyNames)
{
List<string> typeNames = new List<string>();
foreach (string assemblyName in assemblyNames)
{
Assembly assembly = null;
try
{
assembly = Assembly.Load(assemblyName);
}
catch
{
continue;
}
if (assembly == null)
{
continue;
}
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (type.IsClass && !type.IsAbstract && typeBase.IsAssignableFrom(type))
{
typeNames.Add(type.FullName);
}
}
}
typeNames.Sort();
return typeNames.ToArray();
}
/// <summary>
/// 创建辅助器实例
/// </summary>
private object CreateHelperInstance(string helperTypeName, string[] assemblyNames)
{
foreach (string assemblyName in assemblyNames)
{
Assembly assembly = Assembly.Load(assemblyName);
object instance = assembly.CreateInstance(helperTypeName);
if (instance != null)
{
return instance;
}
}
return null;
}
/// <summary>
/// 生成自动绑定代码
/// </summary>
private void GenAutoBindCode()
{
GameObject go = m_Target.gameObject;
string className = !string.IsNullOrEmpty(m_Target.ClassName) ? m_Target.ClassName : go.name;
string codePath = !string.IsNullOrEmpty(m_Target.CodePath) ? m_Target.CodePath : m_Setting.CodePath;
if (!Directory.Exists(codePath))
{
Debug.LogError($"{go.name}的代码保存路径{codePath}无效");
}
using (StreamWriter sw = new StreamWriter($"{codePath}/{className}.BindComponents.cs"))
{
sw.WriteLine(
"//------------------------------------------------------------------------------\n//\t<auto-generated>\n//\t\tTime:[" + DateTime.Now +
"].\n//\t\tThis code was generated by autoBindTool.\n//\t\tChanges to this file may cause incorrect behavior and will be lost if\n//\t\tthe code is regenerated.\n//\t</auto-generated>\n//------------------------------------------------------------------------------");
sw.WriteLine("using UnityEngine;");
sw.WriteLine("using UnityEngine.UI;");
sw.WriteLine("using TEngine;");
sw.WriteLine("");
if (!string.IsNullOrEmpty(m_Target.Namespace))
{
//命名空间
sw.WriteLine("namespace " + m_Target.Namespace);
sw.WriteLine("{");
}
//类名
// if (!m_Target.IsWidget)
// {
// sw.WriteLine($"\tpublic partial class {className} : UIWindow");
// }
// else
// {
// sw.WriteLine($"\tpublic partial class {className} : UIWidget");
// }
sw.WriteLine($"\tpublic partial class {className}");
sw.WriteLine("\t{");
//组件字段
foreach (BindData data in m_Target.BindDatas)
{
if (data.IsGameObject)
{
sw.WriteLine($"\t\tprivate GameObject m_{data.Name};");
}
else
{
sw.WriteLine($"\t\tprivate {data.BindCom.GetType().Name} m_{data.Name};");
}
}
sw.WriteLine("");
// sw.WriteLine(
// "\t\tpublic override void ScriptGenerator()\n\t\t{\n\t\t\tbase.ScriptGenerator();\n\t\t\tGetBindComponents(transform.gameObject);\n\t\t}");
sw.WriteLine("\t\tprivate void GetBindComponents(GameObject go)");
sw.WriteLine("\t\t{");
//获取autoBindTool上的Component
sw.WriteLine($"\t\t\tComponentAutoBindTool autoBindTool = go.GetComponent<ComponentAutoBindTool>();");
sw.WriteLine("");
//根据索引获取
for (int i = 0; i < m_Target.BindDatas.Count; i++)
{
BindData data = m_Target.BindDatas[i];
string filedName = $"m_{data.Name}";
if (data.IsGameObject)
{
sw.WriteLine($"\t\t\t{filedName} = autoBindTool.GetBindComponent<{data.BindCom.GetType().Name}>({i}).gameObject;");
}
else
{
sw.WriteLine($"\t\t\t{filedName} = autoBindTool.GetBindComponent<{data.BindCom.GetType().Name}>({i});");
}
}
sw.WriteLine("\t\t}");
sw.WriteLine("\t}");
if (!string.IsNullOrEmpty(m_Target.Namespace))
{
sw.WriteLine("}");
}
}
AssetDatabase.Refresh();
EditorUtility.DisplayDialog("提示", "代码生成完毕", "OK");
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 77f2df681a094ff5a14e92e380ba90e7
timeCreated: 1698304775

View File

@@ -1,179 +0,0 @@
using System.Collections.Generic;
using System.Text;
using Sirenix.OdinInspector.Editor;
using TEngine.Editor.UI;
using UnityEditor;
using UnityEngine;
#if UNITY_EDITOR
namespace TEngine
{
[CanEditMultipleObjects]
[CustomEditor(typeof(UIElement), true)]
public class UIElementEditor : OdinEditor
{
protected UIElement Element;
protected override void OnEnable()
{
base.OnEnable();
Element = target as UIElement;
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUI.BeginChangeCheck();
if (GUILayout.Button("Generate", GUILayout.Width(130)))
{
CheckUiItems();
}
serializedObject.ApplyModifiedProperties();
if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(Element);
}
base.OnInspectorGUI();
}
protected void CheckUiItems()
{
if (Element == null) return;
ClearUnusedItems();
var root = Element.transform;
StringBuilder strVar = new StringBuilder();
StringBuilder strBind = new StringBuilder();
StringBuilder strOnCreate = new StringBuilder();
StringBuilder strOnCreateRedNote = new StringBuilder();
StringBuilder strCallback = new StringBuilder();
Ergodic(root, root, ref strVar, ref strBind, ref strOnCreate, ref strOnCreateRedNote, ref strCallback);
StringBuilder strFile = new StringBuilder();
// 脚本工具生成的代码
strFile.Append("\t\t#region 脚本工具生成的代码\n");
strFile.Append(strVar);
strFile.Append("\t\tpublic override void ScriptGenerator()\n");
strFile.Append("\t\t{\n");
strFile.Append("\t\t\tCheckUIElement();\n");
strFile.Append(strBind);
strFile.Append(strOnCreate);
strFile.Append(strOnCreateRedNote);
strFile.Append("\t\t}\n");
strFile.Append("\t\t#endregion");
TextEditor te = new TextEditor();
te.text = strFile.ToString();
te.SelectAll();
te.Copy();
}
private void ClearUnusedItems()
{
if (Element == null || Element.Elements == null) return;
List<string> ids = new List<string>();
foreach (var kv in Element.Elements)
{
if (kv.Value == null || !string.IsNullOrEmpty(GetVerType(kv.Key)))
{
ids.Add(kv.Key);
}
}
foreach (var id in ids)
{
Element.Elements.Remove(id);
}
}
private void Ergodic(Transform root, Transform transform, ref StringBuilder strVar, ref StringBuilder strBind, ref StringBuilder strOnCreate,
ref StringBuilder strOnCreateRedNote, ref StringBuilder strCallback)
{
for (int i = 0; i < transform.childCount; ++i)
{
Transform child = transform.GetChild(i);
WriteScript(root, child, ref strVar, ref strBind, ref strOnCreate, ref strOnCreateRedNote, ref strCallback);
if (child.name.StartsWith("m_item"))
{
continue;
}
Ergodic(root, child, ref strVar, ref strBind, ref strOnCreate, ref strOnCreateRedNote, ref strCallback);
}
}
private void WriteScript(Transform root, Transform child, ref StringBuilder strVar, ref StringBuilder strBind, ref StringBuilder strOnCreate,
ref StringBuilder strOnCreateRedNote, ref StringBuilder strCallback)
{
var varName = child.name;
var varType = GetVerType(varName);
if (varType == string.Empty) return;
if (Element.Elements.Contains(varName))
{
Debug.LogError("有重复的key:" + varName);
return;
}
Element.Elements[varName] = child;
if (!string.IsNullOrEmpty(varName))
{
strVar.Append("\t\tprivate " + varType + " " + varName + ";\n");
switch (varType)
{
case "Transform":
strBind.Append($"\t\t\t{varName} = FChild(\"{varName}\");\n");
break;
case "GameObject":
strBind.Append($"\t\t\t{varName} = FChild(\"{varName}\").gameObject;\n");
break;
case "RichItemIcon":
strBind.Append($"\t\t\t{varName} = CreateWidgetByType<{varType}>(FChild(\"{varName}\"));\n");
break;
case "RedNoteWidget":
break;
case "TextButtonItem":
case "SwitchTabItem":
case "UIActorWidget":
case "UIEffectWidget":
case "UISpineWidget":
case "UIMainPlayerWidget":
strBind.Append($"\t\t\t{varName} = CreateWidget<{varType}>(FChild(\"{varName}\").gameObject);\n");
break;
default:
strBind.Append($"\t\t\t{varName} = FChild<{varType}>(\"{varName}\");\n");
break;
}
if (varType == "Button")
{
string varFuncName = ScriptGenerator.GetBtnFuncName(varName);
strOnCreate.Append($"\t\t\t{varName}.onClick.AddListener({varFuncName});\n");
strCallback.Append($"\t\tprivate void {varFuncName}()\n");
strCallback.Append("\t\t{\n\t\t}\n");
}
else if (varType == "Toggle")
{
string varFuncName = ScriptGenerator.GetToggleFuncName(varName);
strOnCreate.Append($"\t\t\t{varName}.onValueChanged.AddListener({varFuncName});\n");
strCallback.Append($"\t\tprivate void {varFuncName}(bool isOn)\n");
strCallback.Append("\t\t{\n\t\t}\n");
}
}
}
protected string GetVerType(string uiName)
{
foreach (var pair in SettingsUtils.GetScriptGenerateRule())
{
if (uiName.StartsWith(pair.uiElementRegex))
{
return pair.componentName;
}
}
return string.Empty;
}
}
}
#endif

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 02ba9976b78c4a079e16aa9302c1b43e
timeCreated: 1696659319

View File

@@ -0,0 +1,69 @@
using UnityEditor;
using UnityEngine;
/// <summary>
/// Unity编辑器类帮助类。
/// </summary>
public static class ClassHelper
{
/// <summary>
/// 获取MonoBehaviour的脚本Id。
/// </summary>
/// <param name="type">脚本类型。</param>
/// <returns>脚本Id。</returns>
public static int GetClassID(System.Type type)
{
GameObject gameObject = EditorUtility.CreateGameObjectWithHideFlags("Temp", HideFlags.HideAndDontSave);
Component component = gameObject.AddComponent(type);
SerializedObject @class = new SerializedObject(component);
int classID = @class.FindProperty("m_Script").objectReferenceInstanceIDValue;
Object.DestroyImmediate(gameObject);
return classID;
}
/// <summary>
/// 获取MonoBehaviour的脚本Id。
/// </summary>
/// <typeparam name="T">脚本类型。</typeparam>
/// <returns>脚本Id。</returns>
public static int GetClassID<T>() where T : MonoBehaviour
{
return GetClassID(typeof(T));
}
#region Method Documentation
/************************************************************************************************************
Example:
[MenuItem("GameObject/UI/转化成CustomText", false, 1999)]
public static void ConvertToCustomText(MenuCommand menuCommand)
{
GameObject go = menuCommand.context as GameObject;
if (go != null)
{
Text text = go.GetComponent<Text>();
if (text != null)
{
var ob = ClassHelper.ReplaceClass(text, typeof(CustomText));
ob.ApplyModifiedProperties();
}
}
}
************************************************************************************************************/
#endregion
/// <summary>
/// 替换MonoBehaviour脚本。
/// </summary>
/// <param name="monoBehaviour"></param>
/// <param name="type"></param>
/// <returns></returns>
public static SerializedObject ReplaceClass(MonoBehaviour monoBehaviour, System.Type type)
{
int classID = GetClassID(type);
SerializedObject @class = new SerializedObject(monoBehaviour);
@class.Update();
@class.FindProperty("m_Script").objectReferenceInstanceIDValue = classID;
@class.ApplyModifiedProperties();
@class.Update();
return @class;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aa5c786315234462bb549c4533d4d858
timeCreated: 1698042158

View File

@@ -0,0 +1,120 @@
#region Class Documentation
/************************************************************************************************************
Class Name: CommandLineReader.cs
Type: Util, Static
Definition:
CommandLineReader.cs give the ability to access [Custom Arguments] sent
through the command line. Simply add your custom arguments under the
keyword '-CustomArgs:' and seperate them by ';'.
Example:
C:\Program Files (x86)\Unity\Editor\Unity.exe [ProjectLocation] -executeMethod [Your entrypoint] -quit -CustomArgs:Language=en_US;Version=1.02
Example1:
set WORKSPACE=.
set UNITYEDITOR_PATH=G:/UnityEditor/2021.3.20f1c1/Editor
set LOGFILE=./build.log
set BUILDROOT=G:/github/TEngine/UnityProject/Bundles
%UNITYEDITOR_PATH%/Unity.exe %WORKSPACE%/UnityProject -logFile %LOGFILE% -executeMethod TEngine.ReleaseTools.BuildPackage -quit -batchmode -CustomArgs:Language=en_US;Version=1.02;outputRoot=%BUILDROOT%
@REM for /f "delims=[" %%i in (%LOGFILE%) do echo %%i
pause
************************************************************************************************************/
#endregion
#region Using
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using Debug = UnityEngine.Debug;
#endregion
/// <summary>
/// Unity命令行拓展帮助类。
/// <remarks>可以用来制定自己项目的打包、编辑器工作流。</remarks>
/// </summary>
public class CommandLineReader
{
//Config
private const string CUSTOM_ARGS_PREFIX = "-CustomArgs:";
private const char CUSTOM_ARGS_SEPARATOR = ';';
public static string[] GetCommandLineArgs()
{
return Environment.GetCommandLineArgs();
}
public static string GetCommandLine()
{
string[] args = GetCommandLineArgs();
if (args.Length > 0)
{
return string.Join(" ", args);
}
else
{
Debug.LogError("CommandLineReader.cs - GetCommandLine() - Can't find any command line arguments!");
return "";
}
}
public static Dictionary<string,string> GetCustomArguments()
{
Dictionary<string, string> customArgsDict = new Dictionary<string, string>();
string[] commandLineArgs = GetCommandLineArgs();
string[] customArgs;
string[] customArgBuffer;
string customArgsStr = "";
try
{
customArgsStr = commandLineArgs.Where(row => row.Contains(CUSTOM_ARGS_PREFIX)).Single();
}
catch (Exception e)
{
Debug.LogError("CommandLineReader.cs - GetCustomArguments() - Can't retrieve any custom arguments in the command line [" + commandLineArgs + "]. Exception: " + e);
return customArgsDict;
}
customArgsStr = customArgsStr.Replace(CUSTOM_ARGS_PREFIX, "");
customArgs = customArgsStr.Split(CUSTOM_ARGS_SEPARATOR);
foreach (string customArg in customArgs)
{
customArgBuffer = customArg.Split('=');
if (customArgBuffer.Length == 2)
{
customArgsDict.Add(customArgBuffer[0], customArgBuffer[1]);
}
else
{
Debug.LogWarning("CommandLineReader.cs - GetCustomArguments() - The custom argument [" + customArg + "] seem to be malformed.");
}
}
return customArgsDict;
}
/// <summary>
/// 获取cmd输入的自定义参数数值。
/// </summary>
/// <param name="argumentName">自定义参数名称。</param>
/// <returns>自定义参数数值。</returns>
public static string GetCustomArgument(string argumentName)
{
Dictionary<string, string> customArgsDict = GetCustomArguments();
if (customArgsDict.TryGetValue(argumentName, out var argument))
{
return argument;
}
else
{
Debug.LogError("CommandLineReader.cs - GetCustomArgument() - Can't retrieve any custom argument named [" + argumentName + "] in the command line [" + GetCommandLine() + "].");
return "";
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9f4bc66bca9a460cb714a36a127739e7
timeCreated: 1698041943

View File

@@ -0,0 +1,99 @@
using System;
using System.Reflection;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditorInternal;
namespace TEngine.Editor
{
/// <summary>
/// 日志重定向相关的实用函数。
/// </summary>
internal static class LogRedirection
{
[OnOpenAsset(0)]
private static bool OnOpenAsset(int instanceID, int line)
{
if (line <= 0)
{
return false;
}
var stackTrace = GetStackTrace();
if (!string.IsNullOrEmpty(stackTrace) && (stackTrace.Contains("[Debug]") ||
stackTrace.Contains("[INFO]") ||
stackTrace.Contains("[ASSERT]") ||
stackTrace.Contains("[WARNING]") ||
stackTrace.Contains("[ERROR]") ||
stackTrace.Contains("[EXCEPTION]")))
{
// 使用正则表达式匹配at的哪个脚本的哪一行
var matches = Regex.Match(stackTrace, @"\(at (.+)\)",
RegexOptions.IgnoreCase);
while (matches.Success)
{
var pathLine = matches.Groups[1].Value;
if (!pathLine.Contains("Logger.cs") &&
!pathLine.Contains("DefaultLogHelper.cs") &&
!pathLine.Contains("GameFrameworkLog.cs") &&
!pathLine.Contains("AssetsLogger.cs") &&
!pathLine.Contains("Log.cs"))
{
var splitIndex = pathLine.LastIndexOf(":", StringComparison.Ordinal);
// 脚本路径
var path = pathLine.Substring(0, splitIndex);
// 行号
line = Convert.ToInt32(pathLine.Substring(splitIndex + 1));
var fullPath = UnityEngine.Application.dataPath.Substring(0, UnityEngine.Application.dataPath.LastIndexOf("Assets", StringComparison.Ordinal));
fullPath = $"{fullPath}{path}";
// 跳转到目标代码的特定行
InternalEditorUtility.OpenFileAtLineExternal(fullPath.Replace('/', '\\'), line);
break;
}
matches = matches.NextMatch();
}
return true;
}
return false;
}
/// <summary>
/// 获取当前日志窗口选中的日志的堆栈信息。
/// </summary>
/// <returns>选中日志的堆栈信息实例。</returns>
private static string GetStackTrace()
{
// 通过反射获取ConsoleWindow类
var consoleWindowType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ConsoleWindow");
// 获取窗口实例
var fieldInfo = consoleWindowType.GetField("ms_ConsoleWindow",
BindingFlags.Static |
BindingFlags.NonPublic);
if (fieldInfo != null)
{
var consoleInstance = fieldInfo.GetValue(null);
if (consoleInstance != null)
if (EditorWindow.focusedWindow == (EditorWindow)consoleInstance)
{
// 获取m_ActiveText成员
fieldInfo = consoleWindowType.GetField("m_ActiveText",
BindingFlags.Instance |
BindingFlags.NonPublic);
// 获取m_ActiveText的值
if (fieldInfo != null)
{
var activeText = fieldInfo.GetValue(consoleInstance).ToString();
return activeText;
}
}
}
return null;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8e219db54fde57a4aae694a55da3e1b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -4,6 +4,9 @@ using System.Collections.Generic;
namespace TEngine
{
/// <summary>
/// Unity编辑器主动执行cmd帮助类。
/// </summary>
public static class ShellHelper
{
public static void Run(string cmd, string workDirectory, List<string> environmentVars = null)

View File

@@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3dac541dae7b4c4d8b5497057739cfb0, type: 3}
m_Name: AutoBindGlobalSetting
m_EditorClassIdentifier:
m_CodePath: Assets/GameScripts
m_Namespace: GameLogic
m_WidgetName: m_item

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eb33bb9d9cdf9484997cc91b0517ba4d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,120 @@
using System.Collections.Generic;
namespace TEngine
{
/// <summary>
/// 游戏框架字典类。
/// </summary>
/// <typeparam name="TKey">指定字典Key的元素类型。</typeparam>
/// <typeparam name="TValue">指定字典Value的元素类型。</typeparam>
public class GameFrameworkDictionary<TKey, TValue>
{
protected readonly List<TKey> KeyList = new List<TKey>();
protected readonly Dictionary<TKey, TValue> Dictionary = new Dictionary<TKey, TValue>();
/// <summary>
/// 存储键的列表。
/// </summary>
public List<TKey> Keys => KeyList;
/// <summary>
/// 存储字典实例。
/// </summary>
public int Count => KeyList.Count;
/// <summary>
/// 通过KEY的数组下标获取元素。
/// </summary>
/// <param name="index">下标。</param>
/// <returns>TValue。</returns>
public TValue GetValueByIndex(int index)
{
return Dictionary[KeyList[index]];
}
/// <summary>
/// 通过KEY的数组下标设置元素。
/// </summary>
/// <param name="index">下标。</param>
/// <param name="item">TValue。</param>
public void SetValue(int index, TValue item)
{
Dictionary[KeyList[index]] = item;
}
/// <summary>
/// 字典索引器。
/// </summary>
/// <param name="key">TKey。</param>
public TValue this[TKey key]
{
get => Dictionary[key];
set
{
if (!ContainsKey(key))
{
Add(key, value);
}
else
{
Dictionary[key] = value;
}
}
}
/// <summary>Removes all keys and values from the <see cref="T:TEngine.GameFrameworkDictionary`2" />.</summary>
public void Clear()
{
KeyList.Clear();
Dictionary.Clear();
}
/// <summary>Adds the specified key and value to the dictionary.</summary>
/// <param name="key">The key of the element to add.</param>
/// <param name="item">The value of the element to add. The value can be <see langword="null" /> for reference types.</param>
public virtual void Add(TKey key, TValue item)
{
KeyList.Add(key);
Dictionary.Add(key, item);
}
/// <summary>Gets the value associated with the specified key.</summary>
/// <param name="key">The key of the value to get.</param>
/// <param name="value">When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the <paramref name="value" /> parameter. This parameter is passed uninitialized.</param>
public bool TryGetValue(TKey key, out TValue value)
{
return Dictionary.TryGetValue(key, out value);
}
/// <summary>Determines whether the <see cref="T:System.Collections.Generic.Dictionary`2" /> contains the specified key.</summary>
/// <param name="key">The key to locate in the </param>
public bool ContainsKey(TKey key)
{
return Dictionary.ContainsKey(key);
}
public TKey GetKey(int index)
{
return KeyList[index];
}
public bool Remove(TKey key)
{
return KeyList.Remove(key) && Dictionary.Remove(key);
}
}
/// <summary>
/// 游戏框架顺序字典类。
/// </summary>
/// <typeparam name="TKey">指定字典Key的元素类型。</typeparam>
/// <typeparam name="TValue">指定字典Value的元素类型。</typeparam>
public class GameFrameworkSortedDictionary<TKey, TValue> : GameFrameworkDictionary<TKey, TValue>
{
public override void Add(TKey key, TValue item)
{
base.Add(key, item);
KeyList.Sort();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3df785fede30420dbfa6acb2ff48c166
timeCreated: 1698296076

View File

@@ -0,0 +1,614 @@
using System;
using System.Collections.Generic;
#region Class Documentation
/************************************************************************************************************
Class Name: ActorEventDispatcher.cs 局部单位事件分发器。
Type: Actor, Event
Example:
private ActorEventDispatcher _event;
/// <summary>
/// 局部事件管理器。
/// <remark>只分发和监听这个Event内部的事件</remark>
/// </summary>
public ActorEventDispatcher Event => _event ??= MemoryPool.Acquire<ActorEventDispatcher>();
// owner局部发送事件。
owner.Event.Send(eventId,xxx);
// owner监听自身事件并绑定持有对象为owner。 比如是组件的情况下。移除时调用RemoveAllListenerByOwner(owner)会根据持有对象(组件)移除。
owner.Event.AddEventListener(eventId,xxx,owner);
************************************************************************************************************/
#endregion
namespace TEngine
{
/// <summary>
/// 局部单位事件分发器。
/// </summary>
public class ActorEventDispatcher : IMemory
{
/// <summary>
/// 所有事件。
/// </summary>
private readonly Dictionary<int, List<EventRegInfo>> _allEventListenerMap;
/// <summary>
/// 用于标记一个事件是不是正在处理。
/// </summary>
private readonly List<int> _processEventList;
/// <summary>
/// 用于标记一个事件是不是被移除。
/// </summary>
private readonly List<int> _delayDeleteEventList;
public ActorEventDispatcher()
{
_processEventList = new List<int>();
_delayDeleteEventList = new List<int>();
_allEventListenerMap = new Dictionary<int, List<EventRegInfo>>();
}
/// <summary>
/// 移除所有事件监听。
/// </summary>
public void DestroyAllEventListener()
{
var itr = _allEventListenerMap.GetEnumerator();
while (itr.MoveNext())
{
var kv = itr.Current;
kv.Value.Clear();
}
_processEventList.Clear();
_delayDeleteEventList.Clear();
itr.Dispose();
}
/// <summary>
/// 延迟移除事件。
/// </summary>
/// <param name="eventId"></param>
private void AddDelayDelete(int eventId)
{
if (!_delayDeleteEventList.Contains(eventId))
{
_delayDeleteEventList.Add(eventId);
Log.Info("delay delete eventId[{0}]", eventId);
}
}
/// <summary>
/// 如果找到eventId对应的监听删除所有标记为delete的监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
private void CheckDelayDelete(int eventId)
{
if (_delayDeleteEventList.Contains(eventId))
{
if (_allEventListenerMap.TryGetValue(eventId, out var listListener))
{
for (int i = 0; i < listListener.Count; i++)
{
if (listListener[i].IsDeleted)
{
Log.Info("remove delay delete eventId[{0}]", eventId);
listListener[i] = listListener[^1];
listListener.RemoveAt(listListener.Count - 1);
i--;
}
}
}
_delayDeleteEventList.Remove(eventId);
}
}
/// <summary>
/// 发送事件。
/// </summary>
/// <param name="eventId">事件Id。</param>
public void SendEvent(int eventId)
{
if (_allEventListenerMap.TryGetValue(eventId, out var listListener))
{
_processEventList.Add(eventId);
#if UNITY_EDITOR
int iEventCnt = _processEventList.Count;
#endif
var count = listListener.Count;
for (int i = 0; i < count; i++)
{
var node = listListener[i];
if (node.IsDeleted)
{
continue;
}
if (listListener[i].Callback is Action callBack)
{
callBack();
}
else
{
Log.Fatal("Invalid event data type: {0}", eventId);
}
}
#if UNITY_EDITOR
Log.Assert(iEventCnt == _processEventList.Count);
Log.Assert(eventId == _processEventList[^1]);
#endif
_processEventList.RemoveAt(_processEventList.Count - 1);
CheckDelayDelete(eventId);
}
}
/// <summary>
/// 发送事件。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="arg1">事件参数。</param>
/// <typeparam name="TArg1">事件参数类型1。</typeparam>
public void SendEvent<TArg1>(int eventId, TArg1 arg1)
{
if (_allEventListenerMap.TryGetValue(eventId, out var listListener))
{
_processEventList.Add(eventId);
#if UNITY_EDITOR
int iEventCnt = _processEventList.Count;
#endif
var count = listListener.Count;
for (int i = 0; i < count; i++)
{
var node = listListener[i];
if (node.IsDeleted)
{
continue;
}
if (listListener[i].Callback is Action<TArg1> callBack)
{
callBack(arg1);
}
else
{
Log.Fatal("Invalid event data type: {0}", eventId);
}
}
#if UNITY_EDITOR
Log.Assert(iEventCnt == _processEventList.Count);
Log.Assert(eventId == _processEventList[^1]);
#endif
_processEventList.RemoveAt(_processEventList.Count - 1);
CheckDelayDelete(eventId);
}
}
/// <summary>
/// 发送事件。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="arg1">事件参数1。</param>
/// <param name="arg2">事件参数2。</param>
/// <typeparam name="TArg1">事件参数类型1。</typeparam>
/// <typeparam name="TArg2">事件参数类型2。</typeparam>
public void SendEvent<TArg1, TArg2>(int eventId, TArg1 arg1, TArg2 arg2)
{
if (_allEventListenerMap.TryGetValue(eventId, out var listListener))
{
_processEventList.Add(eventId);
#if UNITY_EDITOR
int iEventCnt = _processEventList.Count;
#endif
var count = listListener.Count;
for (int i = 0; i < count; i++)
{
var node = listListener[i];
if (node.IsDeleted)
{
continue;
}
if (listListener[i].Callback is Action<TArg1, TArg2> callBack)
{
callBack(arg1, arg2);
}
else
{
Log.Fatal("Invalid event data type: {0}", eventId);
}
}
#if UNITY_EDITOR
Log.Assert(iEventCnt == _processEventList.Count);
Log.Assert(eventId == _processEventList[^1]);
#endif
_processEventList.RemoveAt(_processEventList.Count - 1);
CheckDelayDelete(eventId);
}
}
/// <summary>
/// 发送事件。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="arg1">事件参数1。</param>
/// <param name="arg2">事件参数2。</param>
/// <param name="arg3">事件参数3。</param>
/// <typeparam name="TArg1">事件参数类型1。</typeparam>
/// <typeparam name="TArg2">事件参数类型2。</typeparam>
/// <typeparam name="TArg3">事件参数类型3。</typeparam>
public void SendEvent<TArg1, TArg2, TArg3>(int eventId, TArg1 arg1, TArg2 arg2, TArg3 arg3)
{
if (_allEventListenerMap.TryGetValue(eventId, out var listListener))
{
_processEventList.Add(eventId);
#if UNITY_EDITOR
int iEventCnt = _processEventList.Count;
#endif
var count = listListener.Count;
for (int i = 0; i < count; i++)
{
var node = listListener[i];
if (node.IsDeleted)
{
continue;
}
if (node.Callback is Action<TArg1, TArg2, TArg3> callBack)
{
callBack(arg1, arg2, arg3);
}
else
{
Log.Fatal("Invalid event data type: {0}", eventId);
}
}
#if UNITY_EDITOR
Log.Assert(iEventCnt == _processEventList.Count);
Log.Assert(eventId == _processEventList[^1]);
#endif
_processEventList.RemoveAt(_processEventList.Count - 1);
CheckDelayDelete(eventId);
}
}
/// <summary>
/// 发送事件。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="arg1">事件参数1。</param>
/// <param name="arg2">事件参数2。</param>
/// <param name="arg3">事件参数3。</param>
/// <param name="arg4">事件参数4。</param>
/// <typeparam name="TArg1">事件参数类型1。</typeparam>
/// <typeparam name="TArg2">事件参数类型2。</typeparam>
/// <typeparam name="TArg3">事件参数类型3。</typeparam>
/// <typeparam name="TArg4">事件参数类型4。</typeparam>
public void SendEvent<TArg1, TArg2, TArg3, TArg4>(int eventId, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4)
{
if (_allEventListenerMap.TryGetValue(eventId, out var listListener))
{
_processEventList.Add(eventId);
#if UNITY_EDITOR
int iEventCnt = _processEventList.Count;
#endif
var count = listListener.Count;
for (int i = 0; i < count; i++)
{
var node = listListener[i];
if (node.IsDeleted)
{
continue;
}
if (listListener[i].Callback is Action<TArg1, TArg2, TArg3, TArg4> callBack)
{
callBack(arg1, arg2, arg3, arg4);
}
else
{
Log.Fatal("Invalid event data type: {0}", eventId);
}
}
#if UNITY_EDITOR
Log.Assert(iEventCnt == _processEventList.Count);
Log.Assert(eventId == _processEventList[^1]);
#endif
_processEventList.RemoveAt(_processEventList.Count - 1);
CheckDelayDelete(eventId);
}
}
/// <summary>
/// 增加事件监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="eventCallback">事件回调。</param>
/// <param name="owner">持有者Tag。</param>
public void AddEventListener(int eventId, Action eventCallback, object owner)
{
AddEventListenerImp(eventId, eventCallback, owner);
}
/// <summary>
/// 增加事件监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="eventCallback">事件回调。</param>
/// <param name="owner">持有者Tag。</param>
/// <typeparam name="TArg1">事件参数类型1。</typeparam>
public void AddEventListener<TArg1>(int eventId, Action<TArg1> eventCallback, object owner)
{
AddEventListenerImp(eventId, eventCallback, owner);
}
/// <summary>
/// 增加事件监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="eventCallback">事件回调。</param>
/// <param name="owner">持有者Tag。</param>
/// <typeparam name="TArg1">事件参数类型1。</typeparam>
/// <typeparam name="TArg2">事件参数类型2。</typeparam>
public void AddEventListener<TArg1, TArg2>(int eventId, Action<TArg1, TArg2> eventCallback, object owner)
{
AddEventListenerImp(eventId, eventCallback, owner);
}
/// <summary>
/// 增加事件监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="eventCallback">事件回调。</param>
/// <param name="owner">持有者Tag。</param>
/// <typeparam name="TArg1">事件参数类型1。</typeparam>
/// <typeparam name="TArg2">事件参数类型2。</typeparam>
/// <typeparam name="TArg3">事件参数类型3。</typeparam>
public void AddEventListener<TArg1, TArg2, TArg3>(int eventId, Action<TArg1, TArg2, TArg3> eventCallback, object owner)
{
AddEventListenerImp(eventId, eventCallback, owner);
}
/// <summary>
/// 增加事件监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="eventCallback">事件回调。</param>
/// <param name="owner">持有者Tag。</param>
/// <typeparam name="TArg1">事件参数类型1。</typeparam>
/// <typeparam name="TArg2">事件参数类型2。</typeparam>
/// <typeparam name="TArg3">事件参数类型3。</typeparam>
/// <typeparam name="TArg4">事件参数类型4。</typeparam>
public void AddEventListener<TArg1, TArg2, TArg3, TArg4>(int eventId, Action<TArg1, TArg2, TArg3, TArg4> eventCallback, object owner)
{
AddEventListenerImp(eventId, eventCallback, owner);
}
/// <summary>
/// 增加事件监听具体实现。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="listener">事件回调。</param>
/// <param name="owner">持有者Tag。</param>
private void AddEventListenerImp(int eventId, Delegate listener, object owner)
{
if (!_allEventListenerMap.TryGetValue(eventId, out var listListener))
{
listListener = new List<EventRegInfo>();
_allEventListenerMap.Add(eventId, listListener);
}
var existNode = listListener.Find((node) => node.Callback == listener);
if (existNode != null)
{
if (existNode.IsDeleted)
{
existNode.IsDeleted = false;
Log.Warning("AddEvent hashId deleted, repeat add: {0}", eventId);
return;
}
Log.Fatal("AddEvent hashId repeated: {0}", eventId);
return;
}
listListener.Add(new EventRegInfo(listener, owner));
}
/// <summary>
/// 通过持有者Tag移除监听。
/// </summary>
/// <param name="owner">持有者Tag。</param>
public void RemoveAllListenerByOwner(object owner)
{
var itr = _allEventListenerMap.GetEnumerator();
while (itr.MoveNext())
{
var kv = itr.Current;
var list = kv.Value;
int eventId = kv.Key;
bool isProcessing = _processEventList.Contains(eventId);
bool delayDeleted = false;
for (int i = 0; i < list.Count; i++)
{
var regInfo = list[i];
if (regInfo.Owner == owner)
{
if (isProcessing)
{
regInfo.IsDeleted = true;
delayDeleted = true;
}
else
{
list[i] = list[^1];
list.RemoveAt(list.Count - 1);
i--;
}
}
}
if (delayDeleted)
{
AddDelayDelete(eventId);
}
}
itr.Dispose();
}
/// <summary>
/// 移除事件监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="eventCallback">消息回调。</param>
public void RemoveEventListener(int eventId, Action eventCallback)
{
RemoveEventListenerImp(eventId, eventCallback);
}
/// <summary>
/// 移除事件监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="eventCallback">消息回调。</param>
/// <typeparam name="TArg1">参数类型1。</typeparam>
public void RemoveEventListener<TArg1>(int eventId, Action<TArg1> eventCallback)
{
RemoveEventListenerImp(eventId, eventCallback);
}
/// <summary>
/// 移除事件监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="eventCallback">消息回调。</param>
/// <typeparam name="TArg1">参数类型1。</typeparam>
/// <typeparam name="TArg2">参数类型2。</typeparam>
public void RemoveEventListener<TArg1, TArg2>(int eventId, Action<TArg1, TArg2> eventCallback)
{
RemoveEventListenerImp(eventId, eventCallback);
}
/// <summary>
/// 移除事件监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="eventCallback">消息回调。</param>
/// <typeparam name="TArg1">参数类型1。</typeparam>
/// <typeparam name="TArg2">参数类型2。</typeparam>
/// <typeparam name="TArg3">参数类型3。</typeparam>
public void RemoveEventListener<TArg1, TArg2, TArg3>(int eventId, Action<TArg1, TArg2, TArg3> eventCallback)
{
RemoveEventListenerImp(eventId, eventCallback);
}
/// <summary>
/// 移除事件监听。
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="eventCallback">消息回调。</param>
/// <typeparam name="TArg1">参数类型1。</typeparam>
/// <typeparam name="TArg2">参数类型2。</typeparam>
/// <typeparam name="TArg3">参数类型3。</typeparam>
/// <typeparam name="TArg4">参数类型4。</typeparam>
public void RemoveEventListener<TArg1, TArg2, TArg3, TArg4>(int eventId, Action<TArg1, TArg2, TArg3, TArg4> eventCallback)
{
RemoveEventListenerImp(eventId, eventCallback);
}
/// <summary>
/// 删除监听,如果是正在处理的监听则标记为删除
/// </summary>
/// <param name="eventId">事件Id。</param>
/// <param name="listener">事件监听。</param>
protected void RemoveEventListenerImp(int eventId, Delegate listener)
{
if (_allEventListenerMap.TryGetValue(eventId, out var listListener))
{
bool isProcessing = _processEventList.Contains(eventId);
if (!isProcessing)
{
listListener.RemoveAll(node => node.Callback == listener);
}
else
{
int listenCnt = listListener.Count;
for (int i = 0; i < listenCnt; i++)
{
var node = listListener[i];
if (node.Callback == listener)
{
node.IsDeleted = true;
AddDelayDelete(eventId);
break;
}
}
}
}
}
/// <summary>
/// 清除回收接口。
/// </summary>
public void Clear()
{
DestroyAllEventListener();
}
}
/// <summary>
/// 事件注册信息。
/// </summary>
public class EventRegInfo
{
/// <summary>
/// 事件回调。
/// </summary>
public readonly Delegate Callback;
/// <summary>
/// 事件持有者。
/// </summary>
public readonly object Owner;
/// <summary>
/// 事件是否删除。
/// </summary>
public bool IsDeleted;
public EventRegInfo(Delegate callback, object owner)
{
this.Callback = callback;
Owner = owner;
IsDeleted = false;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 222c2a26f3b14d42950d0e9a10b61b38
timeCreated: 1673511406

View File

@@ -25,7 +25,7 @@ namespace TEngine
var cts = new CancellationTokenSource();
cts.CancelAfterSlim(TimeSpan.FromSeconds(timeout));
UnityWebRequest unityWebRequest = UnityWebRequest.Get(url);
using UnityWebRequest unityWebRequest = UnityWebRequest.Get(url);
return await SendWebRequest(unityWebRequest, cts);
}
@@ -41,7 +41,7 @@ namespace TEngine
var cts = new CancellationTokenSource();
cts.CancelAfterSlim(TimeSpan.FromSeconds(timeout));
UnityWebRequest unityWebRequest = UnityWebRequest.Post(url, postData);
using UnityWebRequest unityWebRequest = UnityWebRequest.Post(url, postData);
return await SendWebRequest(unityWebRequest, cts);
}
@@ -57,7 +57,7 @@ namespace TEngine
var cts = new CancellationTokenSource();
cts.CancelAfterSlim(TimeSpan.FromSeconds(timeout));
UnityWebRequest unityWebRequest = UnityWebRequest.Post(url, formFields);
using UnityWebRequest unityWebRequest = UnityWebRequest.Post(url, formFields);
return await SendWebRequest(unityWebRequest, cts);
}
@@ -73,7 +73,7 @@ namespace TEngine
var cts = new CancellationTokenSource();
cts.CancelAfterSlim(TimeSpan.FromSeconds(timeout));
UnityWebRequest unityWebRequest = UnityWebRequest.Post(url, formData);
using UnityWebRequest unityWebRequest = UnityWebRequest.Post(url, formData);
return await SendWebRequest(unityWebRequest, cts);
}
@@ -91,6 +91,9 @@ namespace TEngine
if (isCanceled)
{
Log.Warning($"HttpPost {unityWebRequest.url} be canceled!");
unityWebRequest.Dispose();
cts.Dispose();
return string.Empty;
}
}
catch (OperationCanceledException ex)
@@ -98,11 +101,16 @@ namespace TEngine
if (ex.CancellationToken == cts.Token)
{
Log.Warning("HttpPost Timeout");
unityWebRequest.Dispose();
cts.Dispose();
return string.Empty;
}
}
return unityWebRequest.downloadHandler.text;
string ret = unityWebRequest.downloadHandler.text;
unityWebRequest.Dispose();
cts.Dispose();
return ret;
}
}
}

View File

@@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: 03804aac55906c846a647bfd1e0b7eca
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -175,10 +175,7 @@ namespace TEngine
/// <returns>音频代理辅助器。</returns>
public static AudioAgent Create(string path, bool bAsync, AudioCategory audioCategory, bool bInPool = false)
{
AudioAgent audioAgent = new AudioAgent
{
_audioModuleImp = ModuleImpSystem.GetModule<AudioModuleImp>()
};
AudioAgent audioAgent = new AudioAgent();
audioAgent.Init(audioCategory);
audioAgent.Load(path, bAsync, bInPool);
return audioAgent;
@@ -191,6 +188,7 @@ namespace TEngine
/// <param name="index">音频代理辅助器编号。</param>
public void Init(AudioCategory audioCategory, int index = 0)
{
_audioModuleImp = ModuleImpSystem.GetModule<AudioModuleImp>();
GameObject host = new GameObject(Utility.Text.Format("Audio Agent Helper - {0} - {1}", audioCategory.AudioMixerGroup.name, index));
host.transform.SetParent(audioCategory.InstanceRoot);
host.transform.localPosition = Vector3.zero;

View File

@@ -38,6 +38,8 @@ namespace TEngine
[SerializeField]
private DebuggerActiveWindowType m_ActiveWindow = DebuggerActiveWindowType.AlwaysOpen;
public DebuggerActiveWindowType ActiveWindowType => m_ActiveWindow;
[SerializeField]
private bool m_ShowFullWindow = false;
@@ -393,7 +395,7 @@ namespace TEngine
DrawDebuggerWindowGroup(subDebuggerWindowGroup);
}
debuggerWindowGroup.SelectedWindow.OnDraw();
debuggerWindowGroup?.SelectedWindow?.OnDraw();
}
private void DrawDebuggerWindowIcon(int windowId)

View File

@@ -11,18 +11,29 @@ namespace TEngine
{
private static readonly Dictionary<Type, Module> _moduleMaps = new Dictionary<Type, Module>(ModuleImpSystem.DesignModuleCount);
private static GameObject _gameModuleRoot;
#region
/// <summary>
/// 获取游戏基础模块。
/// </summary>
public static RootModule Base => _base ??= Get<RootModule>();
public static RootModule Base
{
get => _base ??= Get<RootModule>();
private set => _base = value;
}
private static RootModule _base;
/// <summary>
/// 获取调试模块。
/// </summary>
public static DebuggerModule Debugger => _debugger ??= Get<DebuggerModule>();
public static DebuggerModule Debugger
{
get => _debugger ??= Get<DebuggerModule>();
private set => _debugger = value;
}
private static DebuggerModule _debugger;
@@ -82,6 +93,12 @@ namespace TEngine
private static LocalizationModule _localization;
/// <summary>
/// 获取场景模块。
/// </summary>
public static SceneModule Scene => _scene ??= Get<SceneModule>();
private static SceneModule _scene;
#endregion
/// <summary>
@@ -111,7 +128,31 @@ namespace TEngine
{
Log.Info("GameModule Active");
gameObject.name = $"[{nameof(GameModule)}]";
_gameModuleRoot = gameObject;
DontDestroyOnLoad(gameObject);
}
public static void Shutdown(ShutdownType shutdownType)
{
Log.Info("GameModule Shutdown");
if (_gameModuleRoot != null)
{
Destroy(_gameModuleRoot);
_gameModuleRoot = null;
}
_moduleMaps.Clear();
_base = null;
_debugger = null;
_fsm = null;
_procedure = null;
_objectPool = null;
_resource = null;
_audio = null;
_setting = null;
_ui = null;
_localization = null;
_scene = null;
}
}
}

View File

@@ -84,9 +84,10 @@ namespace TEngine
rootModule.Shutdown();
rootModule = null;
}
_modules.Clear();
GameModule.Shutdown(shutdownType);
if (shutdownType == ShutdownType.None)
{
return;

View File

@@ -62,7 +62,7 @@ namespace TEngine
private void OnDestroy()
{
if (_operationHandle != null)
if (_operationHandle is { IsValid: true })
{
_operationHandle.Release();
_operationHandle = null;

View File

@@ -0,0 +1,28 @@
namespace TEngine
{
/// <summary>
/// 资源管理日志实现器。
/// </summary>
internal class AssetsLogger : YooAsset.ILogger
{
public void Log(string message)
{
TEngine.Log.Info(message);
}
public void Warning(string message)
{
TEngine.Log.Warning(message);
}
public void Error(string message)
{
TEngine.Log.Error(message);
}
public void Exception(System.Exception exception)
{
TEngine.Log.Fatal(exception.Message);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fb010b07ce0e492dae9f04e18a1af2e2
timeCreated: 1698250627

View File

@@ -165,9 +165,10 @@ namespace TEngine
/// </summary>
/// <param name="location">资源的定位地址。</param>
/// <param name="needInstance">是否需要实例化。</param>
/// <param name="needCache">是否需要缓存。</param>
/// <typeparam name="T">要加载资源的类型。</typeparam>
/// <returns>资源实例。</returns>
T LoadAsset<T>(string location, bool needInstance) where T : Object;
T LoadAsset<T>(string location, bool needInstance, bool needCache = false) where T : Object;
/// <summary>
/// 同步加载资源。
@@ -175,18 +176,20 @@ namespace TEngine
/// <param name="location">资源的定位地址。</param>
/// <param name="parent">父节点位置。</param>
/// <param name="needInstance">是否需要实例化。</param>
/// <param name="needCache">是否需要缓存。</param>
/// <typeparam name="T">要加载资源的类型。</typeparam>
/// <returns>资源实例。</returns>
T LoadAsset<T>(string location, Transform parent, bool needInstance) where T : Object;
T LoadAsset<T>(string location, Transform parent, bool needInstance, bool needCache = false) where T : Object;
/// <summary>
/// 同步加载资源。
/// </summary>
/// <param name="handle">资源操作句柄。</param>
/// <param name="location">资源的定位地址。</param>
/// <param name="needCache">是否需要缓存。</param>
/// <typeparam name="T">要加载资源的类型。</typeparam>
/// <returns>资源实例。</returns>
T LoadAsset<T>(string location, out AssetOperationHandle handle) where T : Object;
T LoadAsset<T>(string location, out AssetOperationHandle handle, bool needCache = false) where T : Object;
/// <summary>
/// 同步加载资源。
@@ -194,25 +197,28 @@ namespace TEngine
/// <param name="location">资源的定位地址。</param>
/// <param name="handle">资源操作句柄。</param>
/// <param name="parent">父节点位置。</param>
/// <param name="needCache">是否需要缓存。</param>
/// <typeparam name="T">要加载资源的类型。</typeparam>
/// <returns>资源实例。</returns>
T LoadAsset<T>(string location, Transform parent, out AssetOperationHandle handle) where T : Object;
T LoadAsset<T>(string location, Transform parent, out AssetOperationHandle handle, bool needCache = false) where T : Object;
/// <summary>
/// 同步加载资源并获取句柄。
/// </summary>
/// <param name="location">资源的定位地址。</param>
/// <param name="needCache">是否需要缓存。</param>
/// <typeparam name="T">要加载资源的类型。</typeparam>
/// <returns>同步加载资源句柄。</returns>
AssetOperationHandle LoadAssetGetOperation<T>(string location) where T : Object;
AssetOperationHandle LoadAssetGetOperation<T>(string location, bool needCache = false) where T : Object;
/// <summary>
/// 异步加载资源并获取句柄。
/// </summary>
/// <param name="location">资源的定位地址。</param>
/// <param name="needCache">是否需要缓存。</param>
/// <typeparam name="T">要加载资源的类型。</typeparam>
/// <returns>异步加载资源句柄。</returns>
AssetOperationHandle LoadAssetAsyncHandle<T>(string location) where T : Object;
AssetOperationHandle LoadAssetAsyncHandle<T>(string location, bool needCache = false) where T : Object;
/// <summary>
/// 同步加载子资源对象。
@@ -242,44 +248,25 @@ namespace TEngine
/// <returns>资源对象集合。</returns>
UniTask<List<T>> LoadAssetsByTagAsync<T>(string assetTag) where T : UnityEngine.Object;
/// <summary>
/// 异步加载场景。
/// </summary>
/// <param name="location">场景的定位地址。</param>
/// <param name="sceneMode">场景加载模式。</param>
/// <param name="suspendLoad">加载完毕时是否主动挂起。</param>
/// <param name="priority">优先级。</param>
/// <returns>异步加载场景句柄。</returns>
SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, int priority = 100);
/// <summary>
/// 异步加载场景.
/// </summary>
/// <param name="assetInfo">场景的资源信息。</param>
/// <param name="sceneMode">场景加载模式。</param>
/// <param name="suspendLoad">加载完毕时是否主动挂起。</param>
/// <param name="priority">优先级。</param>
/// <returns>异步加载场景句柄。</returns>
SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false,
int priority = 100);
/// <summary>
/// 异步加载资源。
/// </summary>
/// <param name="location">资源定位地址。</param>
/// <param name="cancellationToken">取消操作Token。</param>
/// <param name="needInstance">是否需要实例化。</param>
/// <param name="needCache">是否需要缓存。</param>
/// <typeparam name="T">要加载资源的类型。</typeparam>
/// <returns>异步资源实例。</returns>
UniTask<T> LoadAssetAsync<T>(string location, CancellationToken cancellationToken = default, bool needInstance = true) where T : Object;
UniTask<T> LoadAssetAsync<T>(string location, CancellationToken cancellationToken = default, bool needInstance = true, bool needCache = false) where T : Object;
/// <summary>
/// 异步加载游戏物体。
/// </summary>
/// <param name="location">资源定位地址。</param>
/// <param name="cancellationToken">取消操作Token。</param>
/// <param name="needCache">是否需要缓存。</param>
/// <returns>异步游戏物体实例。</returns>
UniTask<GameObject> LoadGameObjectAsync(string location, CancellationToken cancellationToken = default);
UniTask<GameObject> LoadGameObjectAsync(string location, CancellationToken cancellationToken = default, bool needCache = false);
/// <summary>
/// 异步加载游戏物体。
@@ -287,8 +274,9 @@ namespace TEngine
/// <param name="location">资源定位地址。</param>
/// <param name="parent">父节点位置。</param>
/// <param name="cancellationToken">取消操作Token。</param>
/// <param name="needCache">是否需要缓存。</param>
/// <returns>异步游戏物体实例。</returns>
UniTask<GameObject> LoadGameObjectAsync(string location, Transform parent, CancellationToken cancellationToken = default);
UniTask<GameObject> LoadGameObjectAsync(string location, Transform parent, CancellationToken cancellationToken = default, bool needCache = false);
/// <summary>
/// 异步加载原生文件。
@@ -316,17 +304,5 @@ namespace TEngine
/// <typeparam name="T">资源实例类型。</typeparam>
/// <returns>原生文件资源实例。</returns>
UniTask<T[]> LoadAllSubAssetAsync<T>(string location, CancellationToken cancellationToken = default) where T : Object;
/// <summary>
/// 异步加载场景。
/// </summary>
/// <param name="location">场景的定位地址。</param>
/// <param name="cancellationToken">取消操作Token。</param>
/// <param name="sceneMode">场景加载模式。</param>
/// <param name="activateOnLoad">加载完毕时是否主动激活。</param>
/// <param name="priority">优先级。</param>
/// <returns>场景资源实例。</returns>
UniTask<Scene> LoadSceneAsyncByUniTask(string location, CancellationToken cancellationToken = default, LoadSceneMode sceneMode = LoadSceneMode.Single,
bool activateOnLoad = true, int priority = 100);
}
}

Some files were not shown because too many files have changed in this diff Show More