Skip to content

Commit 7acd9fd

Browse files
committed
feat: 扩展 EditorConfig 配置,新增 TMP 精灵图集管理器,优化资源加载和 UI 组件
- 扩展 .editorconfig 文件,添加详细的 C# 编码规范和格式化规则 - 新增 TMPSpriteAtlasManager.cs 用于管理 TextMesh Pro 精灵图集 - 优化 AssetBundleManager 资源加载逻辑 - 优化 ModelManager 模型管理功能 - 更新项目文件依赖配置 - 更新 CHANGELOG 和 README 文档 - 统一代码风格和编码规范以提高项目可维护性
1 parent 472f5b9 commit 7acd9fd

18 files changed

Lines changed: 834 additions & 307 deletions

.editorconfig

Lines changed: 282 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,294 @@
1-
# EditorConfig is awesome: https://EditorConfig.org
2-
3-
# top-most EditorConfig file
41
root = true
2+
# 如果要从更高级别的目录继承 .editorconfig 设置,请删除以下行
53

6-
# All files
7-
[*]
8-
charset = utf-8
9-
end_of_line = crlf
10-
insert_final_newline = true
11-
trim_trailing_whitespace = true
12-
13-
# C# files
4+
# c# 文件
145
[*.cs]
15-
indent_style = space
16-
indent_size = 4
176

18-
# JSON files
19-
[*.json]
7+
#### Core EditorConfig 选项 ####
8+
9+
# 缩进和间距
10+
indent_size = 4
2011
indent_style = space
21-
indent_size = 2
12+
tab_width = 4
2213

23-
# Markdown files
24-
[*.md]
25-
trim_trailing_whitespace = false
14+
# 新行首选项
15+
insert_final_newline = true
2616

