mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
TE6 打飞机Demo
TE6 打飞机Demo
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 6635aa4e94cc66546b8b89c48f0a0099
|
guid: 9afd4d88f7b567341823779947b83bd9
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
@@ -1,40 +1,48 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root Version="2.4">
|
<root Version="v2.0.0">
|
||||||
<Common AutoAddressable="True" UniqueBundleName="False" ShowPackageView="False" ShowEditorAlias="False" />
|
<Common ShowPackageView="True" ShowEditorAlias="False" UniqueBundleName="True" />
|
||||||
<Package PackageName="DefaultPackage" PackageDesc="默认资源包">
|
<Package PackageName="DefaultPackage" PackageDesc="" AutoAddressable="True" LocationToLower="False" IncludeAssetGUID="False" IgnoreDefaultType="True">
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="Actor" GroupDesc="角色" AssetTags="Actor">
|
<Group GroupActiveRule="EnableGroup" GroupName="Actor" GroupDesc="" AssetTags="">
|
||||||
<Collector CollectPath="Assets/AssetRaw/Actor" CollectGUID="9c67ce0c9edfd4e4aa1006ee39846d66" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/AssetRaw/Actor" CollectGUID="9c67ce0c9edfd4e4aa1006ee39846d66" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="UIRaw" GroupDesc="图片资源" AssetTags="UIRaw">
|
<Group GroupActiveRule="EnableGroup" GroupName="Audios" GroupDesc="" AssetTags="">
|
||||||
|
<Collector CollectPath="Assets/AssetRaw/Audios" CollectGUID="8ef7a411b66e70f4cb65c2233c9a0868" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
|
</Group>
|
||||||
|
<Group GroupActiveRule="EnableGroup" GroupName="Configs" GroupDesc="" AssetTags="">
|
||||||
|
<Collector CollectPath="Assets/AssetRaw/Configs" CollectGUID="dd2928019aef34248af368b99bc53bea" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
|
</Group>
|
||||||
|
<Group GroupActiveRule="EnableGroup" GroupName="DLL" GroupDesc="" AssetTags="">
|
||||||
|
<Collector CollectPath="Assets/AssetRaw/DLL" CollectGUID="3aad79ec1ea08c24c891bd3c669d4125" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
|
</Group>
|
||||||
|
<Group GroupActiveRule="EnableGroup" GroupName="Effects" GroupDesc="" AssetTags="">
|
||||||
|
<Collector CollectPath="Assets/AssetRaw/Effects" CollectGUID="0fe175e1e1bd49a4ca71e66b6a9b7237" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
|
</Group>
|
||||||
|
<Group GroupActiveRule="EnableGroup" GroupName="Fonts" GroupDesc="" AssetTags="">
|
||||||
|
<Collector CollectPath="Assets/AssetRaw/Fonts" CollectGUID="2473375c9ee163a4b861278b38091455" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
|
</Group>
|
||||||
|
<Group GroupActiveRule="EnableGroup" GroupName="Materials" GroupDesc="" AssetTags="">
|
||||||
|
<Collector CollectPath="Assets/AssetRaw/Materials" CollectGUID="228b1547e7065d546ad0bf215fd6a276" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
|
</Group>
|
||||||
|
<Group GroupActiveRule="EnableGroup" GroupName="Scenes" GroupDesc="" AssetTags="">
|
||||||
|
<Collector CollectPath="Assets/AssetRaw/Scenes" CollectGUID="cace6ee6539f661419b5e5f8ae1c0146" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
|
</Group>
|
||||||
|
<Group GroupActiveRule="EnableGroup" GroupName="UI" GroupDesc="" AssetTags="">
|
||||||
|
<Collector CollectPath="Assets/AssetRaw/UI" CollectGUID="27e87d83814156648b58f380b834e046" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
|
</Group>
|
||||||
|
<Group GroupActiveRule="EnableGroup" GroupName="UIRaw" GroupDesc="" AssetTags="">
|
||||||
<Collector CollectPath="Assets/AssetRaw/UIRaw/Atlas" CollectGUID="6d11fa91acc253840a648b58f23db139" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/AssetRaw/UIRaw/Atlas" CollectGUID="6d11fa91acc253840a648b58f23db139" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
<Collector CollectPath="Assets/AssetRaw/UIRaw/Raw" CollectGUID="6bc134b912ac6bb4399ea1bec4c11636" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Collector CollectPath="Assets/AssetRaw/UIRaw/Raw" CollectGUID="6bc134b912ac6bb4399ea1bec4c11636" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
||||||
</Group>
|
</Group>
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="Audios" GroupDesc="音频" AssetTags="Audios">
|
</Package>
|
||||||
<Collector CollectPath="Assets/AssetRaw/Audios" CollectGUID="8ef7a411b66e70f4cb65c2233c9a0868" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Package PackageName="OtherPackage" PackageDesc="" AutoAddressable="True" LocationToLower="False" IncludeAssetGUID="False" IgnoreDefaultType="True">
|
||||||
</Group>
|
<Group GroupActiveRule="EnableGroup" GroupName="ModelGroup" GroupDesc="" AssetTags="models" />
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="Configs" GroupDesc="配置表" AssetTags="Configs">
|
<Group GroupActiveRule="EnableGroup" GroupName="SceneGroup" GroupDesc="" AssetTags="scenes" />
|
||||||
<Collector CollectPath="Assets/AssetRaw/Configs" CollectGUID="dd2928019aef34248af368b99bc53bea" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
</Package>
|
||||||
</Group>
|
<Package PackageName="Dlc1Package" PackageDesc="" AutoAddressable="True" LocationToLower="False" IncludeAssetGUID="False" IgnoreDefaultType="True">
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="DLL" GroupDesc="代码" AssetTags="DLL">
|
<Group GroupActiveRule="EnableGroup" GroupName="ModelGroup" GroupDesc="" AssetTags="models" />
|
||||||
<Collector CollectPath="Assets/AssetRaw/DLL" CollectGUID="3aad79ec1ea08c24c891bd3c669d4125" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Group GroupActiveRule="EnableGroup" GroupName="SceneGroup" GroupDesc="" AssetTags="scenes" />
|
||||||
</Group>
|
</Package>
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="Effects" GroupDesc="特效" AssetTags="Effects">
|
<Package PackageName="Dlc2Package" PackageDesc="" AutoAddressable="True" LocationToLower="False" IncludeAssetGUID="False" IgnoreDefaultType="True">
|
||||||
<Collector CollectPath="Assets/AssetRaw/Effects" CollectGUID="0fe175e1e1bd49a4ca71e66b6a9b7237" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
<Group GroupActiveRule="EnableGroup" GroupName="ModelGroup" GroupDesc="" AssetTags="models" />
|
||||||
</Group>
|
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="Materials" GroupDesc="材质球" AssetTags="Materials">
|
|
||||||
<Collector CollectPath="Assets/AssetRaw/Materials" CollectGUID="228b1547e7065d546ad0bf215fd6a276" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
|
||||||
</Group>
|
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="Scenes" GroupDesc="场景" AssetTags="Scenes">
|
|
||||||
<Collector CollectPath="Assets/AssetRaw/Scenes" CollectGUID="cace6ee6539f661419b5e5f8ae1c0146" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" UserData="" AssetTags="" />
|
|
||||||
</Group>
|
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="Shaders" GroupDesc="着色器" AssetTags="Shaders">
|
|
||||||
<Collector CollectPath="Assets/AssetRaw/Shaders" CollectGUID="2a4bceb84ed685447ace957f497eb810" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectShaderVariants" UserData="" AssetTags="" />
|
|
||||||
</Group>
|
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="UI" GroupDesc="UI面板" AssetTags="UI">
|
|
||||||
<Collector CollectPath="Assets/AssetRaw/UI" CollectGUID="27e87d83814156648b58f380b834e046" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectAll" UserData="" AssetTags="" />
|
|
||||||
</Group>
|
|
||||||
<Group GroupActiveRule="EnableGroup" GroupName="Fonts" GroupDesc="字体" AssetTags="Fonts">
|
|
||||||
<Collector CollectPath="Assets/AssetRaw/Fonts" CollectGUID="2473375c9ee163a4b861278b38091455" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
|
|
||||||
</Group>
|
|
||||||
</Package>
|
</Package>
|
||||||
</root>
|
</root>
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 218816e46e4f6304eaecd6fdc3a99f4d
|
guid: 40551812c908533438dbfc2b727c9950
|
||||||
TextScriptImporter:
|
TextScriptImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
@@ -12,12 +12,12 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 185f6993d5150494d98da50e26cb1c25, type: 3}
|
m_Script: {fileID: 11500000, guid: 185f6993d5150494d98da50e26cb1c25, type: 3}
|
||||||
m_Name: AssetBundleCollectorSetting
|
m_Name: AssetBundleCollectorSetting
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
ShowPackageView: 0
|
ShowPackageView: 1
|
||||||
ShowEditorAlias: 0
|
ShowEditorAlias: 0
|
||||||
UniqueBundleName: 0
|
UniqueBundleName: 1
|
||||||
Packages:
|
Packages:
|
||||||
- PackageName: DefaultPackage
|
- PackageName: DefaultPackage
|
||||||
PackageDesc: "\u9ED8\u8BA4\u8D44\u6E90\u5305"
|
PackageDesc:
|
||||||
EnableAddressable: 1
|
EnableAddressable: 1
|
||||||
LocationToLower: 0
|
LocationToLower: 0
|
||||||
IncludeAssetGUID: 0
|
IncludeAssetGUID: 0
|
||||||
@@ -25,8 +25,8 @@ MonoBehaviour:
|
|||||||
AutoCollectShaders: 1
|
AutoCollectShaders: 1
|
||||||
Groups:
|
Groups:
|
||||||
- GroupName: Actor
|
- GroupName: Actor
|
||||||
GroupDesc: "\u89D2\u8272"
|
GroupDesc:
|
||||||
AssetTags: Actor
|
AssetTags:
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors:
|
||||||
- CollectPath: Assets/AssetRaw/Actor
|
- CollectPath: Assets/AssetRaw/Actor
|
||||||
@@ -37,9 +37,113 @@ MonoBehaviour:
|
|||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
UserData:
|
UserData:
|
||||||
|
- GroupName: Audios
|
||||||
|
GroupDesc:
|
||||||
|
AssetTags:
|
||||||
|
ActiveRuleName: EnableGroup
|
||||||
|
Collectors:
|
||||||
|
- CollectPath: Assets/AssetRaw/Audios
|
||||||
|
CollectorGUID: 8ef7a411b66e70f4cb65c2233c9a0868
|
||||||
|
CollectorType: 0
|
||||||
|
AddressRuleName: AddressByFileName
|
||||||
|
PackRuleName: PackDirectory
|
||||||
|
FilterRuleName: CollectAll
|
||||||
|
AssetTags:
|
||||||
|
UserData:
|
||||||
|
- GroupName: Configs
|
||||||
|
GroupDesc:
|
||||||
|
AssetTags:
|
||||||
|
ActiveRuleName: EnableGroup
|
||||||
|
Collectors:
|
||||||
|
- CollectPath: Assets/AssetRaw/Configs
|
||||||
|
CollectorGUID: dd2928019aef34248af368b99bc53bea
|
||||||
|
CollectorType: 0
|
||||||
|
AddressRuleName: AddressByFileName
|
||||||
|
PackRuleName: PackDirectory
|
||||||
|
FilterRuleName: CollectAll
|
||||||
|
AssetTags:
|
||||||
|
UserData:
|
||||||
|
- GroupName: DLL
|
||||||
|
GroupDesc:
|
||||||
|
AssetTags:
|
||||||
|
ActiveRuleName: EnableGroup
|
||||||
|
Collectors:
|
||||||
|
- CollectPath: Assets/AssetRaw/DLL
|
||||||
|
CollectorGUID: 3aad79ec1ea08c24c891bd3c669d4125
|
||||||
|
CollectorType: 0
|
||||||
|
AddressRuleName: AddressByFileName
|
||||||
|
PackRuleName: PackDirectory
|
||||||
|
FilterRuleName: CollectAll
|
||||||
|
AssetTags:
|
||||||
|
UserData:
|
||||||
|
- GroupName: Effects
|
||||||
|
GroupDesc:
|
||||||
|
AssetTags:
|
||||||
|
ActiveRuleName: EnableGroup
|
||||||
|
Collectors:
|
||||||
|
- CollectPath: Assets/AssetRaw/Effects
|
||||||
|
CollectorGUID: 0fe175e1e1bd49a4ca71e66b6a9b7237
|
||||||
|
CollectorType: 0
|
||||||
|
AddressRuleName: AddressByFileName
|
||||||
|
PackRuleName: PackDirectory
|
||||||
|
FilterRuleName: CollectAll
|
||||||
|
AssetTags:
|
||||||
|
UserData:
|
||||||
|
- GroupName: Fonts
|
||||||
|
GroupDesc:
|
||||||
|
AssetTags:
|
||||||
|
ActiveRuleName: EnableGroup
|
||||||
|
Collectors:
|
||||||
|
- CollectPath: Assets/AssetRaw/Fonts
|
||||||
|
CollectorGUID: 2473375c9ee163a4b861278b38091455
|
||||||
|
CollectorType: 0
|
||||||
|
AddressRuleName: AddressByFileName
|
||||||
|
PackRuleName: PackDirectory
|
||||||
|
FilterRuleName: CollectAll
|
||||||
|
AssetTags:
|
||||||
|
UserData:
|
||||||
|
- GroupName: Materials
|
||||||
|
GroupDesc:
|
||||||
|
AssetTags:
|
||||||
|
ActiveRuleName: EnableGroup
|
||||||
|
Collectors:
|
||||||
|
- CollectPath: Assets/AssetRaw/Materials
|
||||||
|
CollectorGUID: 228b1547e7065d546ad0bf215fd6a276
|
||||||
|
CollectorType: 0
|
||||||
|
AddressRuleName: AddressByFileName
|
||||||
|
PackRuleName: PackDirectory
|
||||||
|
FilterRuleName: CollectAll
|
||||||
|
AssetTags:
|
||||||
|
UserData:
|
||||||
|
- GroupName: Scenes
|
||||||
|
GroupDesc:
|
||||||
|
AssetTags:
|
||||||
|
ActiveRuleName: EnableGroup
|
||||||
|
Collectors:
|
||||||
|
- CollectPath: Assets/AssetRaw/Scenes
|
||||||
|
CollectorGUID: cace6ee6539f661419b5e5f8ae1c0146
|
||||||
|
CollectorType: 0
|
||||||
|
AddressRuleName: AddressByFileName
|
||||||
|
PackRuleName: PackDirectory
|
||||||
|
FilterRuleName: CollectAll
|
||||||
|
AssetTags:
|
||||||
|
UserData:
|
||||||
|
- GroupName: UI
|
||||||
|
GroupDesc:
|
||||||
|
AssetTags:
|
||||||
|
ActiveRuleName: EnableGroup
|
||||||
|
Collectors:
|
||||||
|
- CollectPath: Assets/AssetRaw/UI
|
||||||
|
CollectorGUID: 27e87d83814156648b58f380b834e046
|
||||||
|
CollectorType: 0
|
||||||
|
AddressRuleName: AddressByFileName
|
||||||
|
PackRuleName: PackDirectory
|
||||||
|
FilterRuleName: CollectAll
|
||||||
|
AssetTags:
|
||||||
|
UserData:
|
||||||
- GroupName: UIRaw
|
- GroupName: UIRaw
|
||||||
GroupDesc: "\u56FE\u7247\u8D44\u6E90"
|
GroupDesc:
|
||||||
AssetTags: UIRaw
|
AssetTags:
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors:
|
||||||
- CollectPath: Assets/AssetRaw/UIRaw/Atlas
|
- CollectPath: Assets/AssetRaw/UIRaw/Atlas
|
||||||
@@ -58,120 +162,52 @@ MonoBehaviour:
|
|||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
UserData:
|
UserData:
|
||||||
- GroupName: Audios
|
- PackageName: OtherPackage
|
||||||
GroupDesc: "\u97F3\u9891"
|
PackageDesc:
|
||||||
AssetTags: Audios
|
EnableAddressable: 1
|
||||||
|
LocationToLower: 0
|
||||||
|
IncludeAssetGUID: 0
|
||||||
|
IgnoreDefaultType: 1
|
||||||
|
AutoCollectShaders: 1
|
||||||
|
Groups:
|
||||||
|
- GroupName: ModelGroup
|
||||||
|
GroupDesc:
|
||||||
|
AssetTags: models
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors: []
|
||||||
- CollectPath: Assets/AssetRaw/Audios
|
- GroupName: SceneGroup
|
||||||
CollectorGUID: 8ef7a411b66e70f4cb65c2233c9a0868
|
GroupDesc:
|
||||||
CollectorType: 0
|
AssetTags: scenes
|
||||||
AddressRuleName: AddressByFileName
|
|
||||||
PackRuleName: PackDirectory
|
|
||||||
FilterRuleName: CollectAll
|
|
||||||
AssetTags:
|
|
||||||
UserData:
|
|
||||||
- GroupName: Configs
|
|
||||||
GroupDesc: "\u914D\u7F6E\u8868"
|
|
||||||
AssetTags: Configs
|
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors: []
|
||||||
- CollectPath: Assets/AssetRaw/Configs
|
- PackageName: Dlc1Package
|
||||||
CollectorGUID: dd2928019aef34248af368b99bc53bea
|
PackageDesc:
|
||||||
CollectorType: 0
|
EnableAddressable: 1
|
||||||
AddressRuleName: AddressByFileName
|
LocationToLower: 0
|
||||||
PackRuleName: PackDirectory
|
IncludeAssetGUID: 0
|
||||||
FilterRuleName: CollectAll
|
IgnoreDefaultType: 1
|
||||||
AssetTags: WEBGL_PRELOAD
|
AutoCollectShaders: 1
|
||||||
UserData:
|
Groups:
|
||||||
- GroupName: DLL
|
- GroupName: ModelGroup
|
||||||
GroupDesc: "\u4EE3\u7801"
|
GroupDesc:
|
||||||
AssetTags: DLL
|
AssetTags: models
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors: []
|
||||||
- CollectPath: Assets/AssetRaw/DLL
|
- GroupName: SceneGroup
|
||||||
CollectorGUID: 3aad79ec1ea08c24c891bd3c669d4125
|
GroupDesc:
|
||||||
CollectorType: 0
|
AssetTags: scenes
|
||||||
AddressRuleName: AddressByFileName
|
|
||||||
PackRuleName: PackDirectory
|
|
||||||
FilterRuleName: CollectAll
|
|
||||||
AssetTags:
|
|
||||||
UserData:
|
|
||||||
- GroupName: Effects
|
|
||||||
GroupDesc: "\u7279\u6548"
|
|
||||||
AssetTags: Effects
|
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors: []
|
||||||
- CollectPath: Assets/AssetRaw/Effects
|
- PackageName: Dlc2Package
|
||||||
CollectorGUID: 0fe175e1e1bd49a4ca71e66b6a9b7237
|
PackageDesc:
|
||||||
CollectorType: 0
|
EnableAddressable: 1
|
||||||
AddressRuleName: AddressByFileName
|
LocationToLower: 0
|
||||||
PackRuleName: PackDirectory
|
IncludeAssetGUID: 0
|
||||||
FilterRuleName: CollectAll
|
IgnoreDefaultType: 1
|
||||||
AssetTags:
|
AutoCollectShaders: 1
|
||||||
UserData:
|
Groups:
|
||||||
- GroupName: Materials
|
- GroupName: ModelGroup
|
||||||
GroupDesc: "\u6750\u8D28\u7403"
|
GroupDesc:
|
||||||
AssetTags: Materials
|
AssetTags: models
|
||||||
ActiveRuleName: EnableGroup
|
ActiveRuleName: EnableGroup
|
||||||
Collectors:
|
Collectors: []
|
||||||
- CollectPath: Assets/AssetRaw/Materials
|
|
||||||
CollectorGUID: 228b1547e7065d546ad0bf215fd6a276
|
|
||||||
CollectorType: 0
|
|
||||||
AddressRuleName: AddressByFileName
|
|
||||||
PackRuleName: PackDirectory
|
|
||||||
FilterRuleName: CollectAll
|
|
||||||
AssetTags:
|
|
||||||
UserData:
|
|
||||||
- GroupName: Scenes
|
|
||||||
GroupDesc: "\u573A\u666F"
|
|
||||||
AssetTags: Scenes
|
|
||||||
ActiveRuleName: EnableGroup
|
|
||||||
Collectors:
|
|
||||||
- CollectPath: Assets/AssetRaw/Scenes
|
|
||||||
CollectorGUID: cace6ee6539f661419b5e5f8ae1c0146
|
|
||||||
CollectorType: 0
|
|
||||||
AddressRuleName: AddressByFileName
|
|
||||||
PackRuleName: PackSeparately
|
|
||||||
FilterRuleName: CollectAll
|
|
||||||
AssetTags:
|
|
||||||
UserData:
|
|
||||||
- GroupName: Shaders
|
|
||||||
GroupDesc: "\u7740\u8272\u5668"
|
|
||||||
AssetTags: Shaders
|
|
||||||
ActiveRuleName: EnableGroup
|
|
||||||
Collectors:
|
|
||||||
- CollectPath: Assets/AssetRaw/Shaders
|
|
||||||
CollectorGUID: 2a4bceb84ed685447ace957f497eb810
|
|
||||||
CollectorType: 0
|
|
||||||
AddressRuleName: AddressByFileName
|
|
||||||
PackRuleName: PackShaderVariants
|
|
||||||
FilterRuleName: CollectShaderVariants
|
|
||||||
AssetTags:
|
|
||||||
UserData:
|
|
||||||
- GroupName: UI
|
|
||||||
GroupDesc: "UI\u9762\u677F"
|
|
||||||
AssetTags: UI
|
|
||||||
ActiveRuleName: EnableGroup
|
|
||||||
Collectors:
|
|
||||||
- CollectPath: Assets/AssetRaw/UI
|
|
||||||
CollectorGUID: 27e87d83814156648b58f380b834e046
|
|
||||||
CollectorType: 0
|
|
||||||
AddressRuleName: AddressByFileName
|
|
||||||
PackRuleName: PackSeparately
|
|
||||||
FilterRuleName: CollectAll
|
|
||||||
AssetTags:
|
|
||||||
UserData:
|
|
||||||
- GroupName: Fonts
|
|
||||||
GroupDesc: "\u5B57\u4F53"
|
|
||||||
AssetTags: Fonts
|
|
||||||
ActiveRuleName: EnableGroup
|
|
||||||
Collectors:
|
|
||||||
- CollectPath: Assets/AssetRaw/Fonts
|
|
||||||
CollectorGUID: 2473375c9ee163a4b861278b38091455
|
|
||||||
CollectorType: 0
|
|
||||||
AddressRuleName: AddressByFileName
|
|
||||||
PackRuleName: PackDirectory
|
|
||||||
FilterRuleName: CollectAll
|
|
||||||
AssetTags:
|
|
||||||
UserData:
|
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 007a65bdc7416fd4a8823ff50f753d50
|
guid: c0d90477c8489f0438ae73994ff045b9
|
||||||
NativeFormatImporter:
|
NativeFormatImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
mainObjectFileID: 11400000
|
mainObjectFileID: 11400000
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 4c9eb26aee01e8643bd4e6dc965d3366
|
guid: f183cc1bcf4014f4c80a8580caabcd3f
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: f069f2f03dfa55843a74dedc551eefb2
|
guid: 50fd67a84c64e184c85bf3e1e343ba87
|
||||||
NativeFormatImporter:
|
NativeFormatImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
mainObjectFileID: 11400000
|
mainObjectFileID: 11400000
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 0fcee77031f85f84dbc6735c875d64b8
|
guid: cace8d5078f400048a8afde10e2bf41d
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
@@ -0,0 +1,36 @@
|
|||||||
|
using TEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
public static class TEngineSettingsProvider
|
||||||
|
{
|
||||||
|
[MenuItem("TEngine/Settings/TEngine UpdateSettings", priority = -1)]
|
||||||
|
public static void OpenSettings() => SettingsService.OpenProjectSettings("Project/TEngine/UpdateSettings");
|
||||||
|
|
||||||
|
private const string SettingsPath = "Project/TEngine/UpdateSettings";
|
||||||
|
|
||||||
|
[SettingsProvider]
|
||||||
|
public static SettingsProvider CreateMySettingsProvider()
|
||||||
|
{
|
||||||
|
return new SettingsProvider(SettingsPath, SettingsScope.Project)
|
||||||
|
{
|
||||||
|
label = "TEngine/UpdateSettings",
|
||||||
|
guiHandler = (searchContext) =>
|
||||||
|
{
|
||||||
|
var settings = Settings.UpdateSetting;
|
||||||
|
var serializedObject = new SerializedObject(settings);
|
||||||
|
|
||||||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("projectName"));
|
||||||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("HotUpdateAssemblies"));
|
||||||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("AOTMetaAssemblies"));
|
||||||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("LogicMainDllName"));
|
||||||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("AssemblyTextAssetExtension"));
|
||||||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("AssemblyTextAssetPath"));
|
||||||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("UpdateStyle"));
|
||||||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("ResDownLoadPath"));
|
||||||
|
EditorGUILayout.PropertyField(serializedObject.FindProperty("FallbackResDownLoadPath"));
|
||||||
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
},
|
||||||
|
keywords = new[] { "TEngine", "Settings", "Custom" }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: aa13a2165836fda459a6c28562ac101a
|
guid: f1c738d23f551c84e9e12af687389aeb
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
@@ -0,0 +1,32 @@
|
|||||||
|
using TEngine.Editor.UI;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
public static class TEngineUISettingsProvider
|
||||||
|
{
|
||||||
|
[MenuItem("TEngine/Settings/TEngineUISettings", priority = -1)]
|
||||||
|
public static void OpenSettings() => SettingsService.OpenProjectSettings("Project/TEngine/UISettings");
|
||||||
|
|
||||||
|
private const string SettingsPath = "Project/TEngine/UISettings";
|
||||||
|
|
||||||
|
[SettingsProvider]
|
||||||
|
public static SettingsProvider CreateMySettingsProvider()
|
||||||
|
{
|
||||||
|
return new SettingsProvider(SettingsPath, SettingsScope.Project)
|
||||||
|
{
|
||||||
|
label = "TEngine/UISettings",
|
||||||
|
guiHandler = (searchContext) =>
|
||||||
|
{
|
||||||
|
var scriptGeneratorSetting = ScriptGeneratorSetting.Instance;
|
||||||
|
var scriptGenerator = new SerializedObject(scriptGeneratorSetting);
|
||||||
|
|
||||||
|
EditorGUILayout.PropertyField(scriptGenerator.FindProperty("_codePath"));
|
||||||
|
EditorGUILayout.PropertyField(scriptGenerator.FindProperty("_namespace"));
|
||||||
|
EditorGUILayout.PropertyField(scriptGenerator.FindProperty("_widgetName"));
|
||||||
|
EditorGUILayout.PropertyField(scriptGenerator.FindProperty("CodeStyle"));
|
||||||
|
EditorGUILayout.PropertyField(scriptGenerator.FindProperty("scriptGenerateRule"));
|
||||||
|
scriptGenerator.ApplyModifiedProperties();
|
||||||
|
},
|
||||||
|
keywords = new[] { "TEngine", "Settings", "Custom" }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2672376ad13242bcb6869e90c4def052
|
||||||
|
timeCreated: 1742814408
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 81dccabae12b7f64086d54bc04a85de0
|
guid: 2982073ed28ef744e96be44c7f55f5f7
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
@@ -0,0 +1,88 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityToolbarExtender;
|
||||||
|
|
||||||
|
namespace TEngine
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class EditorPlayMode
|
||||||
|
{
|
||||||
|
static class ToolbarStyles
|
||||||
|
{
|
||||||
|
public static readonly GUIStyle ToolBarExtenderBtnStyle;
|
||||||
|
|
||||||
|
public static readonly GUIStyle ToolBarTextStyle;
|
||||||
|
|
||||||
|
public static readonly GUIStyle ToolBarButtonGuiStyle;
|
||||||
|
|
||||||
|
static ToolbarStyles()
|
||||||
|
{
|
||||||
|
ToolBarExtenderBtnStyle = new GUIStyle("Command")
|
||||||
|
{
|
||||||
|
fontSize = 12,
|
||||||
|
alignment = TextAnchor.MiddleCenter,
|
||||||
|
imagePosition = ImagePosition.ImageAbove,
|
||||||
|
fontStyle = FontStyle.Normal,
|
||||||
|
fixedWidth = 60
|
||||||
|
};
|
||||||
|
|
||||||
|
ToolBarTextStyle = new GUIStyle(BUTTON_STYLE_NAME)
|
||||||
|
{
|
||||||
|
padding = new RectOffset(2, 8, 2, 2),
|
||||||
|
alignment = TextAnchor.MiddleCenter,
|
||||||
|
fontStyle = FontStyle.Bold
|
||||||
|
};
|
||||||
|
|
||||||
|
ToolBarButtonGuiStyle = new GUIStyle(BUTTON_STYLE_NAME)
|
||||||
|
{
|
||||||
|
padding = new RectOffset(2, 8, 2, 2),
|
||||||
|
alignment = TextAnchor.MiddleCenter,
|
||||||
|
fontStyle = FontStyle.Bold
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static EditorPlayMode()
|
||||||
|
{
|
||||||
|
ToolbarExtender.RightToolbarGUI.Add(OnToolbarGUI);
|
||||||
|
_resourceModeIndex = EditorPrefs.GetInt("EditorPlayMode", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private const string BUTTON_STYLE_NAME = "Tab middle";
|
||||||
|
static GUIStyle _buttonGuiStyle;
|
||||||
|
|
||||||
|
private static readonly string[] _resourceModeNames =
|
||||||
|
{
|
||||||
|
"EditorMode (编辑器下的模拟模式)",
|
||||||
|
"OfflinePlayMode (单机模式)",
|
||||||
|
"HostPlayMode (联机运行模式)",
|
||||||
|
"WebPlayMode (WebGL运行模式)"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static int _resourceModeIndex = 0;
|
||||||
|
public static int ResourceModeIndex => _resourceModeIndex;
|
||||||
|
|
||||||
|
static void OnToolbarGUI()
|
||||||
|
{
|
||||||
|
EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
|
||||||
|
{
|
||||||
|
// GUILayout.Label("资源加载模式:",ToolbarStyles.ToolBarTextStyle);
|
||||||
|
//GUILayout.Space(10);
|
||||||
|
//GUILayout.FlexibleSpace();
|
||||||
|
|
||||||
|
// 资源模式
|
||||||
|
int selectedIndex = EditorGUILayout.Popup("", _resourceModeIndex, _resourceModeNames, ToolbarStyles.ToolBarButtonGuiStyle);
|
||||||
|
// ReSharper disable once RedundantCheckBeforeAssignment
|
||||||
|
if (selectedIndex != _resourceModeIndex)
|
||||||
|
{
|
||||||
|
Debug.Log($"更改编辑器资源运行模式 : {_resourceModeNames[selectedIndex]}");
|
||||||
|
_resourceModeIndex = selectedIndex;
|
||||||
|
EditorPrefs.SetInt("EditorPlayMode", selectedIndex);
|
||||||
|
}
|
||||||
|
//GUILayout.FlexibleSpace();
|
||||||
|
//GUILayout.Space(400);
|
||||||
|
}
|
||||||
|
EditorGUI.EndDisabledGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,126 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.SceneManagement;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityToolbarExtender;
|
||||||
|
|
||||||
|
namespace TEngine.SceneLauncher
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class SceneSwitchLeftButton
|
||||||
|
{
|
||||||
|
private const string PreviousSceneKey = "TEngine_PreviousScenePath"; // 用于存储之前场景路径的键
|
||||||
|
private const string IsLauncherBtn = "TEngine_IsLauncher"; // 用于存储之前是否按下launcher
|
||||||
|
|
||||||
|
private static readonly string SceneMain = "main";
|
||||||
|
|
||||||
|
private static readonly string ButtonStyleName = "Tab middle";
|
||||||
|
private static GUIStyle _buttonGuiStyle;
|
||||||
|
|
||||||
|
static SceneSwitchLeftButton()
|
||||||
|
{
|
||||||
|
ToolbarExtender.LeftToolbarGUI.Add(OnToolbarGUI);
|
||||||
|
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||||
|
EditorApplication.quitting += OnEditorQuit;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnToolbarGUI()
|
||||||
|
{
|
||||||
|
_buttonGuiStyle ??= new GUIStyle(ButtonStyleName)
|
||||||
|
{
|
||||||
|
padding = new RectOffset(2, 8, 2, 2),
|
||||||
|
alignment = TextAnchor.MiddleCenter,
|
||||||
|
fontStyle = FontStyle.Bold
|
||||||
|
};
|
||||||
|
|
||||||
|
GUILayout.FlexibleSpace();
|
||||||
|
if (GUILayout.Button(
|
||||||
|
new GUIContent("Launcher", EditorGUIUtility.FindTexture("PlayButton"), "Start Scene Launcher"),
|
||||||
|
_buttonGuiStyle))
|
||||||
|
SceneHelper.StartScene(SceneMain);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnPlayModeStateChanged(PlayModeStateChange state)
|
||||||
|
{
|
||||||
|
if (state == PlayModeStateChange.EnteredEditMode)
|
||||||
|
{
|
||||||
|
// 从 EditorPrefs 读取之前的场景路径
|
||||||
|
var previousScenePath = EditorPrefs.GetString(PreviousSceneKey, string.Empty);
|
||||||
|
if (!string.IsNullOrEmpty(previousScenePath) && EditorPrefs.GetBool(IsLauncherBtn))
|
||||||
|
{
|
||||||
|
EditorApplication.delayCall += () =>
|
||||||
|
{
|
||||||
|
if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
|
||||||
|
EditorSceneManager.OpenScene(previousScenePath);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorPrefs.SetBool(IsLauncherBtn, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnEditorQuit()
|
||||||
|
{
|
||||||
|
EditorPrefs.SetString(PreviousSceneKey, "");
|
||||||
|
EditorPrefs.SetBool(IsLauncherBtn, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SceneHelper
|
||||||
|
{
|
||||||
|
private static string _sceneToOpen;
|
||||||
|
|
||||||
|
public static void StartScene(string sceneName)
|
||||||
|
{
|
||||||
|
if (EditorApplication.isPlaying) EditorApplication.isPlaying = false;
|
||||||
|
|
||||||
|
// 记录当前场景路径到 EditorPrefs
|
||||||
|
var activeScene = SceneManager.GetActiveScene();
|
||||||
|
if (activeScene.isLoaded && activeScene.name != SceneMain)
|
||||||
|
{
|
||||||
|
EditorPrefs.SetString(PreviousSceneKey, activeScene.path);
|
||||||
|
EditorPrefs.SetBool(IsLauncherBtn, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
_sceneToOpen = sceneName;
|
||||||
|
EditorApplication.update += OnUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnUpdate()
|
||||||
|
{
|
||||||
|
if (_sceneToOpen == null ||
|
||||||
|
EditorApplication.isPlaying || EditorApplication.isPaused ||
|
||||||
|
EditorApplication.isCompiling || EditorApplication.isPlayingOrWillChangePlaymode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EditorApplication.update -= OnUpdate;
|
||||||
|
|
||||||
|
if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
|
||||||
|
{
|
||||||
|
string[] guids = AssetDatabase.FindAssets("t:scene " + _sceneToOpen, null);
|
||||||
|
if (guids.Length == 0)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("Couldn't find scene file");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string scenePath = null;
|
||||||
|
// 优先打开完全匹配_sceneToOpen的场景
|
||||||
|
for (var i = 0; i < guids.Length; i++)
|
||||||
|
{
|
||||||
|
scenePath = AssetDatabase.GUIDToAssetPath(guids[i]);
|
||||||
|
if (scenePath.EndsWith("/" + _sceneToOpen + ".unity")) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果没有完全匹配的场景,默认显示找到的第一个场景
|
||||||
|
if (string.IsNullOrEmpty(scenePath)) scenePath = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||||
|
|
||||||
|
EditorSceneManager.OpenScene(scenePath);
|
||||||
|
EditorApplication.isPlaying = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_sceneToOpen = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2f6d2ca3d3b34950a79294e49dd9d016
|
||||||
|
timeCreated: 1742389721
|
@@ -0,0 +1,115 @@
|
|||||||
|
#if UNITY_EDITOR
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEditor.SceneManagement;
|
||||||
|
|
||||||
|
namespace UnityToolbarExtender.Examples
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public sealed class SceneSwitchLeftButton
|
||||||
|
{
|
||||||
|
private static List<(string sceneName, string scenePath)> m_Scenes;
|
||||||
|
private static string[] m_SceneName;
|
||||||
|
private static string[] m_ScenePath;
|
||||||
|
private static int sceneSelected = 0;
|
||||||
|
|
||||||
|
static SceneSwitchLeftButton()
|
||||||
|
{
|
||||||
|
EditorApplication.projectChanged += UpdateCurrent;
|
||||||
|
UpdateCurrent();
|
||||||
|
ToolbarExtender.RightToolbarGUI.Add(OnToolbarGUI);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void UpdateCurrent()
|
||||||
|
{
|
||||||
|
m_Scenes = SceneSwitcher.GetAllScenesInProject();
|
||||||
|
m_SceneName = new string[m_Scenes.Count];
|
||||||
|
m_ScenePath = new string[m_Scenes.Count];
|
||||||
|
for (int i = 0; i < m_Scenes.Count; i++)
|
||||||
|
{
|
||||||
|
var (name, path) = m_Scenes[i];
|
||||||
|
m_SceneName[i] = name;
|
||||||
|
m_ScenePath[i] = path;
|
||||||
|
if (SceneManager.GetActiveScene().path == path)
|
||||||
|
sceneSelected = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OnToolbarGUI()
|
||||||
|
{
|
||||||
|
if (sceneSelected >= m_SceneName.Length) //空项目0场景判断
|
||||||
|
return;
|
||||||
|
var size = EditorStyles.popup.CalcSize(new GUIContent(m_SceneName[sceneSelected]));
|
||||||
|
// 创建水平布局
|
||||||
|
//EditorGUILayout.BeginHorizontal();
|
||||||
|
GUILayout.Space(20);
|
||||||
|
// 将控件推到左边和右边
|
||||||
|
//GUILayout.FlexibleSpace(); // 先占用左边的所有空间
|
||||||
|
EditorGUILayout.LabelField("当前场景:", GUILayout.Width(55));
|
||||||
|
int sceneSelectedNew = EditorGUILayout.Popup(sceneSelected, m_SceneName, GUILayout.Width(size.x + 5f),
|
||||||
|
GUILayout.MinWidth(55));
|
||||||
|
GUILayout.FlexibleSpace();
|
||||||
|
// 结束水平布局
|
||||||
|
//EditorGUILayout.EndHorizontal();
|
||||||
|
if (sceneSelectedNew != sceneSelected)
|
||||||
|
{
|
||||||
|
sceneSelected = sceneSelectedNew;
|
||||||
|
SceneSwitcher.PromptSaveCurrentScene();
|
||||||
|
EditorSceneManager.OpenScene(m_ScenePath[sceneSelectedNew]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class SceneSwitcher
|
||||||
|
{
|
||||||
|
public static bool PromptSaveCurrentScene()
|
||||||
|
{
|
||||||
|
// 检查当前场景是否已保存
|
||||||
|
if (SceneManager.GetActiveScene().isDirty)
|
||||||
|
{
|
||||||
|
// 提示用户是否要保存当前场景
|
||||||
|
bool saveScene = EditorUtility.DisplayDialog(
|
||||||
|
"Save Current Scene",
|
||||||
|
"The current scene has unsaved changes. Do you want to save it?",
|
||||||
|
"Save",
|
||||||
|
"Cancel"
|
||||||
|
);
|
||||||
|
|
||||||
|
// 如果用户选择“保存”,则保存当前场景
|
||||||
|
if (saveScene)
|
||||||
|
{
|
||||||
|
EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
|
||||||
|
}
|
||||||
|
|
||||||
|
return saveScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果场景已保存或者用户选择了“取消”,则返回 true,表示继续执行后续操作
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取项目中所有的场景文件,并以 (场景名, 场景路径) 的形式返回。
|
||||||
|
/// </summary>
|
||||||
|
public static List<(string sceneName, string scenePath)> GetAllScenesInProject()
|
||||||
|
{
|
||||||
|
List<(string sceneName, string scenePath)> scenes = new List<(string sceneName, string scenePath)>();
|
||||||
|
|
||||||
|
// 查找所有场景文件
|
||||||
|
string[] guids = AssetDatabase.FindAssets("t:Scene");
|
||||||
|
for (int i = 0; i < guids.Length; i++)
|
||||||
|
{
|
||||||
|
var guid = guids[i];
|
||||||
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||||
|
string sceneName = $"{i + 1}_{Path.GetFileNameWithoutExtension(path)}";
|
||||||
|
scenes.Add((sceneName, path));
|
||||||
|
}
|
||||||
|
|
||||||
|
return scenes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 45017e4df12424c4fb16db4708d239f0
|
guid: 1fb6885a187ff8449a9cc083b7fbee28
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
3
UnityProject/Assets/Editor/UIScriptGenerator.meta
Normal file
3
UnityProject/Assets/Editor/UIScriptGenerator.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 12cde5e16fa64eab883975bd63fc5077
|
||||||
|
timeCreated: 1741968067
|
@@ -58,10 +58,20 @@ namespace TEngine.Editor.UI
|
|||||||
strFile.Append("using UnityEngine;\n");
|
strFile.Append("using UnityEngine;\n");
|
||||||
strFile.Append("using UnityEngine.UI;\n");
|
strFile.Append("using UnityEngine.UI;\n");
|
||||||
strFile.Append("using TEngine;\n\n");
|
strFile.Append("using TEngine;\n\n");
|
||||||
strFile.Append($"namespace {SettingsUtils.GetUINameSpace()}\n");
|
strFile.Append($"namespace {ScriptGeneratorSetting.GetUINameSpace()}\n");
|
||||||
strFile.Append("{\n");
|
strFile.Append("{\n");
|
||||||
strFile.Append("\t[Window(UILayer.UI)]\n");
|
|
||||||
strFile.Append("\tclass " + root.name + " : UIWindow\n");
|
var widgetPrefix = $"{(ScriptGeneratorSetting.GetCodeStyle() == UIFieldCodeStyle.MPrefix ? "m_" : "_")}{ScriptGeneratorSetting.GetWidgetName()}";
|
||||||
|
if (root.name.StartsWith(widgetPrefix))
|
||||||
|
{
|
||||||
|
strFile.Append("\tclass " + root.name.Replace(widgetPrefix, "") + " : UIWidget\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strFile.Append("\t[Window(UILayer.UI)]\n");
|
||||||
|
strFile.Append("\tclass " + root.name + " : UIWindow\n");
|
||||||
|
}
|
||||||
|
|
||||||
strFile.Append("\t{\n");
|
strFile.Append("\t{\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,9 +102,11 @@ namespace TEngine.Editor.UI
|
|||||||
te.SelectAll();
|
te.SelectAll();
|
||||||
te.Copy();
|
te.Copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Log($"脚本已生成到剪贴板,请自行Ctl+V粘贴");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Ergodic(Transform root, Transform transform, ref StringBuilder strVar, ref StringBuilder strBind, ref StringBuilder strOnCreate,
|
public static void Ergodic(Transform root, Transform transform, ref StringBuilder strVar, ref StringBuilder strBind, ref StringBuilder strOnCreate,
|
||||||
ref StringBuilder strCallback, bool isUniTask)
|
ref StringBuilder strCallback, bool isUniTask)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < transform.childCount; ++i)
|
for (int i = 0; i < transform.childCount; ++i)
|
||||||
@@ -103,7 +115,6 @@ namespace TEngine.Editor.UI
|
|||||||
WriteScript(root, child, ref strVar, ref strBind, ref strOnCreate, ref strCallback, isUniTask);
|
WriteScript(root, child, ref strVar, ref strBind, ref strOnCreate, ref strCallback, isUniTask);
|
||||||
if (child.name.StartsWith("m_item"))
|
if (child.name.StartsWith("m_item"))
|
||||||
{
|
{
|
||||||
// 子 Item 不再往下遍历
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,37 +138,96 @@ namespace TEngine.Editor.UI
|
|||||||
|
|
||||||
public static string GetBtnFuncName(string varName)
|
public static string GetBtnFuncName(string varName)
|
||||||
{
|
{
|
||||||
return "OnClick" + varName.Replace("m_btn", string.Empty) + "Btn";
|
var codeStyle = ScriptGeneratorSetting.Instance.CodeStyle;
|
||||||
|
if (codeStyle == UIFieldCodeStyle.MPrefix)
|
||||||
|
{
|
||||||
|
return "OnClick" + varName.Replace("m_btn", string.Empty) + "Btn";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "OnClick" + varName.Replace("_btn", string.Empty) + "Btn";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetToggleFuncName(string varName)
|
public static string GetToggleFuncName(string varName)
|
||||||
{
|
{
|
||||||
return "OnToggle" + varName.Replace("m_toggle", string.Empty) + "Change";
|
var codeStyle = ScriptGeneratorSetting.Instance.CodeStyle;
|
||||||
|
if (codeStyle == UIFieldCodeStyle.MPrefix)
|
||||||
|
{
|
||||||
|
return "OnToggle" + varName.Replace("m_toggle", string.Empty) + "Change";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "OnToggle" + varName.Replace("_toggle", string.Empty) + "Change";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetSliderFuncName(string varName)
|
public static string GetSliderFuncName(string varName)
|
||||||
{
|
{
|
||||||
return "OnSlider" + varName.Replace("m_slider", string.Empty) + "Change";
|
var codeStyle = ScriptGeneratorSetting.Instance.CodeStyle;
|
||||||
|
if (codeStyle == UIFieldCodeStyle.MPrefix)
|
||||||
|
{
|
||||||
|
return "OnSlider" + varName.Replace("m_slider", string.Empty) + "Change";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "OnSlider" + varName.Replace("_slider", string.Empty) + "Change";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteScript(Transform root, Transform child, ref StringBuilder strVar, ref StringBuilder strBind, ref StringBuilder strOnCreate,
|
private static void WriteScript(Transform root, Transform child, ref StringBuilder strVar, ref StringBuilder strBind, ref StringBuilder strOnCreate,
|
||||||
ref StringBuilder strCallback, bool isUniTask)
|
ref StringBuilder strCallback, bool isUniTask)
|
||||||
{
|
{
|
||||||
string varName = child.name;
|
string varName = child.name;
|
||||||
|
|
||||||
string componentName = string.Empty;
|
string componentName = string.Empty;
|
||||||
|
|
||||||
var rule = SettingsUtils.GetScriptGenerateRule().Find(t => varName.StartsWith(t.uiElementRegex));
|
var rule = ScriptGeneratorSetting.GetScriptGenerateRule().Find(t => varName.StartsWith(t.uiElementRegex));
|
||||||
|
|
||||||
if (rule != null)
|
if (rule != null)
|
||||||
{
|
{
|
||||||
componentName = rule.componentName;
|
componentName = rule.componentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isUIWidget = rule is { isUIWidget: true };
|
||||||
|
|
||||||
if (componentName == string.Empty)
|
if (componentName == string.Empty)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var codeStyle = ScriptGeneratorSetting.Instance.CodeStyle;
|
||||||
|
if (codeStyle == UIFieldCodeStyle.UnderscorePrefix)
|
||||||
|
{
|
||||||
|
if (varName.StartsWith("_"))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(varName.StartsWith("m_"))
|
||||||
|
{
|
||||||
|
varName = varName.Substring(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
varName = $"_{varName}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (codeStyle == UIFieldCodeStyle.MPrefix)
|
||||||
|
{
|
||||||
|
if (varName.StartsWith("m_"))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (varName.StartsWith("_"))
|
||||||
|
{
|
||||||
|
varName = $"m{varName}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
varName = $"m_{varName}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string varPath = GetRelativePath(child, root);
|
string varPath = GetRelativePath(child, root);
|
||||||
if (!string.IsNullOrEmpty(varName))
|
if (!string.IsNullOrEmpty(varName))
|
||||||
{
|
{
|
||||||
@@ -173,26 +243,11 @@ namespace TEngine.Editor.UI
|
|||||||
case "AnimationCurve":
|
case "AnimationCurve":
|
||||||
strBind.Append($"\t\t\t{varName} = FindChildComponent<AnimCurveObject>(\"{varPath}\").m_animCurve;\n");
|
strBind.Append($"\t\t\t{varName} = FindChildComponent<AnimCurveObject>(\"{varPath}\").m_animCurve;\n");
|
||||||
break;
|
break;
|
||||||
case "RichItemIcon":
|
|
||||||
case "CommonFightWidget":
|
|
||||||
case "PlayerHeadWidget":
|
|
||||||
strBind.Append($"\t\t\t{varName} = CreateWidgetByType<{componentName}>(\"{varPath}\");\n");
|
|
||||||
break;
|
|
||||||
case "RedNoteBehaviour":
|
|
||||||
case "TextButtonItem":
|
|
||||||
case "SwitchTabItem":
|
|
||||||
case "UIActorWidget":
|
|
||||||
case "UIEffectWidget":
|
|
||||||
case "UISpineWidget":
|
|
||||||
strBind.Append($"\t\t\t{varName} = CreateWidget<{componentName}>(\"{varPath}\");\n");
|
|
||||||
break;
|
|
||||||
case "ActorNameBinderText":
|
|
||||||
strBind.Append($"\t\t\t{varName} = FindTextBinder(\"{varPath}\");\n");
|
|
||||||
break;
|
|
||||||
case "ActorNameBinderEffect":
|
|
||||||
strBind.Append($"\t\t\t{varName} = FindEffectBinder(\"{varPath}\");\n");
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
|
if (isUIWidget)
|
||||||
|
{
|
||||||
|
strBind.Append($"\t\t\t{varName} = CreateWidgetByType<{componentName}>(\"{varPath}\");\n");
|
||||||
|
}
|
||||||
strBind.Append($"\t\t\t{varName} = FindChildComponent<{componentName}>(\"{varPath}\");\n");
|
strBind.Append($"\t\t\t{varName} = FindChildComponent<{componentName}>(\"{varPath}\");\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -246,7 +301,7 @@ namespace TEngine.Editor.UI
|
|||||||
protected void OnGUI()
|
protected void OnGUI()
|
||||||
{
|
{
|
||||||
GUILayout.BeginVertical();
|
GUILayout.BeginVertical();
|
||||||
foreach (var item in SettingsUtils.GetScriptGenerateRule())
|
foreach (var item in ScriptGeneratorSetting.GetScriptGenerateRule())
|
||||||
{
|
{
|
||||||
GUILayout.Label(item.uiElementRegex + ":\t" + item.componentName);
|
GUILayout.Label(item.uiElementRegex + ":\t" + item.componentName);
|
||||||
}
|
}
|
||||||
@@ -254,82 +309,5 @@ namespace TEngine.Editor.UI
|
|||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SwitchGroupGenerator
|
|
||||||
{
|
|
||||||
private const string Condition = "m_switchGroup";
|
|
||||||
|
|
||||||
public static readonly SwitchGroupGenerator Instance = new SwitchGroupGenerator();
|
|
||||||
|
|
||||||
public string Process(Transform root)
|
|
||||||
{
|
|
||||||
var sbd = new StringBuilder();
|
|
||||||
var list = new List<Transform>();
|
|
||||||
Collect(root, list);
|
|
||||||
foreach (var node in list)
|
|
||||||
{
|
|
||||||
sbd.AppendLine(Process(root, node)).AppendLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
return sbd.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Collect(Transform node, List<Transform> nodeList)
|
|
||||||
{
|
|
||||||
if (node.name.StartsWith(Condition))
|
|
||||||
{
|
|
||||||
nodeList.Add(node);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var childCnt = node.childCount;
|
|
||||||
for (var i = 0; i < childCnt; i++)
|
|
||||||
{
|
|
||||||
var child = node.GetChild(i);
|
|
||||||
Collect(child, nodeList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string Process(Transform root, Transform groupTf)
|
|
||||||
{
|
|
||||||
var parentPath = GetPath(root, groupTf);
|
|
||||||
var name = groupTf.name;
|
|
||||||
var sbd = new StringBuilder(@"
|
|
||||||
var _namePath = ""#parentPath"";
|
|
||||||
var _nameTf = FindChild(_namePath);
|
|
||||||
var childCnt = _nameTf.childCount;
|
|
||||||
SwitchTabItem[] _name;
|
|
||||||
_name = new SwitchTabItem[childCnt];
|
|
||||||
for (var i = 0; i < childCnt; i++)
|
|
||||||
{
|
|
||||||
var child = _nameTf.GetChild(i);
|
|
||||||
_name[i] = CreateWidget<SwitchTabItem>(_namePath + ""/"" + child.name);
|
|
||||||
}");
|
|
||||||
sbd.Replace("_name", name);
|
|
||||||
sbd.Replace("#parentPath", parentPath);
|
|
||||||
return sbd.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetPath(Transform root, Transform childTf)
|
|
||||||
{
|
|
||||||
if (childTf == null)
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (childTf == root)
|
|
||||||
{
|
|
||||||
return childTf.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
var parentPath = GetPath(root, childTf.parent);
|
|
||||||
if (parentPath == string.Empty)
|
|
||||||
{
|
|
||||||
return childTf.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parentPath + "/" + childTf.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 5cde6b81462affb4bac5ca8cd0862f38
|
guid: 9e5b80682b2036f42b69fcb09c53863a
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
@@ -0,0 +1,82 @@
|
|||||||
|
%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: f8a0dfbcd6854965bb6ae78627009a53, type: 3}
|
||||||
|
m_Name: ScriptGeneratorSetting
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_codePath:
|
||||||
|
_namespace: GameLogic
|
||||||
|
_widgetName: item
|
||||||
|
CodeStyle: 0
|
||||||
|
scriptGenerateRule:
|
||||||
|
- uiElementRegex: m_go
|
||||||
|
componentName: GameObject
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_item
|
||||||
|
componentName: GameObject
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_tf
|
||||||
|
componentName: Transform
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_rect
|
||||||
|
componentName: RectTransform
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_text
|
||||||
|
componentName: Text
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_richText
|
||||||
|
componentName: RichTextItem
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_btn
|
||||||
|
componentName: Button
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_img
|
||||||
|
componentName: Image
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_rimg
|
||||||
|
componentName: RawImage
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_scrollBar
|
||||||
|
componentName: Scrollbar
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_scroll
|
||||||
|
componentName: ScrollRect
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_input
|
||||||
|
componentName: InputField
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_grid
|
||||||
|
componentName: GridLayoutGroup
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_hlay
|
||||||
|
componentName: HorizontalLayoutGroup
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_vlay
|
||||||
|
componentName: VerticalLayoutGroup
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_slider
|
||||||
|
componentName: Slider
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_toggle
|
||||||
|
componentName: Toggle
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_group
|
||||||
|
componentName: ToggleGroup
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_curve
|
||||||
|
componentName: AnimationCurve
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_canvasGroup
|
||||||
|
componentName: CanvasGroup
|
||||||
|
isUIWidget: 0
|
||||||
|
- uiElementRegex: m_tmp
|
||||||
|
componentName: TextMeshProUGUI
|
||||||
|
isUIWidget: 0
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: eb33bb9d9cdf9484997cc91b0517ba4d
|
guid: fe8fecac349dd7a4cafb77822cdba64a
|
||||||
NativeFormatImporter:
|
NativeFormatImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
mainObjectFileID: 11400000
|
mainObjectFileID: 11400000
|
@@ -0,0 +1,195 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace TEngine.Editor.UI
|
||||||
|
{
|
||||||
|
public enum UIFieldCodeStyle
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Field names start with underscore (e.g., _variable)
|
||||||
|
/// </summary>
|
||||||
|
[InspectorName("Field names start with underscore (e.g., _variable)")]
|
||||||
|
UnderscorePrefix,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Field names start with m_ prefix (e.g., m_variable)
|
||||||
|
/// </summary>
|
||||||
|
[InspectorName("Field names start with m_ prefix (e.g., m_variable)")]
|
||||||
|
MPrefix,
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class ScriptGenerateRuler
|
||||||
|
{
|
||||||
|
public string uiElementRegex;
|
||||||
|
public string componentName;
|
||||||
|
public bool isUIWidget = false;
|
||||||
|
|
||||||
|
public ScriptGenerateRuler(string uiElementRegex, string componentName, bool isUIWidget = false)
|
||||||
|
{
|
||||||
|
this.uiElementRegex = uiElementRegex;
|
||||||
|
this.componentName = componentName;
|
||||||
|
this.isUIWidget = isUIWidget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CustomPropertyDrawer(typeof(ScriptGenerateRuler))]
|
||||||
|
public class ScriptGenerateRulerDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||||
|
{
|
||||||
|
EditorGUI.BeginProperty(position, label, property);
|
||||||
|
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
|
||||||
|
var indent = EditorGUI.indentLevel;
|
||||||
|
EditorGUI.indentLevel = 0;
|
||||||
|
var uiElementRegexRect = new Rect(position.x, position.y, 120, position.height);
|
||||||
|
var componentNameRect = new Rect(position.x + 125, position.y, 150, position.height);
|
||||||
|
var isUIWidgetRect = new Rect(position.x + 325, position.y, 150, position.height);
|
||||||
|
EditorGUI.PropertyField(uiElementRegexRect, property.FindPropertyRelative("uiElementRegex"), GUIContent.none);
|
||||||
|
EditorGUI.PropertyField(componentNameRect, property.FindPropertyRelative("componentName"), GUIContent.none);
|
||||||
|
EditorGUI.PropertyField(isUIWidgetRect, property.FindPropertyRelative("isUIWidget"), GUIContent.none);
|
||||||
|
EditorGUI.indentLevel = indent;
|
||||||
|
EditorGUI.EndProperty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CreateAssetMenu(menuName = "TEngine/ScriptGeneratorSetting", fileName = "ScriptGeneratorSetting")]
|
||||||
|
public class ScriptGeneratorSetting : ScriptableObject
|
||||||
|
{
|
||||||
|
private static ScriptGeneratorSetting _instance;
|
||||||
|
|
||||||
|
public static ScriptGeneratorSetting Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_instance == null)
|
||||||
|
{
|
||||||
|
string[] guids = AssetDatabase.FindAssets("t:ScriptGeneratorSetting");
|
||||||
|
if (guids.Length >= 1)
|
||||||
|
{
|
||||||
|
string path = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||||
|
_instance = AssetDatabase.LoadAssetAtPath<ScriptGeneratorSetting>(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// [FolderPath]
|
||||||
|
// [LabelText("默认组件代码保存路径")]
|
||||||
|
[SerializeField]
|
||||||
|
private string _codePath;
|
||||||
|
|
||||||
|
// [LabelText("绑定代码命名空间")]
|
||||||
|
[SerializeField]
|
||||||
|
private string _namespace = "GameLogic";
|
||||||
|
|
||||||
|
// [LabelText("子组件名称(不会往下继续遍历)")]
|
||||||
|
[SerializeField]
|
||||||
|
private string _widgetName = "item";
|
||||||
|
|
||||||
|
public string CodePath => _codePath;
|
||||||
|
|
||||||
|
public string Namespace => _namespace;
|
||||||
|
|
||||||
|
public string WidgetName => _widgetName;
|
||||||
|
|
||||||
|
public UIFieldCodeStyle CodeStyle = UIFieldCodeStyle.UnderscorePrefix;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private List<ScriptGenerateRuler> scriptGenerateRule = new List<ScriptGenerateRuler>()
|
||||||
|
{
|
||||||
|
new ScriptGenerateRuler("m_go", "GameObject"),
|
||||||
|
new ScriptGenerateRuler("m_item", "GameObject"),
|
||||||
|
new ScriptGenerateRuler("m_tf", "Transform"),
|
||||||
|
new ScriptGenerateRuler("m_rect", "RectTransform"),
|
||||||
|
new ScriptGenerateRuler("m_text", "Text"),
|
||||||
|
new ScriptGenerateRuler("m_richText", "RichTextItem"),
|
||||||
|
new ScriptGenerateRuler("m_btn", "Button"),
|
||||||
|
new ScriptGenerateRuler("m_img", "Image"),
|
||||||
|
new ScriptGenerateRuler("m_rimg", "RawImage"),
|
||||||
|
new ScriptGenerateRuler("m_scrollBar", "Scrollbar"),
|
||||||
|
new ScriptGenerateRuler("m_scroll", "ScrollRect"),
|
||||||
|
new ScriptGenerateRuler("m_input", "InputField"),
|
||||||
|
new ScriptGenerateRuler("m_grid", "GridLayoutGroup"),
|
||||||
|
new ScriptGenerateRuler("m_hlay", "HorizontalLayoutGroup"),
|
||||||
|
new ScriptGenerateRuler("m_vlay", "VerticalLayoutGroup"),
|
||||||
|
new ScriptGenerateRuler("m_slider", "Slider"),
|
||||||
|
new ScriptGenerateRuler("m_group", "ToggleGroup"),
|
||||||
|
new ScriptGenerateRuler("m_curve", "AnimationCurve"),
|
||||||
|
new ScriptGenerateRuler("m_canvasGroup", "CanvasGroup"),
|
||||||
|
new ScriptGenerateRuler("m_tmp","TextMeshProUGUI"),
|
||||||
|
};
|
||||||
|
|
||||||
|
public List<ScriptGenerateRuler> ScriptGenerateRule => scriptGenerateRule;
|
||||||
|
|
||||||
|
|
||||||
|
[MenuItem("TEngine/Create ScriptGeneratorSetting")]
|
||||||
|
private static void CreateAutoBindGlobalSetting()
|
||||||
|
{
|
||||||
|
string[] paths = AssetDatabase.FindAssets("t:ScriptGeneratorSetting");
|
||||||
|
if (paths.Length >= 1)
|
||||||
|
{
|
||||||
|
string path = AssetDatabase.GUIDToAssetPath(paths[0]);
|
||||||
|
EditorUtility.DisplayDialog("警告", $"已存在ScriptGeneratorSetting,路径:{path}", "确认");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptGeneratorSetting setting = CreateInstance<ScriptGeneratorSetting>();
|
||||||
|
AssetDatabase.CreateAsset(setting, "Assets/Editor/ScriptGeneratorSetting.asset");
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ScriptGenerateRuler> GetScriptGenerateRule()
|
||||||
|
{
|
||||||
|
if (Instance == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Instance.ScriptGenerateRule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetUINameSpace()
|
||||||
|
{
|
||||||
|
if (Instance == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Instance.Namespace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UIFieldCodeStyle GetCodeStyle()
|
||||||
|
{
|
||||||
|
if (Instance == null)
|
||||||
|
{
|
||||||
|
return UIFieldCodeStyle.UnderscorePrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Instance.CodeStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetCodePath()
|
||||||
|
{
|
||||||
|
if (Instance == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Instance.CodePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetWidgetName()
|
||||||
|
{
|
||||||
|
if (Instance == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Instance.WidgetName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f8a0dfbcd6854965bb6ae78627009a53
|
||||||
|
timeCreated: 1741968155
|
15
UnityProject/Assets/GameScripts/GameEntry.cs
Normal file
15
UnityProject/Assets/GameScripts/GameEntry.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using TEngine;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class GameEntry : MonoBehaviour
|
||||||
|
{
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
ModuleSystem.GetModule<IUpdateDriver>();
|
||||||
|
ModuleSystem.GetModule<IResourceModule>();
|
||||||
|
ModuleSystem.GetModule<IDebuggerModule>();
|
||||||
|
ModuleSystem.GetModule<IFsmModule>();
|
||||||
|
Settings.ProcedureSetting.StartProcedure().Forget();
|
||||||
|
DontDestroyOnLoad(this);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: dd536d252034dd74b87b436507ec44f7
|
guid: 9cdc4a1084443e8408c7e46ec9e661c7
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
@@ -1,79 +0,0 @@
|
|||||||
namespace TEngine
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 基础LogicSys,生命周期由TEngine实现,推荐给系统实现,
|
|
||||||
/// 减少多余的Mono,保持系统层面只有一个Update。
|
|
||||||
/// 用主Mono来驱动LogicSys的生命周期。
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">逻辑系统类型。</typeparam>
|
|
||||||
public abstract class BaseLogicSys<T> : ILogicSys where T : new()
|
|
||||||
{
|
|
||||||
private static T _instance;
|
|
||||||
|
|
||||||
public static bool HasInstance => _instance != null;
|
|
||||||
|
|
||||||
public static T Instance
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (null == _instance)
|
|
||||||
{
|
|
||||||
_instance = new T();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region virtual function
|
|
||||||
public virtual bool OnInit()
|
|
||||||
{
|
|
||||||
if (null == _instance)
|
|
||||||
{
|
|
||||||
_instance = new T();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnStart()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnUpdate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnLateUpdate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnFixedUpdate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnRoleLogin()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnRoleLogout()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnDestroy()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnDrawGizmos()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnApplicationPause(bool pause)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnMapChanged()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: fc4ce19b17fd4277951d189b66f503e2
|
|
||||||
timeCreated: 1683120353
|
|
@@ -1,309 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace TEngine
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 通过LogicSys来驱动且具备Unity完整生命周期的单例(不继承MonoBehaviour)。
|
|
||||||
/// <remarks>Update、FixUpdate以及LateUpdate这些敏感帧更新需要加上对应的Attribute以最优化性能。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">完整生命周期的类型。</typeparam>
|
|
||||||
public abstract class BehaviourSingleton<T> : BaseBehaviourSingleton where T : BaseBehaviourSingleton, new()
|
|
||||||
{
|
|
||||||
private static T _instance;
|
|
||||||
|
|
||||||
public static T Instance
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (null == _instance)
|
|
||||||
{
|
|
||||||
_instance = new T();
|
|
||||||
Log.Assert(_instance != null);
|
|
||||||
_instance.Awake();
|
|
||||||
RegSingleton(_instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void RegSingleton(BaseBehaviourSingleton inst)
|
|
||||||
{
|
|
||||||
BehaviourSingleSystem.Instance.RegSingleton(inst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Attribute
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 帧更新属性。
|
|
||||||
/// <remarks>适用于BehaviourSingleton。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
|
||||||
public class UpdateAttribute : Attribute
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 物理帧更新属性。
|
|
||||||
/// <remarks>适用于BehaviourSingleton。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
|
||||||
public class FixedUpdateAttribute : Attribute
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 后帧更新属性。
|
|
||||||
/// <remarks>适用于BehaviourSingleton。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
|
||||||
public class LateUpdateAttribute : Attribute
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
|
||||||
public class RoleLoginAttribute : Attribute
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
|
||||||
public class RoleLogoutAttribute : Attribute
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 基础Behaviour单例。
|
|
||||||
/// <remarks>(抽象类)</remarks>
|
|
||||||
/// </summary>
|
|
||||||
public abstract class BaseBehaviourSingleton
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 是否已经Start。
|
|
||||||
/// </summary>
|
|
||||||
public bool IsStart = false;
|
|
||||||
|
|
||||||
public virtual void Awake()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Start()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 帧更新。
|
|
||||||
/// <remarks>需要UpdateAttribute。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
public virtual void Update()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 后帧更新。
|
|
||||||
/// <remarks>需要LateUpdateAttribute。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
public virtual void LateUpdate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 物理帧更新。
|
|
||||||
/// <remarks>需要FixedUpdateAttribute。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
public virtual void FixedUpdate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Destroy()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnPause()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnResume()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnDrawGizmos()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 通过LogicSys来驱动且具备Unity完整生命周期的驱动系统(不继承MonoBehaviour)。
|
|
||||||
/// </summary>
|
|
||||||
public sealed class BehaviourSingleSystem : BaseLogicSys<BehaviourSingleSystem>
|
|
||||||
{
|
|
||||||
private readonly List<BaseBehaviourSingleton> _listInst = new List<BaseBehaviourSingleton>();
|
|
||||||
private readonly List<BaseBehaviourSingleton> _listStart = new List<BaseBehaviourSingleton>();
|
|
||||||
private readonly List<BaseBehaviourSingleton> _listUpdate = new List<BaseBehaviourSingleton>();
|
|
||||||
private readonly List<BaseBehaviourSingleton> _listLateUpdate = new List<BaseBehaviourSingleton>();
|
|
||||||
private readonly List<BaseBehaviourSingleton> _listFixedUpdate = new List<BaseBehaviourSingleton>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 注册单例。
|
|
||||||
/// <remarks>调用Instance时自动调用。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="inst">单例实例。</param>
|
|
||||||
internal void RegSingleton(BaseBehaviourSingleton inst)
|
|
||||||
{
|
|
||||||
Log.Assert(!_listInst.Contains(inst));
|
|
||||||
_listInst.Add(inst);
|
|
||||||
_listStart.Add(inst);
|
|
||||||
if (HadAttribute<UpdateAttribute>(inst.GetType()))
|
|
||||||
{
|
|
||||||
_listUpdate.Add(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HadAttribute<LateUpdateAttribute>(inst.GetType()))
|
|
||||||
{
|
|
||||||
_listLateUpdate.Add(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HadAttribute<FixedUpdateAttribute>(inst.GetType()))
|
|
||||||
{
|
|
||||||
_listFixedUpdate.Add(inst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UnRegSingleton(BaseBehaviourSingleton inst)
|
|
||||||
{
|
|
||||||
if (inst == null)
|
|
||||||
{
|
|
||||||
Log.Error($"BaseBehaviourSingleton Is Null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.Assert(_listInst.Contains(inst));
|
|
||||||
if (_listInst.Contains(inst))
|
|
||||||
{
|
|
||||||
_listInst.Remove(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_listStart.Contains(inst))
|
|
||||||
{
|
|
||||||
_listStart.Remove(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_listUpdate.Contains(inst))
|
|
||||||
{
|
|
||||||
_listUpdate.Remove(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_listLateUpdate.Contains(inst))
|
|
||||||
{
|
|
||||||
_listLateUpdate.Remove(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
inst.Destroy();
|
|
||||||
inst = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnUpdate()
|
|
||||||
{
|
|
||||||
var listStart = _listStart;
|
|
||||||
var listToUpdate = _listUpdate;
|
|
||||||
int count = listStart.Count;
|
|
||||||
if (count > 0)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var inst = listStart[i];
|
|
||||||
Log.Assert(!inst.IsStart);
|
|
||||||
|
|
||||||
inst.IsStart = true;
|
|
||||||
inst.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
listStart.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
var listUpdateCnt = listToUpdate.Count;
|
|
||||||
for (int i = 0; i < listUpdateCnt; i++)
|
|
||||||
{
|
|
||||||
var inst = listToUpdate[i];
|
|
||||||
|
|
||||||
TProfiler.BeginFirstSample(inst.GetType().FullName);
|
|
||||||
inst.Update();
|
|
||||||
TProfiler.EndFirstSample();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnLateUpdate()
|
|
||||||
{
|
|
||||||
var listLateUpdate = _listLateUpdate;
|
|
||||||
var listLateUpdateCnt = listLateUpdate.Count;
|
|
||||||
for (int i = 0; i < listLateUpdateCnt; i++)
|
|
||||||
{
|
|
||||||
var inst = listLateUpdate[i];
|
|
||||||
|
|
||||||
TProfiler.BeginFirstSample(inst.GetType().FullName);
|
|
||||||
inst.LateUpdate();
|
|
||||||
TProfiler.EndFirstSample();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnFixedUpdate()
|
|
||||||
{
|
|
||||||
var listFixedUpdate = _listFixedUpdate;
|
|
||||||
var listFixedUpdateCnt = listFixedUpdate.Count;
|
|
||||||
for (int i = 0; i < listFixedUpdateCnt; i++)
|
|
||||||
{
|
|
||||||
var inst = listFixedUpdate[i];
|
|
||||||
|
|
||||||
TProfiler.BeginFirstSample(inst.GetType().FullName);
|
|
||||||
inst.FixedUpdate();
|
|
||||||
TProfiler.EndFirstSample();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnDestroy()
|
|
||||||
{
|
|
||||||
int count = _listInst.Count;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var inst = _listInst[i];
|
|
||||||
inst.Destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnApplicationPause(bool pause)
|
|
||||||
{
|
|
||||||
int count = _listInst.Count;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var inst = _listInst[i];
|
|
||||||
if (pause)
|
|
||||||
{
|
|
||||||
inst.OnPause();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
inst.OnResume();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnDrawGizmos()
|
|
||||||
{
|
|
||||||
int count = _listInst.Count;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var inst = _listInst[i];
|
|
||||||
inst.OnDrawGizmos();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool HadAttribute<T>(Type type) where T : Attribute
|
|
||||||
{
|
|
||||||
T attribute = Attribute.GetCustomAttribute(type, typeof(T)) as T;
|
|
||||||
return attribute != null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 5c0e9c1c8c9d4ce99a1c991fb62a0256
|
|
||||||
timeCreated: 1683120460
|
|
@@ -1,40 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameBase
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 用于检测耗时。
|
|
||||||
/// </summary>
|
|
||||||
public class GameTickWatcher
|
|
||||||
{
|
|
||||||
private long _startTick;
|
|
||||||
|
|
||||||
public GameTickWatcher()
|
|
||||||
{
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Refresh()
|
|
||||||
{
|
|
||||||
_startTick = System.DateTime.Now.Ticks;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取用时。
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public float ElapseTime()
|
|
||||||
{
|
|
||||||
long endTick = System.DateTime.Now.Ticks;
|
|
||||||
return (float)((endTick - _startTick) / 10000) / 1000.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 输出用时。
|
|
||||||
/// </summary>
|
|
||||||
public void LogUsedTime()
|
|
||||||
{
|
|
||||||
Log.Info($"Used Time: {this.ElapseTime()}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7320165f7aa147a998a30fe2f7a5a5c2
|
|
||||||
timeCreated: 1681989139
|
|
@@ -1,58 +0,0 @@
|
|||||||
/// <summary>
|
|
||||||
/// 定义通用的逻辑接口,统一生命期调用
|
|
||||||
/// </summary>
|
|
||||||
public interface ILogicSys
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化接口
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
bool OnInit();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 销毁系统
|
|
||||||
/// </summary>
|
|
||||||
void OnDestroy();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化后,第一帧统一调用
|
|
||||||
/// </summary>
|
|
||||||
void OnStart();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新接口
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
void OnUpdate();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 渲染后调用
|
|
||||||
/// </summary>
|
|
||||||
void OnLateUpdate();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 物理帧更新
|
|
||||||
/// </summary>
|
|
||||||
void OnFixedUpdate();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 登录账号/角色时调用
|
|
||||||
/// </summary>
|
|
||||||
void OnRoleLogin();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清理数据接口,切换账号/角色时调用
|
|
||||||
/// </summary>
|
|
||||||
void OnRoleLogout();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 绘制调试接口
|
|
||||||
/// </summary>
|
|
||||||
void OnDrawGizmos();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 暂停游戏
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pause"></param>
|
|
||||||
void OnApplicationPause(bool pause);
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 63ff6535a43f41d7ac793b8a153a37b6
|
|
||||||
timeCreated: 1681213932
|
|
@@ -1,27 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameBase
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 通用单例。
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">泛型T。</typeparam>
|
|
||||||
public class Singleton<T> where T : new()
|
|
||||||
{
|
|
||||||
private static T _instance;
|
|
||||||
|
|
||||||
public static T Instance
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (null == _instance)
|
|
||||||
{
|
|
||||||
_instance = new T();
|
|
||||||
Log.Assert(_instance != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b68a449df312429cbb27873984ec238e
|
|
||||||
timeCreated: 1681214042
|
|
@@ -1,3 +1,8 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 3026f5e2510440618f6d4f28b37c5244
|
guid: 3026f5e2510440618f6d4f28b37c5244
|
||||||
timeCreated: 1695289286
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 40a878a415f34e7a855fc4916bbb8e6b
|
|
||||||
timeCreated: 1702479104
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 1dcaa491f139438dbd963d8bbf0dba85
|
|
||||||
timeCreated: 1702385397
|
|
@@ -1,9 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
|
||||||
public class BaseAttribute: Attribute
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 819c4eaddddd4646a100da2e3f19c3c7
|
|
||||||
timeCreated: 1702385397
|
|
@@ -1,75 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
public class CodeTypes
|
|
||||||
{
|
|
||||||
private static CodeTypes _instance;
|
|
||||||
public static CodeTypes Instance => _instance ??= new CodeTypes();
|
|
||||||
|
|
||||||
private readonly Dictionary<string, Type> _allTypes = new();
|
|
||||||
private readonly UnOrderMultiMapSet<Type, Type> _types = new();
|
|
||||||
|
|
||||||
public void Init(Assembly[] assemblies)
|
|
||||||
{
|
|
||||||
Dictionary<string, Type> addTypes = GetAssemblyTypes(assemblies);
|
|
||||||
foreach ((string fullName, Type type) in addTypes)
|
|
||||||
{
|
|
||||||
_allTypes[fullName] = type;
|
|
||||||
|
|
||||||
if (type.IsAbstract)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 记录所有的有BaseAttribute标记的的类型
|
|
||||||
object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), true);
|
|
||||||
|
|
||||||
foreach (object o in objects)
|
|
||||||
{
|
|
||||||
_types.Add(o.GetType(), type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashSet<Type> GetTypes(Type systemAttributeType)
|
|
||||||
{
|
|
||||||
if (!_types.ContainsKey(systemAttributeType))
|
|
||||||
{
|
|
||||||
return new HashSet<Type>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _types[systemAttributeType];
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, Type> GetTypes()
|
|
||||||
{
|
|
||||||
return _allTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type GetType(string typeName)
|
|
||||||
{
|
|
||||||
return _allTypes[typeName];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Dictionary<string, Type> GetAssemblyTypes(params Assembly[] args)
|
|
||||||
{
|
|
||||||
Dictionary<string, Type> types = new Dictionary<string, Type>();
|
|
||||||
|
|
||||||
foreach (Assembly ass in args)
|
|
||||||
{
|
|
||||||
foreach (Type type in ass.GetTypes())
|
|
||||||
{
|
|
||||||
if (type.FullName != null)
|
|
||||||
{
|
|
||||||
types[type.FullName] = type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 01fdfc4515314c579523ac3716005210
|
|
||||||
timeCreated: 1702385429
|
|
@@ -1,80 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
public class UnOrderMultiMapSet<TKey, TValue>: Dictionary<TKey, HashSet<TValue>>
|
|
||||||
{
|
|
||||||
public new HashSet<TValue> this[TKey t]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
HashSet<TValue> set;
|
|
||||||
if (!TryGetValue(t, out set))
|
|
||||||
{
|
|
||||||
set = new HashSet<TValue>();
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<TKey, HashSet<TValue>> GetDictionary()
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Add(TKey t, TValue k)
|
|
||||||
{
|
|
||||||
HashSet<TValue> set;
|
|
||||||
TryGetValue(t, out set);
|
|
||||||
if (set == null)
|
|
||||||
{
|
|
||||||
set = new HashSet<TValue>();
|
|
||||||
base[t] = set;
|
|
||||||
}
|
|
||||||
set.Add(k);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Remove(TKey t, TValue k)
|
|
||||||
{
|
|
||||||
HashSet<TValue> set;
|
|
||||||
TryGetValue(t, out set);
|
|
||||||
if (set == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!set.Remove(k))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (set.Count == 0)
|
|
||||||
{
|
|
||||||
Remove(t);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Contains(TKey t, TValue k)
|
|
||||||
{
|
|
||||||
HashSet<TValue> set;
|
|
||||||
TryGetValue(t, out set);
|
|
||||||
if (set == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return set.Contains(k);
|
|
||||||
}
|
|
||||||
|
|
||||||
public new int Count
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
foreach (KeyValuePair<TKey,HashSet<TValue>> kv in this)
|
|
||||||
{
|
|
||||||
count += kv.Value.Count;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b798f0c1317c4caf9ace168f07b51d4f
|
|
||||||
timeCreated: 1702385485
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6dd993a020654e8bbcc4e70ea0029447
|
|
||||||
timeCreated: 1695289810
|
|
@@ -1,189 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using TEngine;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 红点个体行为。
|
|
||||||
/// </summary>
|
|
||||||
public class RedNoteBehaviour : UIWidget
|
|
||||||
{
|
|
||||||
public Action<bool> HaveRedNoteAction;
|
|
||||||
|
|
||||||
//当前红点类型
|
|
||||||
public RedNoteNotify RedNoteNotifyType { get; private set; }
|
|
||||||
|
|
||||||
//启用时当作标记,解决带有ID,创建多个类似条目的情况
|
|
||||||
public readonly List<ulong> IdParamList = new List<ulong>();
|
|
||||||
private readonly List<ulong> _tmpIdParam = new List<ulong>();
|
|
||||||
|
|
||||||
private Image _image;
|
|
||||||
|
|
||||||
private Image Image
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_image == null && gameObject != null)
|
|
||||||
{
|
|
||||||
_image = gameObject.GetComponent<Image>();
|
|
||||||
}
|
|
||||||
return _image;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Text _text;
|
|
||||||
private Text Text
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_text == null && gameObject != null)
|
|
||||||
{
|
|
||||||
_text = FindChildComponent<Text>(rectTransform, "Text");
|
|
||||||
}
|
|
||||||
return _text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool _state = false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 当前红点状态。
|
|
||||||
/// </summary>
|
|
||||||
public bool CurState
|
|
||||||
{
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
_state = value;
|
|
||||||
|
|
||||||
if (Image == null)
|
|
||||||
{
|
|
||||||
gameObject.SetActive(_state);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color c = Image.color;
|
|
||||||
c.a = _state ? 1f : 0.01f;
|
|
||||||
Image.color = c;
|
|
||||||
|
|
||||||
if (HaveRedNoteAction != null)
|
|
||||||
{
|
|
||||||
HaveRedNoteAction(_state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
get => _state;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//设置显示状态
|
|
||||||
public void SetRedNoteState(bool state)
|
|
||||||
{
|
|
||||||
CurState = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置红点类型
|
|
||||||
public void SetNotifyType(RedNoteNotify notifyType)
|
|
||||||
{
|
|
||||||
_tmpIdParam.Clear();
|
|
||||||
SetNotifyType(notifyType, _tmpIdParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 参数重载
|
|
||||||
public void SetNotifyType(RedNoteNotify notifyType, ulong param1)
|
|
||||||
{
|
|
||||||
_tmpIdParam.Clear();
|
|
||||||
_tmpIdParam.Add(param1);
|
|
||||||
SetNotifyType(notifyType, _tmpIdParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetNotifyType(RedNoteNotify notifyType, ulong param1, ulong param2)
|
|
||||||
{
|
|
||||||
_tmpIdParam.Clear();
|
|
||||||
_tmpIdParam.Add(param1);
|
|
||||||
_tmpIdParam.Add(param2);
|
|
||||||
SetNotifyType(notifyType, _tmpIdParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetNotifyType(RedNoteNotify notifyType, ulong param1, ulong param2, ulong param3)
|
|
||||||
{
|
|
||||||
_tmpIdParam.Clear();
|
|
||||||
_tmpIdParam.Add(param1);
|
|
||||||
_tmpIdParam.Add(param2);
|
|
||||||
_tmpIdParam.Add(param3);
|
|
||||||
SetNotifyType(notifyType, _tmpIdParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetNotifyType(RedNoteNotify notifyType, params ulong[] param)
|
|
||||||
{
|
|
||||||
_tmpIdParam.Clear();
|
|
||||||
for (int i = 0; i < param.Length; i++)
|
|
||||||
{
|
|
||||||
_tmpIdParam.Add(param[i]);
|
|
||||||
}
|
|
||||||
SetNotifyType(notifyType, _tmpIdParam);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void SetNotifyType(RedNoteNotify notifyType, List<ulong> paramList)
|
|
||||||
{
|
|
||||||
RemoveNotifyBind();
|
|
||||||
if (notifyType == RedNoteNotify.None) return;
|
|
||||||
|
|
||||||
IdParamList.Clear();
|
|
||||||
IdParamList.AddRange(paramList);
|
|
||||||
SetRedNoteNotifyProcess(notifyType);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetRedNoteNotifyProcess(RedNoteNotify notifyType)
|
|
||||||
{
|
|
||||||
// 移除红点通知的绑定
|
|
||||||
if (Image != null)
|
|
||||||
{
|
|
||||||
Image.rectTransform.SetAsLastSibling();
|
|
||||||
}
|
|
||||||
|
|
||||||
RedNoteNotifyType = notifyType;
|
|
||||||
|
|
||||||
RedNoteMgr.Instance.RegisterNotify(RedNoteNotifyType, this);
|
|
||||||
|
|
||||||
if (!RedNoteMgr.Instance.IsNumType(notifyType, IdParamList))
|
|
||||||
{
|
|
||||||
CurState = RedNoteMgr.Instance.GetNotifyValue(RedNoteNotifyType, IdParamList);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetRedNotePointNum(RedNoteMgr.Instance.GetNotifyPointNum(RedNoteNotifyType, IdParamList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 移除红点通知的绑定。
|
|
||||||
/// </summary>
|
|
||||||
public void RemoveNotifyBind()
|
|
||||||
{
|
|
||||||
if (RedNoteNotifyType != RedNoteNotify.None)
|
|
||||||
{
|
|
||||||
RedNoteMgr.Instance.UnRegisterNotify(RedNoteNotifyType, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
CurState = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnDestroy()
|
|
||||||
{
|
|
||||||
RemoveNotifyBind();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRedNotePointNum(int pointNum)
|
|
||||||
{
|
|
||||||
if (Text != null)
|
|
||||||
{
|
|
||||||
Text.text = pointNum > 0 ? pointNum.ToString() : string.Empty;
|
|
||||||
|
|
||||||
CurState = pointNum > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: dba30ea267ff4b988310dec14c0df1c3
|
|
||||||
timeCreated: 1687263893
|
|
@@ -1,85 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
/// <summary> 红点关联 </summary>
|
|
||||||
public class RedNoteCheckMgr
|
|
||||||
{
|
|
||||||
public string m_ownerStr;
|
|
||||||
public List<string> m_childList { get; private set; }
|
|
||||||
|
|
||||||
public RedNoteCheckMgr(RedNoteNotify ower, List<RedNoteNotify> childList)
|
|
||||||
{
|
|
||||||
m_ownerStr = ower.ToString();
|
|
||||||
m_childList = new List<string>();
|
|
||||||
for (int i = 0; i < childList.Count; i++)
|
|
||||||
{
|
|
||||||
var value = childList[i];
|
|
||||||
m_childList.Add(value.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public RedNoteCheckMgr(string paramKey)
|
|
||||||
{
|
|
||||||
m_ownerStr = paramKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AddChild(string childKey)
|
|
||||||
{
|
|
||||||
if (m_childList == null)
|
|
||||||
{
|
|
||||||
m_childList = new List<string>();
|
|
||||||
}
|
|
||||||
if (!m_childList.Contains(childKey))
|
|
||||||
{
|
|
||||||
m_childList.Add(childKey);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CheckChildRedNote()
|
|
||||||
{
|
|
||||||
var valueItem = RedNoteMgr.Instance.GetNotifyValueItem(m_ownerStr);
|
|
||||||
|
|
||||||
bool childHaveRed = false;
|
|
||||||
int childNotePointNum = 0;
|
|
||||||
|
|
||||||
int count = m_childList.Count;
|
|
||||||
for (var index = 0; index < count; index++)
|
|
||||||
{
|
|
||||||
var child = m_childList[index];
|
|
||||||
var childItem = RedNoteMgr.Instance.GetNotifyValueItem(child);
|
|
||||||
if (childItem.GetRedNoteType() == RedNoteType.Simple)
|
|
||||||
{
|
|
||||||
if (RedNoteMgr.Instance.GetNotifyValue(child))
|
|
||||||
{
|
|
||||||
childHaveRed = true;
|
|
||||||
childNotePointNum++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
childNotePointNum += childItem.GetRedNotePointNum();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valueItem.GetRedNoteType() == RedNoteType.Simple)
|
|
||||||
{
|
|
||||||
RedNoteMgr.Instance.SetNotifyKeyValue(m_ownerStr, childHaveRed);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RedNoteMgr.Instance.SetNotifyKeyPointNum(m_ownerStr, childNotePointNum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public bool CheckChild(string childKey)
|
|
||||||
{
|
|
||||||
bool red = RedNoteMgr.Instance.GetNotifyValue(childKey);
|
|
||||||
return red;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 3dd181174bbf408e9932a6f9484e41a5
|
|
||||||
timeCreated: 1687263893
|
|
@@ -1,669 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using GameBase;
|
|
||||||
using GameLogic;
|
|
||||||
using TEngine;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
#region 红点添加步骤
|
|
||||||
|
|
||||||
/// 1,增加RedNoteNotify定义,加入新的红点枚举。
|
|
||||||
/// 2,添加红点关联,关联定义在InitRelation,查看当前有的关联关系,确定是增加还是重新创建
|
|
||||||
/// 3,把RedNoteBehaviour挂在红点图片上,红点图片一般放置在需要显示红点的按钮/页签上,设置脚本上的枚举类型
|
|
||||||
/// 4,如果是带参数的红点类型,在红点所在的UI声明红点对象,对参数进行设置,参数统一为uint,一般用一个可以唯一区分的ID。
|
|
||||||
/// 有多个参数时,每后一个参数节点都是前一个参数的子节点。 无参数为该层级的根节点。
|
|
||||||
/// 5,红点激活/隐藏
|
|
||||||
/// 在对应模块数据管理类中,检测达到红点激活条件,或红点消失条件,调用SetNotifyValue激活/隐藏红点
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public enum RedNoteNotify
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
CharacterMain,
|
|
||||||
ShopMain,
|
|
||||||
BagMain,
|
|
||||||
BagUseType,
|
|
||||||
ExploreMain,
|
|
||||||
HomeUI,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 红点指引
|
|
||||||
/// </summary>
|
|
||||||
public class RedNoteMgr : Singleton<RedNoteMgr>
|
|
||||||
{
|
|
||||||
//红点状态记录
|
|
||||||
private Dictionary<string, RedNoteValueItem> _notifyMap;
|
|
||||||
|
|
||||||
//红点关联
|
|
||||||
private readonly Dictionary<string, RedNoteCheckMgr> _checkDic = new Dictionary<string, RedNoteCheckMgr>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// child to parent list
|
|
||||||
/// </summary>
|
|
||||||
private readonly Dictionary<string, List<string>> _checkOwnDic = new Dictionary<string, List<string>>();
|
|
||||||
|
|
||||||
private readonly Dictionary<string, RedNoteKeyStruct> _keyConvertDic = new Dictionary<string, RedNoteKeyStruct>();
|
|
||||||
private readonly Dictionary<string, RedNoteStructDic> _keyDic = new Dictionary<string, RedNoteStructDic>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 红点映射
|
|
||||||
/// key => 红点名称
|
|
||||||
/// val => 对应的红点类型
|
|
||||||
/// </summary>
|
|
||||||
private Dictionary<string, RedNoteNotify> _dicRedNoteMap;
|
|
||||||
|
|
||||||
private Dictionary<int, string> _notifyStringMap;
|
|
||||||
|
|
||||||
public void Init()
|
|
||||||
{
|
|
||||||
InitState();
|
|
||||||
InitRedNoteConfig();
|
|
||||||
InitRelation();
|
|
||||||
InitRedNoteTween();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 全局缓动缩放
|
|
||||||
/// </summary>
|
|
||||||
public Vector3 GlobalTwScale { get; protected set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化红点缓动
|
|
||||||
/// </summary>
|
|
||||||
private void InitRedNoteTween()
|
|
||||||
{
|
|
||||||
// LeanTween.value(LeanTween.tweenEmpty, OnRedNoteTween, 1f, 0.75f, 0.5f).setLoopPingPong();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 缓动
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
private void OnRedNoteTween(float value)
|
|
||||||
{
|
|
||||||
GlobalTwScale = value * Vector3.one;
|
|
||||||
}
|
|
||||||
|
|
||||||
//注册红点通知
|
|
||||||
public void RegisterNotify(RedNoteNotify notify, RedNoteBehaviour redNote)
|
|
||||||
{
|
|
||||||
RedNoteValueItem redNoteValueItem = GetOrNewNotifyValueItem(notify, redNote.IdParamList);
|
|
||||||
redNoteValueItem.AddRedNote(redNote);
|
|
||||||
}
|
|
||||||
|
|
||||||
//销毁红点通知
|
|
||||||
public void UnRegisterNotify(RedNoteNotify notify, RedNoteBehaviour redNote)
|
|
||||||
{
|
|
||||||
RedNoteValueItem redNoteValueItem = GetOrNewNotifyValueItem(notify, redNote.IdParamList);
|
|
||||||
if (redNoteValueItem == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
redNoteValueItem.RemoveRedNote(redNote);
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly List<ulong> _tmpRedNoteParams = new List<ulong>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置红点状态。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="notify"></param>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
public void SetNotifyValue(RedNoteNotify notify, bool value)
|
|
||||||
{
|
|
||||||
_tmpRedNoteParams.Clear();
|
|
||||||
SetNotifyValue(notify, value, _tmpRedNoteParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 参数重载 bool
|
|
||||||
|
|
||||||
public void SetNotifyValue(RedNoteNotify notify, bool value, ulong param1)
|
|
||||||
{
|
|
||||||
_tmpRedNoteParams.Clear();
|
|
||||||
_tmpRedNoteParams.Add(param1);
|
|
||||||
SetNotifyValue(notify, value, _tmpRedNoteParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetNotifyValue(RedNoteNotify notify, bool value, ulong param1, ulong param2)
|
|
||||||
{
|
|
||||||
_tmpRedNoteParams.Clear();
|
|
||||||
_tmpRedNoteParams.Add(param1);
|
|
||||||
_tmpRedNoteParams.Add(param2);
|
|
||||||
SetNotifyValue(notify, value, _tmpRedNoteParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetNotifyValue(RedNoteNotify notify, bool value, params ulong[] param)
|
|
||||||
{
|
|
||||||
_tmpRedNoteParams.Clear();
|
|
||||||
for (var i = 0; i < param.Length; i++)
|
|
||||||
{
|
|
||||||
_tmpRedNoteParams.Add(param[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetNotifyValue(notify, value, _tmpRedNoteParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void SetNotifyValue(RedNoteNotify notify, bool value, List<ulong> redNoteParamList)
|
|
||||||
{
|
|
||||||
var key = BuildKey(notify, redNoteParamList);
|
|
||||||
if (!value && !_notifyMap.TryGetValue(key, out var redNoteValueItem))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GetOrNewNotifyValueItem(notify, redNoteParamList);
|
|
||||||
MarkNotifyKeyValueDirty(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MarkNotifyKeyValueDirty(string key, bool value)
|
|
||||||
{
|
|
||||||
if (!_notifyMap.TryGetValue(key, out var redNoteValueItem))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
redNoteValueItem.SetStateDirty(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置红点状态。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
public void SetNotifyKeyValue(string key, bool value)
|
|
||||||
{
|
|
||||||
if (!_notifyMap.TryGetValue(key, out var redNoteValueItem))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置红点状态
|
|
||||||
if (redNoteValueItem.SetRedNoteState(value))
|
|
||||||
{
|
|
||||||
//设置红点关联状态
|
|
||||||
CalcRedNoteRelation(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置红点状态数量
|
|
||||||
public void SetNotifyKeyPointNum(string key, int pointNum)
|
|
||||||
{
|
|
||||||
if (!_notifyMap.TryGetValue(key, out var redNoteValueItem))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (redNoteValueItem.SetRedNotePoint(pointNum))
|
|
||||||
{
|
|
||||||
//设置红点关联状态
|
|
||||||
CalcRedNoteRelation(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool GetNotifyValue(RedNoteNotify notify, ulong param1)
|
|
||||||
{
|
|
||||||
_tmpRedNoteParams.Clear();
|
|
||||||
_tmpRedNoteParams.Add(param1);
|
|
||||||
return GetNotifyValue(notify, _tmpRedNoteParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool GetNotifyValue(RedNoteNotify notify, ulong param1, ulong param2)
|
|
||||||
{
|
|
||||||
_tmpRedNoteParams.Clear();
|
|
||||||
_tmpRedNoteParams.Add(param1);
|
|
||||||
_tmpRedNoteParams.Add(param2);
|
|
||||||
return GetNotifyValue(notify, _tmpRedNoteParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取红点状态。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="notify"></param>
|
|
||||||
/// <param name="param"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool GetNotifyValue(RedNoteNotify notify, List<ulong> param = null)
|
|
||||||
{
|
|
||||||
if (notify == (uint)RedNoteNotify.None)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
RedNoteValueItem item = GetOrNewNotifyValueItem(notify, param);
|
|
||||||
return item.GetRedNoteState();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取红点数量。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="notify"></param>
|
|
||||||
/// <param name="param"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public int GetNotifyPointNum(RedNoteNotify notify, List<ulong> param)
|
|
||||||
{
|
|
||||||
if (notify == (uint)RedNoteNotify.None)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
RedNoteValueItem item = GetOrNewNotifyValueItem(notify, param);
|
|
||||||
return item.GetRedNotePointNum();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool GetNotifyValue(string paramKey)
|
|
||||||
{
|
|
||||||
if (_notifyMap.TryGetValue(paramKey, out var redNoteValueItem))
|
|
||||||
{
|
|
||||||
return redNoteValueItem.GetRedNoteState();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清理红点状态.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="notify"></param>
|
|
||||||
public void ClearNotifyValue(RedNoteNotify notify)
|
|
||||||
{
|
|
||||||
var notifyStr = NotifyTypeToString(notify);
|
|
||||||
RecursiveClearNotifyKeyValue(notifyStr);
|
|
||||||
|
|
||||||
RedNoteValueItem redNoteValueItem = GetNotifyValueItem(notifyStr);
|
|
||||||
redNoteValueItem.ClearRedNoteState(false);
|
|
||||||
CalcRedNoteRelation(notifyStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RecursiveClearNotifyKeyValue(string key)
|
|
||||||
{
|
|
||||||
if (!_checkDic.TryGetValue(key, out var checkMgr))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var childList = checkMgr.m_childList;
|
|
||||||
foreach (var childKey in childList)
|
|
||||||
{
|
|
||||||
RedNoteValueItem redNoteValueItem = GetNotifyValueItem(childKey);
|
|
||||||
redNoteValueItem.ClearRedNoteState(false);
|
|
||||||
|
|
||||||
RecursiveClearNotifyKeyValue(childKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清理数据。
|
|
||||||
/// </summary>
|
|
||||||
public void OnRoleLogout()
|
|
||||||
{
|
|
||||||
var enumerator = _notifyMap.GetEnumerator();
|
|
||||||
while (enumerator.MoveNext())
|
|
||||||
{
|
|
||||||
enumerator.Current.Value.ClearRedNoteState(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
enumerator.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string NotifyTypeToString(RedNoteNotify notify)
|
|
||||||
{
|
|
||||||
_notifyStringMap.TryGetValue((int)notify, out var str);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string BuildKey(RedNoteNotify notifyType, List<ulong> paramList)
|
|
||||||
{
|
|
||||||
var notifyStr = NotifyTypeToString(notifyType);
|
|
||||||
if (notifyStr == null)
|
|
||||||
{
|
|
||||||
Log.Error("RedNoteNotifyId :{0} Not Exit! Please Check", notifyType.ToString());
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_keyDic.TryGetValue(notifyStr, out var dicData))
|
|
||||||
{
|
|
||||||
dicData = new RedNoteStructDic();
|
|
||||||
_keyDic[notifyStr] = dicData;
|
|
||||||
}
|
|
||||||
|
|
||||||
var key = dicData.TryGetKey(notifyStr, paramList);
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetKeyString(string notify, List<ulong> paramList)
|
|
||||||
{
|
|
||||||
if (paramList == null || paramList.Count == 0)
|
|
||||||
{
|
|
||||||
return notify;
|
|
||||||
}
|
|
||||||
|
|
||||||
string key;
|
|
||||||
if (paramList.Count <= 1)
|
|
||||||
{
|
|
||||||
key = $"{notify}-{paramList[0]}";
|
|
||||||
}
|
|
||||||
else if (paramList.Count <= 2)
|
|
||||||
{
|
|
||||||
key = $"{notify}-{paramList[0]}-{paramList[1]}";
|
|
||||||
}
|
|
||||||
else if (paramList.Count <= 3)
|
|
||||||
{
|
|
||||||
key = $"{notify}-{paramList[0]}-{paramList[1]}-{paramList[2]}";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
StringBuilder s = new StringBuilder();
|
|
||||||
s.Append(notify + "-");
|
|
||||||
for (var i = 0; i < paramList.Count; i++)
|
|
||||||
{
|
|
||||||
s.Append(paramList[i]);
|
|
||||||
if (i != paramList.Count - 1)
|
|
||||||
s.Append("-");
|
|
||||||
}
|
|
||||||
|
|
||||||
key = s.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetKeyConvertDic(string key, RedNoteKeyStruct keyStruct)
|
|
||||||
{
|
|
||||||
_keyConvertDic[key] = keyStruct;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly List<ulong> _tmpParamList = new List<ulong>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 计算红点关联.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="notifyKey"></param>
|
|
||||||
private void CalcRedNoteRelation(string notifyKey)
|
|
||||||
{
|
|
||||||
var key = notifyKey;
|
|
||||||
if (_checkOwnDic.TryGetValue(key, out var ownerList))
|
|
||||||
{
|
|
||||||
foreach (var owner in ownerList)
|
|
||||||
{
|
|
||||||
if (_checkDic.TryGetValue(owner, out var checker))
|
|
||||||
{
|
|
||||||
checker.CheckChildRedNote();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化红点状态.
|
|
||||||
/// </summary>
|
|
||||||
private void InitState()
|
|
||||||
{
|
|
||||||
var array = (RedNoteNotify[])Enum.GetValues(typeof(RedNoteNotify));
|
|
||||||
|
|
||||||
var redNoteCnt = array.Length;
|
|
||||||
_notifyMap = new Dictionary<string, RedNoteValueItem>();
|
|
||||||
_dicRedNoteMap = new Dictionary<string, RedNoteNotify>(redNoteCnt);
|
|
||||||
_notifyStringMap = new Dictionary<int, string>(redNoteCnt);
|
|
||||||
|
|
||||||
foreach (var redNoteNotify in array)
|
|
||||||
{
|
|
||||||
var redNoteStr = redNoteNotify.ToString();
|
|
||||||
_dicRedNoteMap.Add(redNoteStr, redNoteNotify);
|
|
||||||
_notifyStringMap.Add((int)redNoteNotify, redNoteStr);
|
|
||||||
|
|
||||||
var key = BuildKey(redNoteNotify, _tmpParamList);
|
|
||||||
var redNoteValueItem = new RedNoteValueItem();
|
|
||||||
bool isNumType = IsNumType(redNoteNotify, null);
|
|
||||||
redNoteValueItem.Init(key, isNumType ? RedNoteType.WithNum : RedNoteType.Simple);
|
|
||||||
_notifyMap.Add(key, redNoteValueItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public RedNoteValueItem GetNotifyValueItem(string key)
|
|
||||||
{
|
|
||||||
_notifyMap.TryGetValue(key, out var redNoteValueItem);
|
|
||||||
return redNoteValueItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private RedNoteValueItem GetOrNewNotifyValueItem(RedNoteNotify notify, List<ulong> paramList)
|
|
||||||
{
|
|
||||||
var key = BuildKey(notify, paramList);
|
|
||||||
var redNoteValueItem = GetNotifyValueItem(key);
|
|
||||||
|
|
||||||
if (redNoteValueItem == null)
|
|
||||||
{
|
|
||||||
List<ulong> tmpParamList = new List<ulong>(paramList);
|
|
||||||
|
|
||||||
//从后往前创建item,如(A, 1, 2)会创建A-1-2,A-1,A。
|
|
||||||
string lastChildKey = string.Empty;
|
|
||||||
int paramIndex = paramList.Count;
|
|
||||||
while (paramIndex >= 0)
|
|
||||||
{
|
|
||||||
var keyStr = BuildKey(notify, tmpParamList);
|
|
||||||
|
|
||||||
if (!_notifyMap.ContainsKey(keyStr))
|
|
||||||
{
|
|
||||||
RedNoteValueItem noteValueItem = new RedNoteValueItem();
|
|
||||||
bool isNumType = IsNumType(notify, paramList);
|
|
||||||
noteValueItem.Init(keyStr, isNumType ? RedNoteType.WithNum : RedNoteType.Simple);
|
|
||||||
_notifyMap.Add(keyStr, noteValueItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
//叶子节点跳过(因为他没有子节点)
|
|
||||||
if (tmpParamList.Count < paramList.Count)
|
|
||||||
{
|
|
||||||
bool addedChild;
|
|
||||||
if (!_checkDic.TryGetValue(keyStr, out var checkMgr))
|
|
||||||
{
|
|
||||||
checkMgr = new RedNoteCheckMgr(keyStr);
|
|
||||||
addedChild = checkMgr.AddChild(lastChildKey);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addedChild = checkMgr.AddChild(lastChildKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addedChild)
|
|
||||||
{
|
|
||||||
AddDic(checkMgr); //重新生成父子关系
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lastChildKey = keyStr;
|
|
||||||
paramIndex--;
|
|
||||||
if (paramIndex < tmpParamList.Count && tmpParamList.Count > 0)
|
|
||||||
{
|
|
||||||
tmpParamList.RemoveAt(paramIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
redNoteValueItem = _notifyMap[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
return redNoteValueItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddDic(RedNoteNotify owner, List<RedNoteNotify> childList)
|
|
||||||
{
|
|
||||||
AddDic(new RedNoteCheckMgr(owner, childList));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddDic(RedNoteCheckMgr checker)
|
|
||||||
{
|
|
||||||
var owner = checker.m_ownerStr;
|
|
||||||
_checkDic[owner] = checker;
|
|
||||||
|
|
||||||
var childList = checker.m_childList;
|
|
||||||
int count = childList.Count;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var child = childList[i];
|
|
||||||
if (!_checkOwnDic.TryGetValue(child, out var ownerList))
|
|
||||||
{
|
|
||||||
ownerList = new List<string>();
|
|
||||||
_checkOwnDic[child] = ownerList;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ownerList.Contains(owner))
|
|
||||||
{
|
|
||||||
ownerList.Add(owner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsNumType(RedNoteNotify noteNotify, List<ulong> paramList)
|
|
||||||
{
|
|
||||||
if (paramList is { Count: > 0 })
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 通过名字获取红点类型
|
|
||||||
public static RedNoteNotify GetRedNoteByName(string redNoteName)
|
|
||||||
{
|
|
||||||
Instance._dicRedNoteMap.TryGetValue(redNoteName, out var redNote);
|
|
||||||
|
|
||||||
return redNote;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnUpdate()
|
|
||||||
{
|
|
||||||
foreach (var redNoteValueItem in _notifyMap)
|
|
||||||
{
|
|
||||||
redNoteValueItem.Value.CheckDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 初始化红点
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化红点配置表
|
|
||||||
/// </summary>
|
|
||||||
private void InitRedNoteConfig()
|
|
||||||
{
|
|
||||||
// ResDictionaryList<uint, RedNoteConfig> cfgs = new ResDictionaryList<uint, RedNoteConfig>();
|
|
||||||
// cfgs.Init(val => val.RedNoteParentID);
|
|
||||||
// List<RedNoteNotify> list = new List<RedNoteNotify>();
|
|
||||||
// foreach (var kv in cfgs.Data)
|
|
||||||
// {
|
|
||||||
// list.Clear();
|
|
||||||
// foreach (var cfg in kv.Value)
|
|
||||||
// {
|
|
||||||
// list.Add((RedNoteNotify)cfg.RedNoteID);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// AddDic((RedNoteNotify)kv.Key, list);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
//初始化红点关联
|
|
||||||
private void InitRelation()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class RedNoteStructDic
|
|
||||||
{
|
|
||||||
private readonly List<RedNoteKeyStruct> _keyStructList = new List<RedNoteKeyStruct>();
|
|
||||||
|
|
||||||
public string TryGetKey(string notify, List<ulong> paramList)
|
|
||||||
{
|
|
||||||
string key = string.Empty;
|
|
||||||
List<RedNoteKeyStruct> list = _keyStructList;
|
|
||||||
{
|
|
||||||
int count = list.Count;
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
var keyStruct = list[i];
|
|
||||||
if (keyStruct.IsSame(notify, paramList))
|
|
||||||
{
|
|
||||||
key = keyStruct.Key;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(key))
|
|
||||||
{
|
|
||||||
var keyStruct = new RedNoteKeyStruct(notify, paramList);
|
|
||||||
key = keyStruct.Key;
|
|
||||||
RedNoteMgr.Instance.SetKeyConvertDic(key, keyStruct);
|
|
||||||
list.Add(keyStruct);
|
|
||||||
}
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class RedNoteKeyStruct
|
|
||||||
{
|
|
||||||
public string Notify;
|
|
||||||
public List<ulong> ParamList;
|
|
||||||
|
|
||||||
public RedNoteKeyStruct(string notify, List<ulong> paramList)
|
|
||||||
{
|
|
||||||
Notify = notify;
|
|
||||||
if (paramList != null)
|
|
||||||
{
|
|
||||||
ParamList = new List<ulong>(paramList);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ParamList = new List<ulong>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string _key;
|
|
||||||
|
|
||||||
public string Key
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_key))
|
|
||||||
{
|
|
||||||
_key = RedNoteMgr.GetKeyString(Notify, ParamList);
|
|
||||||
}
|
|
||||||
return _key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsSame(string notify, List<ulong> paramList)
|
|
||||||
{
|
|
||||||
if (notify != Notify)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var list1 = paramList;
|
|
||||||
var list2 = ParamList;
|
|
||||||
|
|
||||||
int cnt1 = list1?.Count ?? 0;
|
|
||||||
int cnt2 = list2?.Count ?? 0;
|
|
||||||
|
|
||||||
if (cnt1 != cnt2)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cnt1 == 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < cnt1; i++)
|
|
||||||
{
|
|
||||||
// ReSharper disable PossibleNullReferenceException
|
|
||||||
if (list1[i] != list2[i])
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 66ededab0a1e409588f150be58193032
|
|
||||||
timeCreated: 1687263893
|
|
@@ -1,159 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
public class RedNoteValueItem
|
|
||||||
{
|
|
||||||
public string m_key;
|
|
||||||
//所有关联的红点UI
|
|
||||||
private HashSet<RedNoteBehaviour> m_redNoteDic = new HashSet<RedNoteBehaviour>();
|
|
||||||
private bool m_state;
|
|
||||||
private int m_pointNum;
|
|
||||||
private RedNoteType m_noteType;
|
|
||||||
|
|
||||||
private bool m_dirty;
|
|
||||||
private bool m_tmpState;
|
|
||||||
|
|
||||||
public void Init(string keyStr, RedNoteType noteType)
|
|
||||||
{
|
|
||||||
m_key = keyStr;
|
|
||||||
m_noteType = noteType;
|
|
||||||
}
|
|
||||||
|
|
||||||
//添加红点对象
|
|
||||||
public void AddRedNote(RedNoteBehaviour redNote)
|
|
||||||
{
|
|
||||||
m_redNoteDic.Add(redNote);
|
|
||||||
}
|
|
||||||
|
|
||||||
//移除对象
|
|
||||||
public void RemoveRedNote(RedNoteBehaviour redNote)
|
|
||||||
{
|
|
||||||
m_redNoteDic.Remove(redNote);
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取具体对象的状态
|
|
||||||
public bool GetRedNoteState()
|
|
||||||
{
|
|
||||||
if (m_dirty)
|
|
||||||
{
|
|
||||||
return m_tmpState;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取具体对象的红点数
|
|
||||||
public int GetRedNotePointNum()
|
|
||||||
{
|
|
||||||
return m_pointNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RedNoteType GetRedNoteType()
|
|
||||||
{
|
|
||||||
return m_noteType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetStateDirty(bool state)
|
|
||||||
{
|
|
||||||
m_dirty = m_state != state;
|
|
||||||
m_tmpState = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置对象状态
|
|
||||||
public bool SetRedNoteState(bool state)
|
|
||||||
{
|
|
||||||
bool chg = state != m_state;
|
|
||||||
m_state = state;
|
|
||||||
if (chg)
|
|
||||||
{
|
|
||||||
SetBehaviourState(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
return chg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetRedNotePoint(int num)
|
|
||||||
{
|
|
||||||
if (m_pointNum != num)
|
|
||||||
{
|
|
||||||
m_pointNum = num;
|
|
||||||
SetBehaviourPoint(num);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetBehaviourState(bool state)
|
|
||||||
{
|
|
||||||
//检查是否注册过具体对象
|
|
||||||
foreach (var redNote in m_redNoteDic)
|
|
||||||
{
|
|
||||||
if (redNote == null || redNote.gameObject == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
redNote.SetRedNoteState(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 移除空的红点
|
|
||||||
ClearTheNullRedNote();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetBehaviourPoint(int pointNum)
|
|
||||||
{
|
|
||||||
foreach (var redNote in m_redNoteDic)
|
|
||||||
{
|
|
||||||
if (redNote == null || redNote.gameObject == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
redNote.SetRedNotePointNum(pointNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 移除空的红点
|
|
||||||
ClearTheNullRedNote();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 移除空的红点
|
|
||||||
private void ClearTheNullRedNote()
|
|
||||||
{
|
|
||||||
m_redNoteDic.RemoveWhere(redNote => redNote == null || redNote.gameObject == null);
|
|
||||||
}
|
|
||||||
|
|
||||||
//清理状态
|
|
||||||
public void ClearRedNoteState(bool clearBehavior)
|
|
||||||
{
|
|
||||||
foreach (var redNote in m_redNoteDic)
|
|
||||||
{
|
|
||||||
if (redNote != null)
|
|
||||||
{
|
|
||||||
redNote.SetRedNoteState(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clearBehavior)
|
|
||||||
{
|
|
||||||
m_redNoteDic.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_state = false;
|
|
||||||
m_dirty = false;
|
|
||||||
m_tmpState = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CheckDirty()
|
|
||||||
{
|
|
||||||
if (m_dirty)
|
|
||||||
{
|
|
||||||
m_dirty = false;
|
|
||||||
RedNoteMgr.Instance.SetNotifyKeyValue(m_key, m_tmpState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum RedNoteType
|
|
||||||
{
|
|
||||||
Simple,
|
|
||||||
WithNum,
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 3c29f4a552c34bd8ab9d2c64b5b2b49d
|
|
||||||
timeCreated: 1687263893
|
|
@@ -1,57 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
public class RedNoteWidget : UIWidget
|
|
||||||
{
|
|
||||||
#region 脚本工具生成的代码
|
|
||||||
protected override void ScriptGenerator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Image m_image;
|
|
||||||
public RedNoteBehaviour m_redNote;
|
|
||||||
protected override void OnCreate()
|
|
||||||
{
|
|
||||||
m_redNote = CreateWidget<RedNoteBehaviour>(gameObject);
|
|
||||||
m_image = gameObject.GetComponent<Image>();
|
|
||||||
rectTransform.anchoredPosition = Vector2.zero;
|
|
||||||
SetNotifyState(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetNotifyType(RedNoteNotify notifyType)
|
|
||||||
{
|
|
||||||
m_redNote.SetNotifyType(notifyType);
|
|
||||||
}
|
|
||||||
public void SetNotifyType(RedNoteNotify notifyType, ulong param1)
|
|
||||||
{
|
|
||||||
m_redNote.SetNotifyType(notifyType, param1);
|
|
||||||
}
|
|
||||||
public void SetNotifyType(RedNoteNotify notifyType, ulong param1, ulong param2)
|
|
||||||
{
|
|
||||||
m_redNote.SetNotifyType(notifyType, param1, param2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetNotifyState(bool state)
|
|
||||||
{
|
|
||||||
m_redNote.SetRedNoteState(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSprite(string sprite)
|
|
||||||
{
|
|
||||||
// m_image.SetSprite(sprite);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnUpdate()
|
|
||||||
{
|
|
||||||
/*if (!m_redNote.CurState)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gameObject.transform.localScale = RedNoteMgr.Instance.GlobalTwScale;*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2644c5700a07442a995008ee9fa8159d
|
|
||||||
timeCreated: 1695289825
|
|
@@ -1,49 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace TEngine
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 封装一个角色可能用到的各种shader场景。
|
|
||||||
/// </summary>
|
|
||||||
class ActorShaderGroup
|
|
||||||
{
|
|
||||||
private readonly TShader[] _allShader = new TShader[(int)ActorShaderEnvType.EnvTypeMax];
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 增加Shader到角色Shader分组。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="shaderType">当前环境类型。</param>
|
|
||||||
/// <param name="shader">TShader。</param>
|
|
||||||
public void AddShader(ActorShaderEnvType shaderType, TShader shader)
|
|
||||||
{
|
|
||||||
_allShader[(int)shaderType] = shader;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 根据当前环境获取Shader。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="type">当前环境类型。</param>
|
|
||||||
/// <returns>TShader。</returns>
|
|
||||||
public TShader GetShader(ActorShaderEnvType type)
|
|
||||||
{
|
|
||||||
return _allShader[(int)type];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 判断是否符合shader集合。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="shader">Shader实例。</param>
|
|
||||||
/// <returns>是否符合。</returns>
|
|
||||||
public bool IsMatch(Shader shader)
|
|
||||||
{
|
|
||||||
foreach (var dodShader in _allShader)
|
|
||||||
{
|
|
||||||
if (dodShader != null && dodShader.Shader == shader)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 79b6e5be73e14c929b6a3b4a980976ac
|
|
||||||
timeCreated: 1701916950
|
|
@@ -1,117 +0,0 @@
|
|||||||
using GameBase;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace TEngine
|
|
||||||
{
|
|
||||||
enum ActorShaderGroupType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 通用的角色shader
|
|
||||||
/// </summary>
|
|
||||||
Brdf = 0,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 眼睛
|
|
||||||
/// </summary>
|
|
||||||
BrdfEye,
|
|
||||||
|
|
||||||
///可能后面扩展,比如特效的特殊角色材质
|
|
||||||
GroupMax,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ActorShaderEnvType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 游戏内场景默认模型,不带阴影,不带xray,不透明效果
|
|
||||||
/// </summary>
|
|
||||||
EnvNormal = 0,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 展示场景
|
|
||||||
/// </summary>
|
|
||||||
EnvShow,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 带阴影
|
|
||||||
/// </summary>
|
|
||||||
EnvShadow,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 带xray,默认也带Shadow
|
|
||||||
/// </summary>
|
|
||||||
EnvXRay,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 透明渐隐效果
|
|
||||||
/// </summary>
|
|
||||||
EnvAlphaFade,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 展示场景没shadow
|
|
||||||
/// </summary>
|
|
||||||
EnvShow_NoShadow,
|
|
||||||
|
|
||||||
EnvTypeMax
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 角色Shader管理器。
|
|
||||||
/// </summary>
|
|
||||||
class ActorShaderMgr : Singleton<ActorShaderMgr>
|
|
||||||
{
|
|
||||||
private readonly ActorShaderGroup[] _allShaderGroup = new ActorShaderGroup[(int)ActorShaderGroupType.GroupMax];
|
|
||||||
|
|
||||||
public ActorShaderMgr()
|
|
||||||
{
|
|
||||||
CreateBrdfShader();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 根据当前Render查找角色的Shader分组。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="render">Render。</param>
|
|
||||||
/// <returns>角色的Shader分组。</returns>
|
|
||||||
public ActorShaderGroup FindShaderGroup(Renderer render)
|
|
||||||
{
|
|
||||||
var sharedMat = render.sharedMaterial;
|
|
||||||
if (sharedMat == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var shader = sharedMat.shader;
|
|
||||||
foreach (var group in _allShaderGroup)
|
|
||||||
{
|
|
||||||
if (group != null && group.IsMatch(shader))
|
|
||||||
{
|
|
||||||
return group;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateBrdfShader()
|
|
||||||
{
|
|
||||||
//通用的效果
|
|
||||||
var actorShader = new ActorShaderGroup();
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvNormal, new TShader("TEngine/Actor/ActorBrdf",shaderLocation:"ActorBrdf"));
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvShow, new TShader("TEngine/Actor/Show/ActorBrdf",shaderLocation:"ActorBrdf_Show"));
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvShow_NoShadow, new TShader("TEngine/Actor/Show/ActorBrdf_NoShadow",shaderLocation:"ActorBrdf_NoShadow"));
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvShadow, new TShader("TEngine/Actor/ActorBrdf",shaderLocation:"ActorBrdf_Normal"));
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvXRay, new TShader("TEngine/Actor/X-Ray",shaderLocation:"X-Ray"));
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvAlphaFade, new TShader("TEngine/Actor/Fade/ActorBrdf",shaderLocation:"ActorBrdf_Fade"));
|
|
||||||
_allShaderGroup[(int)ActorShaderGroupType.Brdf] = actorShader;
|
|
||||||
|
|
||||||
|
|
||||||
//眼睛效果
|
|
||||||
actorShader = new ActorShaderGroup();
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvNormal, new TShader("TEngine/Actor/ActorEye",shaderLocation:"ActorEye"));
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvShow, new TShader("TEngine/Actor/Show/ActorEye",shaderLocation:"ActorEye_Show", "MRT_DISABLE", "MRT_ENABLE"));
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvShadow, new TShader("TEngine/Actor/ActorEye",shaderLocation:"ActorEye"));
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvXRay, new TShader("TEngine/Actor/ActorEye",shaderLocation:"ActorEye"));
|
|
||||||
actorShader.AddShader(ActorShaderEnvType.EnvAlphaFade, new TShader("TEngine/Actor/Fade/ActorEye",shaderLocation:"ActorEye_Fade"));
|
|
||||||
|
|
||||||
_allShaderGroup[(int)ActorShaderGroupType.BrdfEye] = actorShader;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 5a38b9b4bee84fabb1ef8db5292a6db6
|
|
||||||
timeCreated: 1701916853
|
|
@@ -1,154 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace TEngine
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// TShader scripts used for all rendering.
|
|
||||||
/// <remarks>统一封装对shader的管理。</remarks>
|
|
||||||
/// </summary>
|
|
||||||
public class TShader
|
|
||||||
{
|
|
||||||
private bool _loaded;
|
|
||||||
private Shader _shader;
|
|
||||||
private readonly string _shaderName;
|
|
||||||
private readonly string _shaderLocation;
|
|
||||||
private readonly List<string> _keywordOn = new List<string>();
|
|
||||||
private readonly List<string> _keywordOff = new List<string>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Shader scripts used for all rendering.
|
|
||||||
/// </summary>
|
|
||||||
public Shader Shader
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!_loaded)
|
|
||||||
{
|
|
||||||
_loaded = true;
|
|
||||||
_shader = FindShader(_shaderLocation,_shaderName);
|
|
||||||
|
|
||||||
if (_shader == null)
|
|
||||||
{
|
|
||||||
Log.Error($"invalid shader path: {_shaderLocation}, shader name {_shaderName}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _shader;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找Shader。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="shaderLocation">Shader定位地址。</param>
|
|
||||||
/// <param name="shaderName">Shader名称。</param>
|
|
||||||
/// <returns>Shader实例。</returns>
|
|
||||||
public static Shader FindShader(string shaderLocation,string shaderName)
|
|
||||||
{
|
|
||||||
Shader shader = GameModule.Resource.LoadAsset<Shader>(shaderLocation);
|
|
||||||
if (shader != null)
|
|
||||||
{
|
|
||||||
return shader;
|
|
||||||
}
|
|
||||||
return Shader.Find(shaderName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// TShader构造函数。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="shaderName">shader名称。</param>
|
|
||||||
/// <param name="shaderLocation">shader路径。</param>
|
|
||||||
public TShader(string shaderName, string shaderLocation)
|
|
||||||
{
|
|
||||||
_shaderName = shaderName;
|
|
||||||
_shaderLocation = shaderLocation;
|
|
||||||
_shader = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// TShader构造函数。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="shaderName">shader名称。</param>
|
|
||||||
/// <param name="shaderLocation">shader路径。</param>
|
|
||||||
/// <param name="keywordOn">开启选项。</param>
|
|
||||||
/// <param name="keywordOff">关闭选项。</param>
|
|
||||||
public TShader(string shaderName, string shaderLocation, string keywordOn, string keywordOff)
|
|
||||||
{
|
|
||||||
_shaderName = shaderName;
|
|
||||||
_shaderLocation = shaderLocation;
|
|
||||||
_shader = null;
|
|
||||||
_keywordOn.Add(keywordOn);
|
|
||||||
_keywordOff.Add(keywordOff);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// TShader构造函数。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="shaderName">shader名称。</param>
|
|
||||||
/// <param name="shaderLocation">shader路径。</param>
|
|
||||||
/// <param name="keywordOn">开启选项。</param>
|
|
||||||
/// <param name="keywordOff">关闭选项。</param>
|
|
||||||
public TShader(string shaderName, string shaderLocation, string[] keywordOn, string[] keywordOff)
|
|
||||||
{
|
|
||||||
_shaderName = shaderName;
|
|
||||||
_shaderLocation = shaderLocation;
|
|
||||||
_shader = null;
|
|
||||||
_keywordOn.AddRange(keywordOn);
|
|
||||||
_keywordOff.AddRange(keywordOff);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置Shader效果。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="render">渲染对象。</param>
|
|
||||||
public void ApplyRender(Renderer render)
|
|
||||||
{
|
|
||||||
var sharedMat = render.sharedMaterial;
|
|
||||||
if (sharedMat != null)
|
|
||||||
{
|
|
||||||
//copy一份材质
|
|
||||||
sharedMat = render.material;
|
|
||||||
sharedMat.shader = Shader;
|
|
||||||
|
|
||||||
foreach (var keyword in _keywordOff)
|
|
||||||
{
|
|
||||||
sharedMat.DisableKeyword(keyword);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var keyword in _keywordOn)
|
|
||||||
{
|
|
||||||
sharedMat.EnableKeyword(keyword);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清除shader。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="render">渲染对象。</param>
|
|
||||||
public void ClearRender(Renderer render)
|
|
||||||
{
|
|
||||||
if (_keywordOff.Count <= 0 && _keywordOn.Count <= 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var sharedMat = render.sharedMaterial;
|
|
||||||
if (sharedMat != null)
|
|
||||||
{
|
|
||||||
//copy一份材质。
|
|
||||||
sharedMat = render.material;
|
|
||||||
for (int k = 0; k < _keywordOn.Count; k++)
|
|
||||||
{
|
|
||||||
sharedMat.DisableKeyword(_keywordOn[k]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int k = 0; k < _keywordOff.Count; k++)
|
|
||||||
{
|
|
||||||
sharedMat.EnableKeyword(_keywordOff[k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e219233984c14f7d97bc744c07fe13d0
|
|
||||||
timeCreated: 1698115491
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 0615e8b32d534bc48a60e42c973053ad
|
|
||||||
timeCreated: 1695289443
|
|
@@ -1,84 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
public class ClickEventListener : MonoBehaviour, IPointerClickHandler, IPointerDownHandler, IPointerUpHandler
|
|
||||||
{
|
|
||||||
public static ClickEventListener Get(GameObject obj)
|
|
||||||
{
|
|
||||||
ClickEventListener listener = obj.GetComponent<ClickEventListener>();
|
|
||||||
if (listener == null)
|
|
||||||
{
|
|
||||||
listener = obj.AddComponent<ClickEventListener>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
private System.Action<GameObject> _clickedHandler = null;
|
|
||||||
private System.Action<GameObject> _doubleClickedHandler = null;
|
|
||||||
private System.Action<GameObject> _onPointerDownHandler = null;
|
|
||||||
private System.Action<GameObject> _onPointerUpHandler = null;
|
|
||||||
bool _isPressed = false;
|
|
||||||
|
|
||||||
public bool IsPressed => _isPressed;
|
|
||||||
|
|
||||||
public void OnPointerClick(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (eventData.clickCount == 2)
|
|
||||||
{
|
|
||||||
if (_doubleClickedHandler != null)
|
|
||||||
{
|
|
||||||
_doubleClickedHandler(gameObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_clickedHandler != null)
|
|
||||||
{
|
|
||||||
_clickedHandler(gameObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetClickEventHandler(System.Action<GameObject> handler)
|
|
||||||
{
|
|
||||||
_clickedHandler = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetDoubleClickEventHandler(System.Action<GameObject> handler)
|
|
||||||
{
|
|
||||||
_doubleClickedHandler = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetPointerDownHandler(System.Action<GameObject> handler)
|
|
||||||
{
|
|
||||||
_onPointerDownHandler = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetPointerUpHandler(System.Action<GameObject> handler)
|
|
||||||
{
|
|
||||||
_onPointerUpHandler = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void OnPointerDown(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
_isPressed = true;
|
|
||||||
if (_onPointerDownHandler != null)
|
|
||||||
{
|
|
||||||
_onPointerDownHandler(gameObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnPointerUp(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
_isPressed = false;
|
|
||||||
if (_onPointerUpHandler != null)
|
|
||||||
{
|
|
||||||
_onPointerUpHandler(gameObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,86 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
public enum SnapStatus
|
|
||||||
{
|
|
||||||
NoTargetSet = 0,
|
|
||||||
TargetHasSet = 1,
|
|
||||||
SnapMoving = 2,
|
|
||||||
SnapMoveFinish = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public enum ItemCornerEnum
|
|
||||||
{
|
|
||||||
LeftBottom = 0,
|
|
||||||
LeftTop,
|
|
||||||
RightTop,
|
|
||||||
RightBottom,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public enum ListItemArrangeType
|
|
||||||
{
|
|
||||||
TopToBottom = 0,
|
|
||||||
BottomToTop,
|
|
||||||
LeftToRight,
|
|
||||||
RightToLeft,
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum GridItemArrangeType
|
|
||||||
{
|
|
||||||
TopLeftToBottomRight = 0,
|
|
||||||
BottomLeftToTopRight,
|
|
||||||
TopRightToBottomLeft,
|
|
||||||
BottomRightToTopLeft,
|
|
||||||
}
|
|
||||||
public enum GridFixedType
|
|
||||||
{
|
|
||||||
ColumnCountFixed = 0,
|
|
||||||
RowCountFixed,
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct RowColumnPair
|
|
||||||
{
|
|
||||||
public RowColumnPair(int row1, int column1)
|
|
||||||
{
|
|
||||||
mRow = row1;
|
|
||||||
mColumn = column1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(RowColumnPair other)
|
|
||||||
{
|
|
||||||
return this.mRow == other.mRow && this.mColumn == other.mColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(RowColumnPair a, RowColumnPair b)
|
|
||||||
{
|
|
||||||
return (a.mRow == b.mRow)&&(a.mColumn == b.mColumn);
|
|
||||||
}
|
|
||||||
public static bool operator !=(RowColumnPair a, RowColumnPair b)
|
|
||||||
{
|
|
||||||
return (a.mRow != b.mRow) || (a.mColumn != b.mColumn); ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (obj is RowColumnPair) && Equals((RowColumnPair)obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int mRow;
|
|
||||||
public int mColumn;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 19e4e487f35877f4b9bb864eb43484d6
|
|
||||||
timeCreated: 1534508353
|
|
||||||
licenseType: Store
|
|
||||||
MonoImporter:
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@@ -1,326 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
public class ItemSizeGroup
|
|
||||||
{
|
|
||||||
public float[] ItemSizeArray = null;
|
|
||||||
public float[] ItemStartPosArray = null;
|
|
||||||
public int ItemCount = 0;
|
|
||||||
private int _dirtyBeginIndex = ItemPosMgr.ItemMaxCountPerGroup;
|
|
||||||
public float GroupSize = 0;
|
|
||||||
public float GroupStartPos = 0;
|
|
||||||
public float GroupEndPos = 0;
|
|
||||||
public int GroupIndex = 0;
|
|
||||||
public float ItemDefaultSize = 0;
|
|
||||||
|
|
||||||
public ItemSizeGroup(int index, float itemDefaultSize)
|
|
||||||
{
|
|
||||||
GroupIndex = index;
|
|
||||||
ItemDefaultSize = itemDefaultSize;
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Init()
|
|
||||||
{
|
|
||||||
ItemSizeArray = new float[ItemPosMgr.ItemMaxCountPerGroup];
|
|
||||||
if (ItemDefaultSize != 0)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ItemSizeArray.Length; ++i)
|
|
||||||
{
|
|
||||||
ItemSizeArray[i] = ItemDefaultSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStartPosArray = new float[ItemPosMgr.ItemMaxCountPerGroup];
|
|
||||||
ItemStartPosArray[0] = 0;
|
|
||||||
ItemCount = ItemPosMgr.ItemMaxCountPerGroup;
|
|
||||||
GroupSize = ItemDefaultSize * ItemSizeArray.Length;
|
|
||||||
if (ItemDefaultSize != 0)
|
|
||||||
{
|
|
||||||
_dirtyBeginIndex = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_dirtyBeginIndex = ItemPosMgr.ItemMaxCountPerGroup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float GetItemStartPos(int index)
|
|
||||||
{
|
|
||||||
return GroupStartPos + ItemStartPosArray[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsDirty
|
|
||||||
{
|
|
||||||
get { return (_dirtyBeginIndex < ItemCount); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public float SetItemSize(int index, float size)
|
|
||||||
{
|
|
||||||
float old = ItemSizeArray[index];
|
|
||||||
if (Math.Abs(old - size) < 0.001f)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemSizeArray[index] = size;
|
|
||||||
if (index < _dirtyBeginIndex)
|
|
||||||
{
|
|
||||||
_dirtyBeginIndex = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ds = size - old;
|
|
||||||
GroupSize = GroupSize + ds;
|
|
||||||
return ds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetItemCount(int count)
|
|
||||||
{
|
|
||||||
if (ItemCount == count)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemCount = count;
|
|
||||||
RecalcGroupSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RecalcGroupSize()
|
|
||||||
{
|
|
||||||
GroupSize = 0;
|
|
||||||
for (int i = 0; i < ItemCount; ++i)
|
|
||||||
{
|
|
||||||
GroupSize += ItemSizeArray[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetItemIndexByPos(float pos)
|
|
||||||
{
|
|
||||||
if (ItemCount == 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int low = 0;
|
|
||||||
int high = ItemCount - 1;
|
|
||||||
while (low <= high)
|
|
||||||
{
|
|
||||||
int mid = (low + high) / 2;
|
|
||||||
float startPos = ItemStartPosArray[mid];
|
|
||||||
float endPos = startPos + ItemSizeArray[mid];
|
|
||||||
if (startPos <= pos && endPos >= pos)
|
|
||||||
{
|
|
||||||
return mid;
|
|
||||||
}
|
|
||||||
else if (pos > endPos)
|
|
||||||
{
|
|
||||||
low = mid + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
high = mid - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateAllItemStartPos()
|
|
||||||
{
|
|
||||||
if (_dirtyBeginIndex >= ItemCount)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int startIndex = (_dirtyBeginIndex < 1) ? 1 : _dirtyBeginIndex;
|
|
||||||
for (int i = startIndex; i < ItemCount; ++i)
|
|
||||||
{
|
|
||||||
ItemStartPosArray[i] = ItemStartPosArray[i - 1] + ItemSizeArray[i - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
_dirtyBeginIndex = ItemCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ItemPosMgr
|
|
||||||
{
|
|
||||||
public const int ItemMaxCountPerGroup = 100;
|
|
||||||
readonly List<ItemSizeGroup> _itemSizeGroupList = new List<ItemSizeGroup>();
|
|
||||||
public int _dirtyBeginIndex = int.MaxValue;
|
|
||||||
public float TotalSize = 0;
|
|
||||||
public float ItemDefaultSize = 20;
|
|
||||||
|
|
||||||
public ItemPosMgr(float itemDefaultSize)
|
|
||||||
{
|
|
||||||
ItemDefaultSize = itemDefaultSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetItemMaxCount(int maxCount)
|
|
||||||
{
|
|
||||||
_dirtyBeginIndex = 0;
|
|
||||||
TotalSize = 0;
|
|
||||||
int st = maxCount % ItemMaxCountPerGroup;
|
|
||||||
int lastGroupItemCount = st;
|
|
||||||
int needMaxGroupCount = maxCount / ItemMaxCountPerGroup;
|
|
||||||
if (st > 0)
|
|
||||||
{
|
|
||||||
needMaxGroupCount++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lastGroupItemCount = ItemMaxCountPerGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
int count = _itemSizeGroupList.Count;
|
|
||||||
if (count > needMaxGroupCount)
|
|
||||||
{
|
|
||||||
int d = count - needMaxGroupCount;
|
|
||||||
_itemSizeGroupList.RemoveRange(needMaxGroupCount, d);
|
|
||||||
}
|
|
||||||
else if (count < needMaxGroupCount)
|
|
||||||
{
|
|
||||||
int d = needMaxGroupCount - count;
|
|
||||||
for (int i = 0; i < d; ++i)
|
|
||||||
{
|
|
||||||
ItemSizeGroup tGroup = new ItemSizeGroup(count + i, ItemDefaultSize);
|
|
||||||
_itemSizeGroupList.Add(tGroup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
count = _itemSizeGroupList.Count;
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < count - 1; ++i)
|
|
||||||
{
|
|
||||||
_itemSizeGroupList[i].SetItemCount(ItemMaxCountPerGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
_itemSizeGroupList[count - 1].SetItemCount(lastGroupItemCount);
|
|
||||||
for (int i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
TotalSize = TotalSize + _itemSizeGroupList[i].GroupSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetItemSize(int itemIndex, float size)
|
|
||||||
{
|
|
||||||
int groupIndex = itemIndex / ItemMaxCountPerGroup;
|
|
||||||
int indexInGroup = itemIndex % ItemMaxCountPerGroup;
|
|
||||||
ItemSizeGroup tGroup = _itemSizeGroupList[groupIndex];
|
|
||||||
float changedSize = tGroup.SetItemSize(indexInGroup, size);
|
|
||||||
if (changedSize != 0f)
|
|
||||||
{
|
|
||||||
if (groupIndex < _dirtyBeginIndex)
|
|
||||||
{
|
|
||||||
_dirtyBeginIndex = groupIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TotalSize += changedSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float GetItemPos(int itemIndex)
|
|
||||||
{
|
|
||||||
Update(true);
|
|
||||||
int groupIndex = itemIndex / ItemMaxCountPerGroup;
|
|
||||||
int indexInGroup = itemIndex % ItemMaxCountPerGroup;
|
|
||||||
return _itemSizeGroupList[groupIndex].GetItemStartPos(indexInGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GetItemIndexAndPosAtGivenPos(float pos, ref int index, ref float itemPos)
|
|
||||||
{
|
|
||||||
Update(true);
|
|
||||||
index = 0;
|
|
||||||
itemPos = 0f;
|
|
||||||
int count = _itemSizeGroupList.Count;
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemSizeGroup hitGroup = null;
|
|
||||||
|
|
||||||
int low = 0;
|
|
||||||
int high = count - 1;
|
|
||||||
while (low <= high)
|
|
||||||
{
|
|
||||||
int mid = (low + high) / 2;
|
|
||||||
ItemSizeGroup tGroup = _itemSizeGroupList[mid];
|
|
||||||
if (tGroup.GroupStartPos <= pos && tGroup.GroupEndPos >= pos)
|
|
||||||
{
|
|
||||||
hitGroup = tGroup;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (pos > tGroup.GroupEndPos)
|
|
||||||
{
|
|
||||||
low = mid + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
high = mid - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int hitIndex = -1;
|
|
||||||
if (hitGroup != null)
|
|
||||||
{
|
|
||||||
hitIndex = hitGroup.GetItemIndexByPos(pos - hitGroup.GroupStartPos);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hitIndex < 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
index = hitIndex + hitGroup.GroupIndex * ItemMaxCountPerGroup;
|
|
||||||
itemPos = hitGroup.GetItemStartPos(hitIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update(bool updateAll)
|
|
||||||
{
|
|
||||||
int count = _itemSizeGroupList.Count;
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_dirtyBeginIndex >= count)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int loopCount = 0;
|
|
||||||
for (int i = _dirtyBeginIndex; i < count; ++i)
|
|
||||||
{
|
|
||||||
loopCount++;
|
|
||||||
ItemSizeGroup tGroup = _itemSizeGroupList[i];
|
|
||||||
_dirtyBeginIndex++;
|
|
||||||
tGroup.UpdateAllItemStartPos();
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
tGroup.GroupStartPos = 0;
|
|
||||||
tGroup.GroupEndPos = tGroup.GroupSize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tGroup.GroupStartPos = _itemSizeGroupList[i - 1].GroupEndPos;
|
|
||||||
tGroup.GroupEndPos = tGroup.GroupStartPos + tGroup.GroupSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!updateAll && loopCount > 1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d7f738dc5a266e94d9e9870fc76009c2
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@@ -1,173 +0,0 @@
|
|||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
//if GridFixedType is GridFixedType.ColumnCountFixed, then the GridItemGroup is one row of the gridview
|
|
||||||
//if GridFixedType is GridFixedType.RowCountFixed, then the GridItemGroup is one column of the gridview
|
|
||||||
public class GridItemGroup
|
|
||||||
{
|
|
||||||
private int _count = 0;
|
|
||||||
private int _groupIndex = -1;//the row index or the column index of this group
|
|
||||||
private LoopGridViewItem _first = null;
|
|
||||||
private LoopGridViewItem _last = null;
|
|
||||||
public int Count => _count;
|
|
||||||
|
|
||||||
public LoopGridViewItem First => _first;
|
|
||||||
|
|
||||||
public LoopGridViewItem Last => _last;
|
|
||||||
|
|
||||||
public int GroupIndex
|
|
||||||
{
|
|
||||||
get => _groupIndex;
|
|
||||||
set => _groupIndex = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public LoopGridViewItem GetItemByColumn(int column)
|
|
||||||
{
|
|
||||||
LoopGridViewItem cur = _first;
|
|
||||||
while(cur != null)
|
|
||||||
{
|
|
||||||
if(cur.Column == column)
|
|
||||||
{
|
|
||||||
return cur;
|
|
||||||
}
|
|
||||||
cur = cur.NextItem;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public LoopGridViewItem GetItemByRow(int row)
|
|
||||||
{
|
|
||||||
LoopGridViewItem cur = _first;
|
|
||||||
while (cur != null)
|
|
||||||
{
|
|
||||||
if (cur.Row == row)
|
|
||||||
{
|
|
||||||
return cur;
|
|
||||||
}
|
|
||||||
cur = cur.NextItem;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void ReplaceItem(LoopGridViewItem curItem,LoopGridViewItem newItem)
|
|
||||||
{
|
|
||||||
newItem.PrevItem = curItem.PrevItem;
|
|
||||||
newItem.NextItem = curItem.NextItem;
|
|
||||||
if(newItem.PrevItem != null)
|
|
||||||
{
|
|
||||||
newItem.PrevItem.NextItem = newItem;
|
|
||||||
}
|
|
||||||
if(newItem.NextItem != null)
|
|
||||||
{
|
|
||||||
newItem.NextItem.PrevItem = newItem;
|
|
||||||
}
|
|
||||||
if(_first == curItem)
|
|
||||||
{
|
|
||||||
_first = newItem;
|
|
||||||
}
|
|
||||||
if(_last == curItem)
|
|
||||||
{
|
|
||||||
_last = newItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddFirst(LoopGridViewItem newItem)
|
|
||||||
{
|
|
||||||
newItem.PrevItem = null;
|
|
||||||
newItem.NextItem = null;
|
|
||||||
if (_first == null)
|
|
||||||
{
|
|
||||||
_first = newItem;
|
|
||||||
_last = newItem;
|
|
||||||
_first.PrevItem = null;
|
|
||||||
_first.NextItem = null;
|
|
||||||
_count++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_first.PrevItem = newItem;
|
|
||||||
newItem.PrevItem = null;
|
|
||||||
newItem.NextItem = _first;
|
|
||||||
_first = newItem;
|
|
||||||
_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddLast(LoopGridViewItem newItem)
|
|
||||||
{
|
|
||||||
newItem.PrevItem = null;
|
|
||||||
newItem.NextItem = null;
|
|
||||||
if (_first == null)
|
|
||||||
{
|
|
||||||
_first = newItem;
|
|
||||||
_last = newItem;
|
|
||||||
_first.PrevItem = null;
|
|
||||||
_first.NextItem = null;
|
|
||||||
_count++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_last.NextItem = newItem;
|
|
||||||
newItem.PrevItem = _last;
|
|
||||||
newItem.NextItem = null;
|
|
||||||
_last = newItem;
|
|
||||||
_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoopGridViewItem RemoveFirst()
|
|
||||||
{
|
|
||||||
LoopGridViewItem ret = _first;
|
|
||||||
if (_first == null)
|
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
if(_first == _last)
|
|
||||||
{
|
|
||||||
_first = null;
|
|
||||||
_last = null;
|
|
||||||
--_count;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
_first = _first.NextItem;
|
|
||||||
_first.PrevItem = null;
|
|
||||||
--_count;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
public LoopGridViewItem RemoveLast()
|
|
||||||
{
|
|
||||||
LoopGridViewItem ret = _last;
|
|
||||||
if (_first == null)
|
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
if (_first == _last)
|
|
||||||
{
|
|
||||||
_first = null;
|
|
||||||
_last = null;
|
|
||||||
--_count;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
_last = _last.PrevItem;
|
|
||||||
_last.NextItem = null;
|
|
||||||
--_count;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Clear()
|
|
||||||
{
|
|
||||||
LoopGridViewItem current = _first;
|
|
||||||
while (current != null)
|
|
||||||
{
|
|
||||||
current.PrevItem = null;
|
|
||||||
current.NextItem = null;
|
|
||||||
current = current.NextItem;
|
|
||||||
}
|
|
||||||
_first = null;
|
|
||||||
_last = null;
|
|
||||||
_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f7e7eb25fe1319d4b8773ddfab7a240e
|
|
||||||
timeCreated: 1554538573
|
|
||||||
licenseType: Store
|
|
||||||
MonoImporter:
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@@ -1,113 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
public class GridItemPool
|
|
||||||
{
|
|
||||||
private GameObject _prefabObj;
|
|
||||||
private string _prefabName;
|
|
||||||
private int _initCreateCount = 1;
|
|
||||||
private readonly List<LoopGridViewItem> _tmpPooledItemList = new List<LoopGridViewItem>();
|
|
||||||
private readonly List<LoopGridViewItem> _pooledItemList = new List<LoopGridViewItem>();
|
|
||||||
private static int _curItemIdCount = 0;
|
|
||||||
private RectTransform _itemParent = null;
|
|
||||||
public GridItemPool()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
public void Init(GameObject prefabObj, int createCount, RectTransform parent)
|
|
||||||
{
|
|
||||||
_prefabObj = prefabObj;
|
|
||||||
_prefabName = _prefabObj.name;
|
|
||||||
_initCreateCount = createCount;
|
|
||||||
_itemParent = parent;
|
|
||||||
_prefabObj.SetActive(false);
|
|
||||||
for (int i = 0; i < _initCreateCount; ++i)
|
|
||||||
{
|
|
||||||
LoopGridViewItem tViewItem = CreateItem();
|
|
||||||
RecycleItemReal(tViewItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public LoopGridViewItem GetItem()
|
|
||||||
{
|
|
||||||
_curItemIdCount++;
|
|
||||||
LoopGridViewItem tItem = null;
|
|
||||||
if (_tmpPooledItemList.Count > 0)
|
|
||||||
{
|
|
||||||
int count = _tmpPooledItemList.Count;
|
|
||||||
tItem = _tmpPooledItemList[count - 1];
|
|
||||||
_tmpPooledItemList.RemoveAt(count - 1);
|
|
||||||
tItem.gameObject.SetActive(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int count = _pooledItemList.Count;
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
tItem = CreateItem();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tItem = _pooledItemList[count - 1];
|
|
||||||
_pooledItemList.RemoveAt(count - 1);
|
|
||||||
tItem.gameObject.SetActive(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tItem.ItemId = _curItemIdCount;
|
|
||||||
return tItem;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DestroyAllItem()
|
|
||||||
{
|
|
||||||
ClearTmpRecycledItem();
|
|
||||||
int count = _pooledItemList.Count;
|
|
||||||
for (int i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
GameObject.DestroyImmediate(_pooledItemList[i].gameObject);
|
|
||||||
}
|
|
||||||
_pooledItemList.Clear();
|
|
||||||
}
|
|
||||||
public LoopGridViewItem CreateItem()
|
|
||||||
{
|
|
||||||
|
|
||||||
GameObject go = GameObject.Instantiate<GameObject>(_prefabObj, Vector3.zero, Quaternion.identity, _itemParent);
|
|
||||||
go.SetActive(true);
|
|
||||||
RectTransform rf = go.GetComponent<RectTransform>();
|
|
||||||
rf.localScale = Vector3.one;
|
|
||||||
rf.anchoredPosition3D = Vector3.zero;
|
|
||||||
rf.localEulerAngles = Vector3.zero;
|
|
||||||
LoopGridViewItem tViewItem = go.GetComponent<LoopGridViewItem>();
|
|
||||||
tViewItem.ItemPrefabName = _prefabName;
|
|
||||||
tViewItem.GoId = go.GetHashCode();
|
|
||||||
return tViewItem;
|
|
||||||
}
|
|
||||||
void RecycleItemReal(LoopGridViewItem item)
|
|
||||||
{
|
|
||||||
item.gameObject.SetActive(false);
|
|
||||||
_pooledItemList.Add(item);
|
|
||||||
}
|
|
||||||
public void RecycleItem(LoopGridViewItem item)
|
|
||||||
{
|
|
||||||
item.PrevItem = null;
|
|
||||||
item.NextItem = null;
|
|
||||||
_tmpPooledItemList.Add(item);
|
|
||||||
}
|
|
||||||
public void ClearTmpRecycledItem()
|
|
||||||
{
|
|
||||||
int count = _tmpPooledItemList.Count;
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
RecycleItemReal(_tmpPooledItemList[i]);
|
|
||||||
}
|
|
||||||
_tmpPooledItemList.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c1eb92a17e8cee642a2245950dfaabea
|
|
||||||
timeCreated: 1554538573
|
|
||||||
licenseType: Store
|
|
||||||
MonoImporter:
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 17e9881a7bce8124a8f855b96a8ca11a
|
|
||||||
timeCreated: 1554538573
|
|
||||||
licenseType: Store
|
|
||||||
MonoImporter:
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@@ -1,184 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
|
|
||||||
public class LoopGridViewItem : MonoBehaviour
|
|
||||||
{
|
|
||||||
// indicates the item’s index in the list the mItemIndex can only be from 0 to itemTotalCount -1.
|
|
||||||
int mItemIndex = -1;
|
|
||||||
// the row index, the item is in. starting from 0.
|
|
||||||
int mRow = -1;
|
|
||||||
// the column index, the item is in. starting from 0.
|
|
||||||
int mColumn = -1;
|
|
||||||
//indicates the item’s id.
|
|
||||||
//This property is set when the item is created or fetched from pool,
|
|
||||||
//and will no longer change until the item is recycled back to pool.
|
|
||||||
int mItemId = -1;
|
|
||||||
|
|
||||||
private int _goId = 0;
|
|
||||||
|
|
||||||
public int GoId
|
|
||||||
{
|
|
||||||
set => _goId = value;
|
|
||||||
get => _goId;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoopGridView mParentGridView = null;
|
|
||||||
bool mIsInitHandlerCalled = false;
|
|
||||||
string mItemPrefabName;
|
|
||||||
RectTransform mCachedRectTransform;
|
|
||||||
int mItemCreatedCheckFrameCount = 0;
|
|
||||||
|
|
||||||
object mUserObjectData = null;
|
|
||||||
int mUserIntData1 = 0;
|
|
||||||
int mUserIntData2 = 0;
|
|
||||||
string mUserStringData1 = null;
|
|
||||||
string mUserStringData2 = null;
|
|
||||||
|
|
||||||
LoopGridViewItem mPrevItem;
|
|
||||||
LoopGridViewItem mNextItem;
|
|
||||||
|
|
||||||
public object UserObjectData
|
|
||||||
{
|
|
||||||
get { return mUserObjectData; }
|
|
||||||
set { mUserObjectData = value; }
|
|
||||||
}
|
|
||||||
public int UserIntData1
|
|
||||||
{
|
|
||||||
get { return mUserIntData1; }
|
|
||||||
set { mUserIntData1 = value; }
|
|
||||||
}
|
|
||||||
public int UserIntData2
|
|
||||||
{
|
|
||||||
get { return mUserIntData2; }
|
|
||||||
set { mUserIntData2 = value; }
|
|
||||||
}
|
|
||||||
public string UserStringData1
|
|
||||||
{
|
|
||||||
get { return mUserStringData1; }
|
|
||||||
set { mUserStringData1 = value; }
|
|
||||||
}
|
|
||||||
public string UserStringData2
|
|
||||||
{
|
|
||||||
get { return mUserStringData2; }
|
|
||||||
set { mUserStringData2 = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ItemCreatedCheckFrameCount
|
|
||||||
{
|
|
||||||
get { return mItemCreatedCheckFrameCount; }
|
|
||||||
set { mItemCreatedCheckFrameCount = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public RectTransform CachedRectTransform
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (mCachedRectTransform == null)
|
|
||||||
{
|
|
||||||
mCachedRectTransform = gameObject.GetComponent<RectTransform>();
|
|
||||||
}
|
|
||||||
return mCachedRectTransform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ItemPrefabName
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return mItemPrefabName;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
mItemPrefabName = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Row
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return mRow;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
mRow = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int Column
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return mColumn;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
mColumn = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ItemIndex
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return mItemIndex;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
mItemIndex = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int ItemId
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return mItemId;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
mItemId = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public bool IsInitHandlerCalled
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return mIsInitHandlerCalled;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
mIsInitHandlerCalled = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoopGridView ParentGridView
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return mParentGridView;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
mParentGridView = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoopGridViewItem PrevItem
|
|
||||||
{
|
|
||||||
get { return mPrevItem; }
|
|
||||||
set { mPrevItem = value; }
|
|
||||||
}
|
|
||||||
public LoopGridViewItem NextItem
|
|
||||||
{
|
|
||||||
get { return mNextItem; }
|
|
||||||
set { mNextItem = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ec0432517adfcb84bb6163d7a44ab8c1
|
|
||||||
timeCreated: 1554538573
|
|
||||||
licenseType: Store
|
|
||||||
MonoImporter:
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e9bbd48a4abc45c46a92b92d0df3ae07
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,216 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
public class LoopListViewItem : MonoBehaviour
|
|
||||||
{
|
|
||||||
public float Padding;
|
|
||||||
|
|
||||||
private int _itemIndex = -1;
|
|
||||||
private int _itemId = -1;
|
|
||||||
private LoopListView _parentListView = null;
|
|
||||||
private bool _isInitHandlerCalled = false;
|
|
||||||
private string _itemPrefabName;
|
|
||||||
private RectTransform _cachedRectTransform;
|
|
||||||
private float _padding;
|
|
||||||
private float _distanceWithViewPortSnapCenter = 0;
|
|
||||||
private int _itemCreatedCheckFrameCount = 0;
|
|
||||||
private float _startPosOffset = 0;
|
|
||||||
|
|
||||||
private object _userObjectData = null;
|
|
||||||
private int _userIntData1 = 0;
|
|
||||||
private int _userIntData2 = 0;
|
|
||||||
private string _userStringData1 = null;
|
|
||||||
private string _userStringData2 = null;
|
|
||||||
|
|
||||||
private int _goId = 0;
|
|
||||||
|
|
||||||
public int GoId
|
|
||||||
{
|
|
||||||
set => _goId = value;
|
|
||||||
get => _goId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object UserObjectData
|
|
||||||
{
|
|
||||||
get => _userObjectData;
|
|
||||||
set => _userObjectData = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int UserIntData1
|
|
||||||
{
|
|
||||||
get => _userIntData1;
|
|
||||||
set => _userIntData1 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int UserIntData2
|
|
||||||
{
|
|
||||||
get => _userIntData2;
|
|
||||||
set => _userIntData2 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string UserStringData1
|
|
||||||
{
|
|
||||||
get => _userStringData1;
|
|
||||||
set => _userStringData1 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string UserStringData2
|
|
||||||
{
|
|
||||||
get => _userStringData2;
|
|
||||||
set => _userStringData2 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float DistanceWithViewPortSnapCenter
|
|
||||||
{
|
|
||||||
get => _distanceWithViewPortSnapCenter;
|
|
||||||
set => _distanceWithViewPortSnapCenter = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float StartPosOffset
|
|
||||||
{
|
|
||||||
get => _startPosOffset;
|
|
||||||
set => _startPosOffset = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ItemCreatedCheckFrameCount
|
|
||||||
{
|
|
||||||
get => _itemCreatedCheckFrameCount;
|
|
||||||
set => _itemCreatedCheckFrameCount = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RectTransform CachedRectTransform
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_cachedRectTransform == null)
|
|
||||||
{
|
|
||||||
_cachedRectTransform = gameObject.GetComponent<RectTransform>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _cachedRectTransform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ItemPrefabName
|
|
||||||
{
|
|
||||||
get => _itemPrefabName;
|
|
||||||
set => _itemPrefabName = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ItemIndex
|
|
||||||
{
|
|
||||||
get => _itemIndex;
|
|
||||||
set => _itemIndex = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ItemId
|
|
||||||
{
|
|
||||||
get => _itemId;
|
|
||||||
set => _itemId = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public bool IsInitHandlerCalled
|
|
||||||
{
|
|
||||||
get => _isInitHandlerCalled;
|
|
||||||
set => _isInitHandlerCalled = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoopListView ParentListView
|
|
||||||
{
|
|
||||||
get => _parentListView;
|
|
||||||
set => _parentListView = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float TopY
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
ListItemArrangeType arrageType = ParentListView.ArrangeType;
|
|
||||||
if (arrageType == ListItemArrangeType.TopToBottom)
|
|
||||||
{
|
|
||||||
return CachedRectTransform.localPosition.y;
|
|
||||||
}
|
|
||||||
else if (arrageType == ListItemArrangeType.BottomToTop)
|
|
||||||
{
|
|
||||||
return CachedRectTransform.localPosition.y + CachedRectTransform.rect.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float BottomY
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
ListItemArrangeType arrageType = ParentListView.ArrangeType;
|
|
||||||
if (arrageType == ListItemArrangeType.TopToBottom)
|
|
||||||
{
|
|
||||||
return CachedRectTransform.localPosition.y - CachedRectTransform.rect.height;
|
|
||||||
}
|
|
||||||
else if (arrageType == ListItemArrangeType.BottomToTop)
|
|
||||||
{
|
|
||||||
return CachedRectTransform.localPosition.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public float LeftX
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
ListItemArrangeType arrageType = ParentListView.ArrangeType;
|
|
||||||
if (arrageType == ListItemArrangeType.LeftToRight)
|
|
||||||
{
|
|
||||||
return CachedRectTransform.localPosition.x;
|
|
||||||
}
|
|
||||||
else if (arrageType == ListItemArrangeType.RightToLeft)
|
|
||||||
{
|
|
||||||
return CachedRectTransform.localPosition.x - CachedRectTransform.rect.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float RightX
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
ListItemArrangeType arrageType = ParentListView.ArrangeType;
|
|
||||||
if (arrageType == ListItemArrangeType.LeftToRight)
|
|
||||||
{
|
|
||||||
return CachedRectTransform.localPosition.x + CachedRectTransform.rect.width;
|
|
||||||
}
|
|
||||||
else if (arrageType == ListItemArrangeType.RightToLeft)
|
|
||||||
{
|
|
||||||
return CachedRectTransform.localPosition.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float ItemSize
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (ParentListView.IsVertList)
|
|
||||||
{
|
|
||||||
return CachedRectTransform.rect.height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return CachedRectTransform.rect.width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float ItemSizeWithPadding => ItemSize + _padding;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 4f3fbd5ce2514056b72986a6dea2aec2
|
|
||||||
timeCreated: 1695289443
|
|
@@ -1,71 +0,0 @@
|
|||||||
using TEngine;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 子界面之间共享的数据。
|
|
||||||
/// </summary>
|
|
||||||
public class ChildPageSharData
|
|
||||||
{
|
|
||||||
private object[] m_arrParams = new object[3]; // 共享参数列表
|
|
||||||
|
|
||||||
public object Param1 { get { return m_arrParams[0]; } }
|
|
||||||
public object Param2 { get { return m_arrParams[1]; } }
|
|
||||||
public object Param3 { get { return m_arrParams[2]; } }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置指定索引的参数。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="paramIdx"></param>
|
|
||||||
/// <param name="param"></param>
|
|
||||||
public void SetParam(int paramIdx, object param)
|
|
||||||
{
|
|
||||||
if (paramIdx >= m_arrParams.Length)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_arrParams[paramIdx] = param;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ChildPageBase : UIWidget
|
|
||||||
{
|
|
||||||
|
|
||||||
protected ChildPageSharData m_shareObjData; // 共享数据
|
|
||||||
|
|
||||||
// 初始化数据
|
|
||||||
public void InitData(ChildPageSharData shareObjData)
|
|
||||||
{
|
|
||||||
m_shareObjData = shareObjData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void OnPageShowed(int oldShowType, int newShowType)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 无参数刷新当前子界面
|
|
||||||
// 收到那些数据变动的消息的时候使用
|
|
||||||
public virtual void RefreshPage()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ShareData1
|
|
||||||
{
|
|
||||||
get => m_shareObjData.Param1;
|
|
||||||
set => m_shareObjData.SetParam(0, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ShareData2
|
|
||||||
{
|
|
||||||
get => m_shareObjData.Param2;
|
|
||||||
set => m_shareObjData.SetParam(1, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ShareData3
|
|
||||||
{
|
|
||||||
get => m_shareObjData.Param3;
|
|
||||||
set => m_shareObjData.SetParam(2, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e4b742d9af72478b9d6f7ebd2fa493a0
|
|
||||||
timeCreated: 1687859782
|
|
@@ -1,457 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using TEngine;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
public class SwitchPageMgr
|
|
||||||
{
|
|
||||||
private event Action<int, int> SwitchTabAction;
|
|
||||||
|
|
||||||
public delegate bool SwitchTabCondition(int selectId);
|
|
||||||
|
|
||||||
private SwitchTabCondition _switchTabCondition;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 页签Grid。
|
|
||||||
/// </summary>
|
|
||||||
protected Transform m_tabGrid;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 子UI父节点。
|
|
||||||
/// </summary>
|
|
||||||
public Transform ChildPageParent;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 存储子UI。
|
|
||||||
/// </summary>
|
|
||||||
private readonly Dictionary<int, List<string>> _switchPageDic = new Dictionary<int, List<string>>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 子页签名字。
|
|
||||||
/// </summary>
|
|
||||||
private readonly List<string> _childPageNames = new List<string>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 子页签字典。
|
|
||||||
/// </summary>
|
|
||||||
private readonly Dictionary<string, ChildPageBase> _childPageDic = new Dictionary<string, ChildPageBase>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 存储页签。
|
|
||||||
/// </summary>
|
|
||||||
private readonly Dictionary<int, SwitchTabItem> _tabDic = new Dictionary<int, SwitchTabItem>();
|
|
||||||
|
|
||||||
private readonly Dictionary<int, string> _tabName = new Dictionary<int, string>();
|
|
||||||
|
|
||||||
protected readonly List<int> IDList = new List<int>();
|
|
||||||
|
|
||||||
private readonly UIBase _owner;
|
|
||||||
|
|
||||||
protected int CurrentChildID = -100;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 需要设置显示隐藏。
|
|
||||||
/// </summary>
|
|
||||||
private readonly bool _needSetActive;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 子界面的共享数据。
|
|
||||||
/// </summary>
|
|
||||||
private readonly ChildPageSharData _shareData = new ChildPageSharData();
|
|
||||||
|
|
||||||
public object ShareData1 => _shareData.Param1;
|
|
||||||
public object ShareData2 => _shareData.Param2;
|
|
||||||
public object ShareData3 => _shareData.Param3;
|
|
||||||
|
|
||||||
public SwitchPageMgr(Transform grid, Transform childPageParent, UIBase owner, bool needSetActive = true)
|
|
||||||
{
|
|
||||||
m_tabGrid = grid;
|
|
||||||
ChildPageParent = childPageParent;
|
|
||||||
_owner = owner;
|
|
||||||
_needSetActive = needSetActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddSwitchAction(Action<int, int> action)
|
|
||||||
{
|
|
||||||
SwitchTabAction += action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveSwitchAction(Action<int, int> action)
|
|
||||||
{
|
|
||||||
SwitchTabAction -= action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddSwitchCondition(SwitchTabCondition action)
|
|
||||||
{
|
|
||||||
_switchTabCondition = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindChildPage<T>(int childID) where T : ChildPageBase, new()
|
|
||||||
{
|
|
||||||
BindChildPage<T>(childID, string.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindChildPage<T>(int childID, string tabName) where T : ChildPageBase, new()
|
|
||||||
{
|
|
||||||
var pageName = typeof(T).Name;
|
|
||||||
|
|
||||||
if (IDList.IndexOf(childID) < 0)
|
|
||||||
{
|
|
||||||
IDList.Add(childID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_childPageDic.ContainsKey(pageName))
|
|
||||||
{
|
|
||||||
_childPageDic[pageName] = new T();
|
|
||||||
_childPageNames.Add(pageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_switchPageDic.ContainsKey(childID))
|
|
||||||
{
|
|
||||||
_switchPageDic[childID] = new List<string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_switchPageDic[childID].IndexOf(pageName) < 0)
|
|
||||||
{
|
|
||||||
_switchPageDic[childID].Add(pageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
_tabName[childID] = tabName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T CreatTab<T>(int initChildID, GameObject tabTemp = null) where T : SwitchTabItem, new()
|
|
||||||
{
|
|
||||||
T tab = null;
|
|
||||||
for (var index = 0; index < IDList.Count; index++)
|
|
||||||
{
|
|
||||||
var childID = IDList[index];
|
|
||||||
if (!_tabDic.ContainsKey(childID))
|
|
||||||
{
|
|
||||||
if (tabTemp != null)
|
|
||||||
{
|
|
||||||
tab = _owner.CreateWidgetByPrefab<T>(tabTemp, m_tabGrid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tab = _owner.CreateWidgetByType<T>(m_tabGrid);
|
|
||||||
}
|
|
||||||
|
|
||||||
tab.UpdateTabName(_tabName[childID]);
|
|
||||||
tab.BindClickEvent(TabOnClick, childID);
|
|
||||||
_tabDic[childID] = tab;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SwitchPage(initChildID);
|
|
||||||
return tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreatTabByItem<T>(int initChildID, GameObject go) where T : SwitchTabItem, new()
|
|
||||||
{
|
|
||||||
if (!_tabDic.ContainsKey(initChildID))
|
|
||||||
{
|
|
||||||
T tab = _owner.CreateWidgetByPrefab<T>(go, m_tabGrid);
|
|
||||||
tab.UpdateTabName(_tabName[initChildID]);
|
|
||||||
tab.BindClickEvent(TabOnClick, initChildID);
|
|
||||||
_tabDic[initChildID] = tab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置页签的自定义点击行为
|
|
||||||
public void SetCustomTabClickAction(int tabIdx, Action<SwitchTabItem> clickAction, object param1 = null,
|
|
||||||
object param2 = null, object param3 = null)
|
|
||||||
{
|
|
||||||
_tabDic[tabIdx].BindClickEvent(clickAction, param1, param2, param3);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int TabCount => _tabDic.Count;
|
|
||||||
|
|
||||||
public void SetTabRedNode(int tabId, bool isShow)
|
|
||||||
{
|
|
||||||
if (_tabDic.TryGetValue(tabId, out var value))
|
|
||||||
{
|
|
||||||
value.SetRedNote(isShow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetTabFontSize(int fontSize)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < IDList.Count; i++)
|
|
||||||
{
|
|
||||||
var tabId = IDList[i];
|
|
||||||
_tabDic[tabId].SetITabTextFontSize(fontSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TabOnClick(SwitchTabItem tab)
|
|
||||||
{
|
|
||||||
var childID = (int)tab.EventParam1;
|
|
||||||
SwitchPage(childID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void SwitchPage(int selectID)
|
|
||||||
{
|
|
||||||
if (_switchTabCondition != null && !_switchTabCondition(selectID))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CurrentChildID != selectID)
|
|
||||||
{
|
|
||||||
if (_switchPageDic.TryGetValue(selectID, out var pageLs))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < pageLs.Count; i++)
|
|
||||||
{
|
|
||||||
var pageName = pageLs[i];
|
|
||||||
ChildPageBase page = GetChildPageByName(pageName);
|
|
||||||
if (page != null && page.gameObject == null)
|
|
||||||
{
|
|
||||||
page.CreateByPath(pageName, _owner, ChildPageParent);
|
|
||||||
page.InitData(_shareData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < _childPageNames.Count; i++)
|
|
||||||
{
|
|
||||||
string pageName = _childPageNames[i];
|
|
||||||
ChildPageBase page = GetChildPageByName(pageName);
|
|
||||||
bool beShow = pageLs.IndexOf(pageName) >= 0;
|
|
||||||
if (page != null && page.gameObject != null)
|
|
||||||
{
|
|
||||||
if (_needSetActive)
|
|
||||||
{
|
|
||||||
//page.Show(beShow);
|
|
||||||
if (beShow)
|
|
||||||
{
|
|
||||||
page.gameObject.SetActive(true);
|
|
||||||
// page.Visible = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
page.gameObject.SetActive(false);
|
|
||||||
// page.Visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (page != null && beShow)
|
|
||||||
if (page != null)
|
|
||||||
{
|
|
||||||
page.OnPageShowed(CurrentChildID, selectID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var index = 0; index < IDList.Count; index++)
|
|
||||||
{
|
|
||||||
var childID = IDList[index];
|
|
||||||
SwitchTabItem tab;
|
|
||||||
if (_tabDic.TryGetValue(childID, out tab))
|
|
||||||
{
|
|
||||||
tab.SetState(selectID == childID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var oldID = CurrentChildID;
|
|
||||||
CurrentChildID = selectID;
|
|
||||||
if (SwitchTabAction != null)
|
|
||||||
{
|
|
||||||
SwitchTabAction(oldID, selectID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void ShowPage(int selectID)
|
|
||||||
{
|
|
||||||
if (_switchPageDic.TryGetValue(selectID, out var pageLs))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < pageLs.Count; i++)
|
|
||||||
{
|
|
||||||
var pageName = pageLs[i];
|
|
||||||
ChildPageBase page = GetChildPageByName(pageName);
|
|
||||||
if (page != null && page.gameObject == null)
|
|
||||||
{
|
|
||||||
page.CreateByPath(pageName, _owner, ChildPageParent);
|
|
||||||
page.InitData(_shareData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < _childPageNames.Count; i++)
|
|
||||||
{
|
|
||||||
string pageName = _childPageNames[i];
|
|
||||||
ChildPageBase page = GetChildPageByName(pageName);
|
|
||||||
bool beShow = pageLs.IndexOf(pageName) >= 0;
|
|
||||||
if (page != null && page.gameObject != null)
|
|
||||||
{
|
|
||||||
if (beShow)
|
|
||||||
{
|
|
||||||
page.gameObject.SetActive(true);
|
|
||||||
// page.Visible = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
page.gameObject.SetActive(false);
|
|
||||||
// page.Visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var index = 0; index < IDList.Count; index++)
|
|
||||||
{
|
|
||||||
var childID = IDList[index];
|
|
||||||
SwitchTabItem tab;
|
|
||||||
if (_tabDic.TryGetValue(childID, out tab))
|
|
||||||
{
|
|
||||||
tab.SetState(selectID == childID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RefreshCurrentChildPage()
|
|
||||||
{
|
|
||||||
if (_switchPageDic.TryGetValue(CurrentChildID, out var pageNames))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < pageNames.Count; i++)
|
|
||||||
{
|
|
||||||
ChildPageBase page = GetChildPageByName(pageNames[i]);
|
|
||||||
if (page != null && page.gameObject != null)
|
|
||||||
{
|
|
||||||
page.RefreshPage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RefreshChildPage(int childID)
|
|
||||||
{
|
|
||||||
if (_switchPageDic.TryGetValue(childID, out var pageNames))
|
|
||||||
{
|
|
||||||
for (int i = 0; i < pageNames.Count; i++)
|
|
||||||
{
|
|
||||||
ChildPageBase page = GetChildPageByName(pageNames[i]);
|
|
||||||
if (page != null && page.gameObject != null)
|
|
||||||
{
|
|
||||||
page.RefreshPage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TryGetChildPage<T>(out T t) where T : ChildPageBase
|
|
||||||
{
|
|
||||||
t = GetChildPage<T>();
|
|
||||||
return t != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetCurShowType()
|
|
||||||
{
|
|
||||||
return CurrentChildID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReductionShowType()
|
|
||||||
{
|
|
||||||
CurrentChildID = -100;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 没有ChildPage,可通过m_switchTabAction来处理切页事件(也可以光展示用)
|
|
||||||
|
|
||||||
public SwitchTabItem GetTabItem(int childId)
|
|
||||||
{
|
|
||||||
_tabDic.TryGetValue(childId, out var item);
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateJumpTab<T>(int initChildID, string tabName, GameObject tabTemp = null)
|
|
||||||
where T : SwitchTabItem, new()
|
|
||||||
{
|
|
||||||
if (IDList.IndexOf(initChildID) < 0)
|
|
||||||
{
|
|
||||||
IDList.Add(initChildID);
|
|
||||||
}
|
|
||||||
|
|
||||||
_tabName[initChildID] = tabName;
|
|
||||||
|
|
||||||
for (var index = 0; index < IDList.Count; index++)
|
|
||||||
{
|
|
||||||
var childID = IDList[index];
|
|
||||||
if (!_tabDic.ContainsKey(childID))
|
|
||||||
{
|
|
||||||
T tab;
|
|
||||||
if (tabTemp != null)
|
|
||||||
{
|
|
||||||
tab = _owner.CreateWidgetByPrefab<T>(tabTemp, m_tabGrid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tab = _owner.CreateWidgetByType<T>(m_tabGrid);
|
|
||||||
}
|
|
||||||
|
|
||||||
tab.UpdateTabName(_tabName[childID]);
|
|
||||||
tab.BindClickEvent(TabOnClick, childID);
|
|
||||||
_tabDic[childID] = tab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SwitchPage(initChildID);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置共享参数。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="paramIdx"></param>
|
|
||||||
/// <param name="param"></param>
|
|
||||||
public void SetShareParam(int paramIdx, object param)
|
|
||||||
{
|
|
||||||
_shareData.SetParam(paramIdx, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T GetChildPage<T>() where T : ChildPageBase
|
|
||||||
{
|
|
||||||
var pageName = typeof(T).Name;
|
|
||||||
_childPageDic.TryGetValue(pageName, out var page);
|
|
||||||
return page as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChildPageBase GetChildPageByName(string pageName)
|
|
||||||
{
|
|
||||||
_childPageDic.TryGetValue(pageName, out var page);
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindChildPage<T, U>(int childID, string tabName)
|
|
||||||
where T : ChildPageBase, new()
|
|
||||||
where U : ChildPageBase, new()
|
|
||||||
{
|
|
||||||
BindChildPage<T>(childID, tabName);
|
|
||||||
BindChildPage<U>(childID, tabName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindChildPage<T, U, V>(int childID, string tabName)
|
|
||||||
where T : ChildPageBase, new()
|
|
||||||
where U : ChildPageBase, new()
|
|
||||||
where V : ChildPageBase, new()
|
|
||||||
{
|
|
||||||
BindChildPage<T>(childID, tabName);
|
|
||||||
BindChildPage<U>(childID, tabName);
|
|
||||||
BindChildPage<V>(childID, tabName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindChildPage<T, U, V, W>(int childID, string tabName)
|
|
||||||
where T : ChildPageBase, new()
|
|
||||||
where U : ChildPageBase, new()
|
|
||||||
where V : ChildPageBase, new()
|
|
||||||
where W : ChildPageBase, new()
|
|
||||||
{
|
|
||||||
BindChildPage<T>(childID, tabName);
|
|
||||||
BindChildPage<U>(childID, tabName);
|
|
||||||
BindChildPage<V>(childID, tabName);
|
|
||||||
BindChildPage<W>(childID, tabName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e04155ae1ce3448587a5e322477d0076
|
|
||||||
timeCreated: 1687859725
|
|
@@ -1,263 +0,0 @@
|
|||||||
using System;
|
|
||||||
using TMPro;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
public class SwitchTabItem : UIEventItem<SwitchTabItem>
|
|
||||||
{
|
|
||||||
//选中时的文本
|
|
||||||
protected TextMeshProUGUI m_selectText;
|
|
||||||
//未选中时的文本
|
|
||||||
protected TextMeshProUGUI m_noSelectText;
|
|
||||||
//选中时的图片
|
|
||||||
protected Image m_selectImage;
|
|
||||||
//未选中时的图片
|
|
||||||
protected Image m_noSelectImage;
|
|
||||||
//选中时的节点
|
|
||||||
protected Transform m_selectNode;
|
|
||||||
//未选中时的节点
|
|
||||||
protected Transform m_noSelectNode;
|
|
||||||
|
|
||||||
//选中时的Icon
|
|
||||||
protected Image m_selectIcon;
|
|
||||||
//未选中时的Icon
|
|
||||||
protected Image m_noSelectIcon;
|
|
||||||
|
|
||||||
protected GameObject m_goRedNote;
|
|
||||||
|
|
||||||
//是否选中
|
|
||||||
public bool IsSelect
|
|
||||||
{
|
|
||||||
get { return m_isSelect; }
|
|
||||||
set { SetState(value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
protected bool m_isSelect = false;
|
|
||||||
|
|
||||||
//private RedNoteBehaviour m_redNote;
|
|
||||||
public RedNoteWidget m_redNote { get; private set; }
|
|
||||||
|
|
||||||
public virtual Vector2 SelectRedPointPos
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Vector2.zero;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual Vector2 NoSelectRedPointPos
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return Vector2.zero;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void BindMemberProperty()
|
|
||||||
{
|
|
||||||
m_selectNode = FindChild("SelectNode");
|
|
||||||
m_noSelectNode = FindChild("NoSelectNode");
|
|
||||||
if (m_selectNode != null)
|
|
||||||
{
|
|
||||||
m_selectText = FindChildComponent<TextMeshProUGUI>(m_selectNode, "SelectText");
|
|
||||||
m_selectImage = FindChildComponent<Image>(m_selectNode, "SelectImage");
|
|
||||||
m_selectIcon = FindChildComponent<Image>(m_selectNode, "SelectIcon");
|
|
||||||
}
|
|
||||||
if (m_noSelectNode != null)
|
|
||||||
{
|
|
||||||
m_noSelectText = FindChildComponent<TextMeshProUGUI>(m_noSelectNode, "NoSelectText");
|
|
||||||
m_noSelectImage = FindChildComponent<Image>(m_noSelectNode, "NoSelectImage");
|
|
||||||
m_noSelectIcon = FindChildComponent<Image>(m_noSelectNode, "NoSelectIcon");
|
|
||||||
}
|
|
||||||
|
|
||||||
var tf = FindChild("m_goRedNote");
|
|
||||||
if (tf != null)
|
|
||||||
{
|
|
||||||
m_goRedNote = tf.gameObject;
|
|
||||||
m_redNote = CreateWidgetByType<RedNoteWidget>(tf);
|
|
||||||
m_redNote.rectTransform.anchoredPosition = Vector2.zero;
|
|
||||||
SetRedNote(false);
|
|
||||||
//CreateDefaultRedNote();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 红点相关
|
|
||||||
public void SetRedNoteType(RedNoteNotify type)
|
|
||||||
{
|
|
||||||
if (m_redNote != null)
|
|
||||||
{
|
|
||||||
m_redNote.m_redNote.SetNotifyType(type);
|
|
||||||
}
|
|
||||||
SetRedNote(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRedNoteType(RedNoteNotify type, ulong param1)
|
|
||||||
{
|
|
||||||
if (m_redNote != null)
|
|
||||||
{
|
|
||||||
m_redNote.m_redNote.SetNotifyType(type, param1);
|
|
||||||
}
|
|
||||||
SetRedNote(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRedNoteType(RedNoteNotify type, ulong param1, ulong param2)
|
|
||||||
{
|
|
||||||
if (m_redNote != null)
|
|
||||||
{
|
|
||||||
m_redNote.m_redNote.SetNotifyType(type, param1, param2);
|
|
||||||
}
|
|
||||||
SetRedNote(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRedNoteType(RedNoteNotify type, ulong param1, ulong param2, ulong param3)
|
|
||||||
{
|
|
||||||
if (m_redNote != null)
|
|
||||||
{
|
|
||||||
m_redNote.m_redNote.SetNotifyType(type, param1, param2, param3);
|
|
||||||
}
|
|
||||||
SetRedNote(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRedNoteState(bool state)
|
|
||||||
{
|
|
||||||
if (m_redNote != null)
|
|
||||||
{
|
|
||||||
m_redNote.m_redNote.SetRedNoteState(state);
|
|
||||||
}
|
|
||||||
SetRedNote(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void UpdateTabName(string tabName)
|
|
||||||
{
|
|
||||||
if (m_selectText != null)
|
|
||||||
{
|
|
||||||
m_selectText.text = tabName;
|
|
||||||
m_selectText.rectTransform.sizeDelta = new Vector2(m_selectText.preferredWidth, m_selectText.rectTransform.sizeDelta.y);
|
|
||||||
}
|
|
||||||
if (m_noSelectText != null)
|
|
||||||
{
|
|
||||||
m_noSelectText.text = tabName;
|
|
||||||
m_noSelectText.rectTransform.sizeDelta = new Vector2(m_noSelectText.preferredWidth, m_noSelectText
|
|
||||||
.rectTransform.sizeDelta.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void UpdateTabImage(string selectImageName,string noSelectImageName)
|
|
||||||
// {
|
|
||||||
// if (m_selectImage != null)
|
|
||||||
// {
|
|
||||||
// UISpriteHelper.Instance.SetSprite(m_selectImage, selectImageName);
|
|
||||||
// }
|
|
||||||
// if (m_noSelectImage != null)
|
|
||||||
// {
|
|
||||||
// UISpriteHelper.Instance.SetSprite(m_noSelectImage, noSelectImageName);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void UpdateIcon(string selectIconName, string noSelectIconName)
|
|
||||||
// {
|
|
||||||
// if (m_selectIcon != null)
|
|
||||||
// {
|
|
||||||
// DUISpriteHelper.Instance.SetSprite(m_selectIcon, selectIconName, true);
|
|
||||||
// }
|
|
||||||
// if (m_noSelectIcon != null)
|
|
||||||
// {
|
|
||||||
// DUISpriteHelper.Instance.SetSprite(m_noSelectIcon, noSelectIconName, true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public virtual void CreateDefaultRedNote()
|
|
||||||
// {
|
|
||||||
// if (m_goRedNote != null)
|
|
||||||
// {
|
|
||||||
// UIEffectHelper.CreateUIEffectGoById((uint)CommonEffectID.EffectRedPoint, m_goRedNote.transform);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void SetRedNote(bool show)
|
|
||||||
{
|
|
||||||
if (m_goRedNote != null)
|
|
||||||
{
|
|
||||||
m_goRedNote.SetActive(show);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void SetState(bool select)
|
|
||||||
{
|
|
||||||
m_isSelect = select;
|
|
||||||
if (m_selectNode != null)
|
|
||||||
{
|
|
||||||
m_selectNode.gameObject.SetActive(select);
|
|
||||||
}
|
|
||||||
if (m_noSelectNode != null)
|
|
||||||
{
|
|
||||||
m_noSelectNode.gameObject.SetActive(!select);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_goRedNote != null)
|
|
||||||
{
|
|
||||||
if (select)
|
|
||||||
{
|
|
||||||
if (SelectRedPointPos != Vector2.zero)
|
|
||||||
{
|
|
||||||
((RectTransform)m_goRedNote.transform).anchoredPosition = SelectRedPointPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (NoSelectRedPointPos != Vector2.zero)
|
|
||||||
{
|
|
||||||
((RectTransform)m_goRedNote.transform).anchoredPosition = NoSelectRedPointPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetITabTextFontSize(int fontSize)
|
|
||||||
{
|
|
||||||
if (m_selectText != null)
|
|
||||||
{
|
|
||||||
m_selectText.fontSize = fontSize;
|
|
||||||
}
|
|
||||||
if (m_noSelectText != null)
|
|
||||||
{
|
|
||||||
m_noSelectText.fontSize = fontSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region UI-ID
|
|
||||||
/// <summary>
|
|
||||||
/// UI-ID
|
|
||||||
/// </summary>
|
|
||||||
public uint uiID;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// UI标识
|
|
||||||
/// </summary>
|
|
||||||
protected string m_uiFlag;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检查方法
|
|
||||||
/// </summary>
|
|
||||||
protected Func<bool> m_funcCheck;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 页签索引
|
|
||||||
/// </summary>
|
|
||||||
public int tabIndex = -1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// UI标识
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public virtual string GetUiFlag()
|
|
||||||
{
|
|
||||||
return string.IsNullOrEmpty(m_uiFlag) ? uiID.ToString() : m_uiFlag;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 498417b8785d47249da952f77d069c33
|
|
||||||
timeCreated: 1687667780
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b50cf85b0f0d4e43b12cb694f6c07979
|
|
||||||
timeCreated: 1695289335
|
|
@@ -1,18 +0,0 @@
|
|||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
public class EmptyGraph : Graphic
|
|
||||||
{
|
|
||||||
public bool m_debug = false;
|
|
||||||
|
|
||||||
protected override void OnPopulateMesh(VertexHelper vbo)
|
|
||||||
{
|
|
||||||
vbo.Clear();
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
if (m_debug)
|
|
||||||
{
|
|
||||||
base.OnPopulateMesh(vbo);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 21df3dfa358b498e8da3d169d736df58
|
|
||||||
timeCreated: 1695289370
|
|
@@ -1,138 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
[AddComponentMenu("UI/TScrollRect Rect", 37)]
|
|
||||||
[SelectionBase]
|
|
||||||
[ExecuteAlways]
|
|
||||||
[DisallowMultipleComponent]
|
|
||||||
[RequireComponent(typeof (RectTransform))]
|
|
||||||
public class TScrollRect : ScrollRect
|
|
||||||
{
|
|
||||||
private event Action ActionBeginDrag;
|
|
||||||
private event Action ActionOnDrag;
|
|
||||||
private event Action ActionEndDrag;
|
|
||||||
|
|
||||||
public List<ScrollRect> parentScrollRectList;
|
|
||||||
|
|
||||||
protected override void Awake()
|
|
||||||
{
|
|
||||||
base.Awake();
|
|
||||||
if (parentScrollRectList != null && parentScrollRectList.Count > 0)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < parentScrollRectList.Count; i++)
|
|
||||||
{
|
|
||||||
AddParentScrollRect(parentScrollRectList[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ScrollRect> m_listParentScrollRect;
|
|
||||||
|
|
||||||
public void AddParentScrollRect(ScrollRect parentScrollRect)
|
|
||||||
{
|
|
||||||
if (parentScrollRect == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_listParentScrollRect == null)
|
|
||||||
{
|
|
||||||
m_listParentScrollRect = new List<ScrollRect>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_listParentScrollRect.Contains(parentScrollRect))
|
|
||||||
{
|
|
||||||
m_listParentScrollRect.Add(parentScrollRect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddBeginDragListener(Action action)
|
|
||||||
{
|
|
||||||
ActionBeginDrag += action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveBeginDragListener(Action action)
|
|
||||||
{
|
|
||||||
ActionBeginDrag -= action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddOnDragListener(Action action)
|
|
||||||
{
|
|
||||||
ActionOnDrag += action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveOnDragListener(Action action)
|
|
||||||
{
|
|
||||||
ActionOnDrag -= action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddEndDragListener(Action action)
|
|
||||||
{
|
|
||||||
ActionEndDrag += action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveEndDragListener(Action action)
|
|
||||||
{
|
|
||||||
ActionEndDrag -= action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnBeginDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
base.OnBeginDrag(eventData);
|
|
||||||
if (ActionBeginDrag != null)
|
|
||||||
{
|
|
||||||
ActionBeginDrag();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_listParentScrollRect != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < m_listParentScrollRect.Count; i++)
|
|
||||||
{
|
|
||||||
var parentScrollRect = m_listParentScrollRect[i];
|
|
||||||
parentScrollRect.OnBeginDrag(eventData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
base.OnDrag(eventData);
|
|
||||||
if (ActionOnDrag != null)
|
|
||||||
{
|
|
||||||
ActionOnDrag();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_listParentScrollRect != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < m_listParentScrollRect.Count; i++)
|
|
||||||
{
|
|
||||||
var parentScrollRect = m_listParentScrollRect[i];
|
|
||||||
parentScrollRect.OnDrag(eventData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnEndDrag(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
base.OnEndDrag(eventData);
|
|
||||||
if (ActionEndDrag != null)
|
|
||||||
{
|
|
||||||
ActionEndDrag();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_listParentScrollRect != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < m_listParentScrollRect.Count; i++)
|
|
||||||
{
|
|
||||||
var parentScrollRect = m_listParentScrollRect[i];
|
|
||||||
parentScrollRect.OnEndDrag(eventData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d322e77e03014f65a9ec277d50bd12f8
|
|
||||||
timeCreated: 1695289370
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user