27-
# Project files
28-
[*.{csproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
29-
indent_style = space
30-
indent_size = 2
17+
#### .NET 代码操作 ####
18+
19+
# 类型成员
20+
dotnet_hide_advanced_members = false
21+
dotnet_member_insertion_location = with_other_members_of_the_same_kind
22+
dotnet_property_generation_behavior = prefer_throwing_properties
23+
24+
# 符号搜索
25+
dotnet_search_reference_assemblies = true
26+
27+
#### .NET 编码约定 ####
28+
29+
# 组织 Using
30+
dotnet_separate_import_directive_groups = false
31+
32+
# this. 和 Me. 首选项
33+
dotnet_style_qualification_for_event = false:suggestion
34+
dotnet_style_qualification_for_field = false:suggestion
35+
dotnet_style_qualification_for_method = false:suggestion
36+
dotnet_style_qualification_for_property = false:suggestion
37+
38+
# 语言关键字与 bcl 类型首选项
39+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
40+
dotnet_style_predefined_type_for_member_access = true:suggestion
41+
42+
# 括号首选项
43+
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
44+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none
45+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
46+
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
47+
48+
# 修饰符首选项
49+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
50+
51+
# 表达式级首选项
52+
dotnet_prefer_system_hash_code = true
53+
dotnet_style_coalesce_expression = true
54+
dotnet_style_collection_initializer = true
55+
dotnet_style_explicit_tuple_names = true
56+
dotnet_style_namespace_match_folder = true
57+
dotnet_style_null_propagation = true
58+
dotnet_style_object_initializer = true
59+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
60+
dotnet_style_prefer_auto_properties = true
61+
dotnet_style_prefer_collection_expression = when_types_loosely_match
62+
dotnet_style_prefer_compound_assignment = true
63+
dotnet_style_prefer_conditional_expression_over_assignment = true
64+
dotnet_style_prefer_conditional_expression_over_return = true
65+
dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
66+
dotnet_style_prefer_inferred_anonymous_type_member_names = true
67+
dotnet_style_prefer_inferred_tuple_names = true
68+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
69+
dotnet_style_prefer_simplified_boolean_expressions = true
70+
dotnet_style_prefer_simplified_interpolation = true
71+
72+
# 字段首选项
73+
dotnet_style_readonly_field = true
74+
75+
# 参数首选项
76+
dotnet_code_quality_unused_parameters = all
77+
78+
# 禁止显示首选项
79+
dotnet_remove_unnecessary_suppression_exclusions = none
80+
81+
# 新行首选项
82+
dotnet_style_allow_multiple_blank_lines_experimental = true
83+
dotnet_style_allow_statement_immediately_after_block_experimental = true
84+
85+
#### c# 编码约定 ####
86+
87+
# var 首选项
88+
csharp_style_var_elsewhere = true:suggestion
89+
csharp_style_var_for_built_in_types = true:suggestion
90+
csharp_style_var_when_type_is_apparent = true:suggestion
91+
92+
# Expression-bodied 成员
93+
csharp_style_expression_bodied_accessors = true
94+
csharp_style_expression_bodied_constructors = false
95+
csharp_style_expression_bodied_indexers = true
96+
csharp_style_expression_bodied_lambdas = true
97+
csharp_style_expression_bodied_local_functions = false
98+
csharp_style_expression_bodied_methods = false
99+
csharp_style_expression_bodied_operators = false
100+
csharp_style_expression_bodied_properties = true
101+
102+
# 模式匹配首选项
103+
csharp_style_pattern_matching_over_as_with_null_check = true
104+
csharp_style_pattern_matching_over_is_with_cast_check = true
105+
csharp_style_prefer_extended_property_pattern = true
106+
csharp_style_prefer_not_pattern = true
107+
csharp_style_prefer_pattern_matching = true
108+
csharp_style_prefer_switch_expression = true
109+
110+
# Null 检查首选项
111+
csharp_style_conditional_delegate_call = true
31112

32-
# XML project files
33-
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
113+
# 修饰符首选项
114+
csharp_prefer_static_anonymous_function = true
115+
csharp_prefer_static_local_function = true
116+
csharp_preferred_modifier_order = public, private, protected, internal, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion
117+
csharp_style_prefer_readonly_struct = true
118+
csharp_style_prefer_readonly_struct_member = true
119+
120+
# 代码块首选项
121+
csharp_prefer_braces = true
122+
csharp_prefer_simple_using_statement = true
123+
csharp_prefer_system_threading_lock = true
124+
csharp_style_namespace_declarations = block_scoped:suggestion
125+
csharp_style_prefer_method_group_conversion = true
126+
csharp_style_prefer_primary_constructors = true
127+
csharp_style_prefer_top_level_statements = true
128+
129+
# 表达式级首选项
130+
csharp_prefer_simple_default_expression = true
131+
csharp_style_deconstructed_variable_declaration = true
132+
csharp_style_implicit_object_creation_when_type_is_apparent = true
133+
csharp_style_inlined_variable_declaration = true
134+
csharp_style_prefer_index_operator = true
135+
csharp_style_prefer_local_over_anonymous_function = true
136+
csharp_style_prefer_null_check_over_type_check = true
137+
csharp_style_prefer_range_operator = true
138+
csharp_style_prefer_tuple_swap = true
139+
csharp_style_prefer_utf8_string_literals = true:suggestion
140+
csharp_style_throw_expression = true
141+
csharp_style_unused_value_assignment_preference = discard_variable
142+
csharp_style_unused_value_expression_statement_preference = discard_variable
143+
144+
# "using" 指令首选项
145+
146+
# 新行首选项
147+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
148+
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true
149+
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true
150+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
151+
csharp_style_allow_embedded_statements_on_same_line_experimental = true
152+
153+
#### C# 格式规则 ####
154+
155+
# 新行首选项
156+
csharp_new_line_before_catch = true
157+
csharp_new_line_before_else = true
158+
csharp_new_line_before_finally = true
159+
csharp_new_line_before_members_in_anonymous_types = true
160+
csharp_new_line_before_members_in_object_initializers = false
161+
csharp_new_line_before_open_brace = all
162+
csharp_new_line_between_query_expression_clauses = true
163+
164+
# 缩进首选项
165+
csharp_indent_block_contents = true
166+
csharp_indent_braces = false
167+
csharp_indent_case_contents = true
168+
csharp_indent_case_contents_when_block = true
169+
csharp_indent_labels = flush_left
170+
csharp_indent_switch_labels = true
171+
172+
# 空格键首选项
173+
csharp_space_after_cast = false
174+
csharp_space_after_colon_in_inheritance_clause = true
175+
csharp_space_after_comma = true
176+
csharp_space_after_dot = false
177+
csharp_space_after_keywords_in_control_flow_statements = true
178+
csharp_space_after_semicolon_in_for_statement = true
179+
csharp_space_around_binary_operators = before_and_after
180+
csharp_space_around_declaration_statements = false
181+
csharp_space_before_colon_in_inheritance_clause = true
182+
csharp_space_before_comma = false
183+
csharp_space_before_dot = false
184+
csharp_space_before_open_square_brackets = false
185+
csharp_space_before_semicolon_in_for_statement = false
186+
csharp_space_between_empty_square_brackets = false
187+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
188+
csharp_space_between_method_call_name_and_opening_parenthesis = false
189+
csharp_space_between_method_call_parameter_list_parentheses = false
190+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
191+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
192+
csharp_space_between_method_declaration_parameter_list_parentheses = false
193+
csharp_space_between_parentheses = false
194+
csharp_space_between_square_brackets = false
195+
196+
# 包装首选项
197+
csharp_preserve_single_line_blocks = true
198+
csharp_preserve_single_line_statements = true
199+
200+
#### 命名样式 ####
201+
202+
# 命名规则
203+
204+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
205+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
206+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
207+
208+
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
209+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
210+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
211+
212+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
213+
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
214+
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
215+
216+
# 符号规范
217+
218+
dotnet_naming_symbols.interface.applicable_kinds = interface
219+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
220+
dotnet_naming_symbols.interface.required_modifiers =
221+
222+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
223+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
224+
dotnet_naming_symbols.types.required_modifiers =
225+
226+
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
227+
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
228+
dotnet_naming_symbols.non_field_members.required_modifiers =
229+
230+
# 命名样式
231+
232+
dotnet_naming_style.pascal_case.required_prefix =
233+
dotnet_naming_style.pascal_case.required_suffix =
234+
dotnet_naming_style.pascal_case.word_separator =
235+
dotnet_naming_style.pascal_case.capitalization = pascal_case
236+
237+
dotnet_naming_style.begins_with_i.required_prefix = I
238+
dotnet_naming_style.begins_with_i.required_suffix =
239+
dotnet_naming_style.begins_with_i.word_separator =
240+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
241+
242+
# ReSharper properties
243+
resharper_apply_on_completion = true
244+
resharper_braces_for_for = not_required
245+
resharper_braces_for_foreach = not_required
246+
resharper_braces_for_ifelse = not_required_for_both
247+
resharper_braces_for_while = not_required
248+
resharper_braces_redundant = true
249+
resharper_cpp_insert_final_newline = true
250+
resharper_csharp_brace_style = next_line
251+
resharper_csharp_keep_existing_enum_arrangement = false
252+
resharper_keep_existing_declaration_block_arrangement = false
253+
resharper_keep_existing_embedded_block_arrangement = false
254+
resharper_object_creation_when_type_not_evident = target_typed
255+
resharper_trailing_comma_in_multiline_lists = true
256+
resharper_use_heuristics_for_body_style = true
257+
258+
# ReSharper inspection severities
259+
resharper_arrange_namespace_body_highlighting = hint
260+
resharper_arrange_redundant_parentheses_highlighting = hint
261+
resharper_arrange_this_qualifier_highlighting = hint
262+
resharper_arrange_type_member_modifiers_highlighting = hint
263+
resharper_arrange_type_modifiers_highlighting = hint
264+
resharper_async_apostle_async_await_may_be_elided_highlighting_highlighting = none
265+
resharper_async_void_method_highlighting = none
266+
resharper_built_in_type_reference_style_for_member_access_highlighting = hint
267+
resharper_built_in_type_reference_style_highlighting = hint
268+
resharper_check_namespace_highlighting = none
269+
resharper_class_never_instantiated_global_highlighting = none
270+
resharper_function_never_returns_highlighting = none
271+
resharper_member_can_be_private_global_highlighting = none
272+
resharper_not_accessed_field_local_highlighting = none
273+
resharper_public_constructor_in_abstract_class_highlighting = none
274+
resharper_redundant_base_qualifier_highlighting = warning
275+
resharper_suggest_var_or_type_built_in_types_highlighting = hint
276+
resharper_suggest_var_or_type_elsewhere_highlighting = hint
277+
resharper_suggest_var_or_type_simple_types_highlighting = hint
278+
resharper_switch_statement_handles_some_known_enum_values_with_default_highlighting = none
279+
resharper_switch_statement_missing_some_enum_cases_no_default_highlighting = none
280+
281+
[*.{appxmanifest,axml,blockshader,build,c,c++,c++m,cc,ccm,cginc,compute,config,cp,cpp,cppm,cshtml,csproj,cu,cuh,cxx,cxxm,dbml,discomap,dtd,fx,fxh,h,h++,hh,hlsl,hlsli,hlslinc,hp,hpp,htm,html,hxx,icc,inc,inl,ino,ipp,ixx,jsproj,lsproj,mpp,mq4,mq5,mqh,mxx,njsproj,nuspec,proj,props,proto,razor,resw,resx,shaderFoundry,StyleCop,targets,tasks,tcc,tpp,urtshader,usf,ush,vbproj,xml,xsd}]
282+
indent_style = tab
283+
indent_size = tab
284+
tab_width = 4
285+
286+
[*.{asax,ascx,aspx,axaml,cs,css,js,jsx,master,paml,skin,ts,tsx,vb,xaml,xamlx,xoml}]
34287
indent_style = space
35-
indent_size = 2
288+
indent_size = 4
289+
tab_width = 4
36290

37-
# XML documentation files
38-
[*.{csproj,vcxproj,vcxproj.filters,proj,projitems,shproj}.sln]
291+
[*.{json,resjson}]
39292
indent_style = space
40293
indent_size = 2
41-
294+
tab_width = 2

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
[English](CHANGELOG_EN.md) | 中文
44

5+
## 未发布
6+
7+
### 新增
8+
9+
- 新增 TMP Sprite Atlas 支持
10+
-`bundleinfo.json` 中添加 `SpriteAtlasPaths` 字段,可指定 TextMeshPro Sprite Asset 路径
11+
- 系统会自动加载并注册图集到 TMP 的全局 fallback sprite assets 列表
12+
- 支持在 TMP 文本中使用 `<sprite name="sprite_name">` 语法引用自定义 Sprite
13+
- Bundle 卸载时自动注销相关图集
14+
15+
### API 变更
16+
17+
- `ModelBundleInfo` 新增 `SpriteAtlasPaths` 属性(可选)
18+
- `AssetBundleManager` 新增方法:
19+
- `LoadSpriteAtlases<T>(ModelBundleInfo)` - 同步加载图集
20+
- `LoadSpriteAtlasesAsync<T>(ModelBundleInfo, CancellationToken)` - 异步加载图集
21+
- 新增 `TMPSpriteAtlasManager` 类,用于管理 TMP Sprite Asset 的生命周期
22+
523
## v1.11.1
624

725
- 补充了一个特殊的音频替换逻辑,以允许替换一些特定事件

CHANGELOG_EN.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
English | [中文](CHANGELOG.md)
44

5+
## Unreleased
6+
7+
### Added
8+
9+
- Added TMP Sprite Atlas support
10+
- Add `SpriteAtlasPaths` field in `bundleinfo.json` to specify TextMeshPro Sprite Asset paths
11+
- System automatically loads and registers atlases to TMP's global fallback sprite assets list
12+
- Support using `<sprite name="sprite_name">` syntax in TMP text to reference custom sprites
13+
- Automatically unregister atlases when bundle is unloaded
14+
15+
### API Changes
16+
17+
- `ModelBundleInfo` added `SpriteAtlasPaths` property (optional)
18+
- `AssetBundleManager` added methods:
19+
- `LoadSpriteAtlases<T>(ModelBundleInfo)` - Synchronously load atlases
20+
- `LoadSpriteAtlasesAsync<T>(ModelBundleInfo, CancellationToken)` - Asynchronously load atlases
21+
- Added `TMPSpriteAtlasManager` class for managing TMP Sprite Asset lifecycle
22+
523
## v1.11.1
624

725
- Added a special audio replacement logic to allow replacing certain events

DuckovCustomModel.Core/Data/ModelBundleInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class ModelBundleInfo
1212

1313
public ModelInfo[] Models { get; set; } = [];
1414

15+
public string[]? SpriteAtlasPaths { get; set; }
16+
1517
[JsonIgnore] public string DirectoryPath { get; internal set; } = string.Empty;
1618

1719
public static ModelBundleInfo? LoadFromDirectory(string directoryPath,
@@ -54,6 +56,7 @@ public ModelBundleInfo CreateFilteredCopy(ModelInfo[] filteredModels)
5456
BundlePath = BundlePath,
5557
Models = filteredModels,
5658
DirectoryPath = DirectoryPath,
59+
SpriteAtlasPaths = SpriteAtlasPaths,
5760
};
5861
return copy;
5962
}

0 commit comments

Comments
 (0)