From 2393d3f2810b04f0d1e2e2846dfe182613571109 Mon Sep 17 00:00:00 2001 From: tangbin <11111111> Date: Fri, 22 Aug 2025 16:02:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E7=BC=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scenes/SampleScene.unity | 692 ++++++++++++++++++------ Assets/Scripts/Map/MapManager.Region.cs | 20 +- Assets/Scripts/UI/UICellInfo.cs | 17 +- Assets/Scripts/UI/UIMapPanel.cs | 189 ++++++- 4 files changed, 733 insertions(+), 185 deletions(-) diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index b722850..7bf7475 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -1297,6 +1297,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 41794797} m_CullTransparentMesh: 1 +--- !u!1 &66077950 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 66077953} + - component: {fileID: 66077952} + - component: {fileID: 66077951} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &66077951 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 66077950} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u8F93\u5165\u56FE\u7247\u5927\u5C0F\uFF081000\uFF09" +--- !u!222 &66077952 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 66077950} + m_CullTransparentMesh: 1 +--- !u!224 &66077953 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 66077950} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 226014274} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &75572015 GameObject: m_ObjectHideFlags: 0 @@ -1331,7 +1410,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -595, y: 3.4000244} + m_AnchoredPosition: {x: -595, y: -29.599976} m_SizeDelta: {x: 100, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &75572017 @@ -3020,6 +3099,139 @@ MonoBehaviour: m_ChildScaleWidth: 0 m_ChildScaleHeight: 0 m_ReverseArrangement: 0 +--- !u!1 &146404237 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 146404238} + - component: {fileID: 146404241} + - component: {fileID: 146404240} + - component: {fileID: 146404239} + m_Layer: 5 + m_Name: btnReName + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &146404238 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 146404237} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 243492792} + m_Father: {fileID: 801927797} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 42.6, y: 30.2} + m_SizeDelta: {x: 150, y: 40} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &146404239 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 146404237} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 146404240} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 801927800} + m_TargetAssemblyTypeName: UIMapPanel, Assembly-CSharp + m_MethodName: ReNamePicFormat + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &146404240 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 146404237} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &146404241 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 146404237} + m_CullTransparentMesh: 1 --- !u!1 &146441348 GameObject: m_ObjectHideFlags: 0 @@ -4110,6 +4322,152 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 223083443} m_CullTransparentMesh: 1 +--- !u!1 &226014270 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 226014274} + - component: {fileID: 226014273} + - component: {fileID: 226014272} + - component: {fileID: 226014271} + m_Layer: 5 + m_Name: imgMapWidth + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &226014271 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 226014270} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 226014272} + m_TextComponent: {fileID: 765495786} + m_Placeholder: {fileID: 66077951} + m_ContentType: 2 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 4 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 1 + m_CharacterLimit: 0 + m_OnSubmit: + m_PersistentCalls: + m_Calls: [] + m_OnDidEndEdit: + m_PersistentCalls: + m_Calls: [] + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: 1000 + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 + m_ShouldActivateOnSelect: 1 +--- !u!114 &226014272 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 226014270} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &226014273 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 226014270} + m_CullTransparentMesh: 1 +--- !u!224 &226014274 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 226014270} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 66077953} + - {fileID: 765495788} + m_Father: {fileID: 586896005} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -476.9, y: 39.3} + m_SizeDelta: {x: 100, y: 30} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &229065465 GameObject: m_ObjectHideFlags: 0 @@ -4445,6 +4803,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 236057322} m_CullTransparentMesh: 1 +--- !u!1 &243492791 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 243492792} + - component: {fileID: 243492794} + - component: {fileID: 243492793} + m_Layer: 5 + m_Name: Text (TMP) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &243492792 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 243492791} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 146404238} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &243492793 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 243492791} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 20 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u91CD\u547D\u540D\u56FE\u7247\u683C\u5F0F" +--- !u!222 &243492794 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 243492791} + m_CullTransparentMesh: 1 --- !u!1 &253257407 GameObject: m_ObjectHideFlags: 0 @@ -5488,7 +5925,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -373, y: 36.19995} + m_AnchoredPosition: {x: -586.2, y: 3.1999512} m_SizeDelta: {x: 100, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &284887506 @@ -9615,7 +10052,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -364, y: 1.4000244} + m_AnchoredPosition: {x: -364, y: -31.599976} m_SizeDelta: {x: 100, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &493765333 @@ -12137,10 +12574,10 @@ RectTransform: m_Children: - {fileID: 1896052475} - {fileID: 284887505} - - {fileID: 1636137587} - {fileID: 1615225087} - {fileID: 75572016} - {fileID: 1961181749} + - {fileID: 226014274} - {fileID: 493765332} - {fileID: 1291799213} - {fileID: 995221087} @@ -12183,7 +12620,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 59fe40e084ac9b645ad1567b57bea785, type: 3} m_Name: m_EditorClassIdentifier: - txtMapWidth: {fileID: 1839851984} + txtMapWidth: {fileID: 226014271} txtMapHeight: {fileID: 1635066442} txtTotalCells: {fileID: 492525887} txtMoveCells: {fileID: 135583406} @@ -14756,6 +15193,85 @@ MonoBehaviour: curActiveList: [] itemParent: {fileID: 23629425} btnAdd: {fileID: 2093000581} +--- !u!1 &765495785 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 765495788} + - component: {fileID: 765495787} + - component: {fileID: 765495786} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &765495786 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 765495785} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 1 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 1000 +--- !u!222 &765495787 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 765495785} + m_CullTransparentMesh: 1 +--- !u!224 &765495788 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 765495785} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 226014274} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &767193159 GameObject: m_ObjectHideFlags: 0 @@ -15901,6 +16417,7 @@ RectTransform: - {fileID: 779816121} - {fileID: 454030827} - {fileID: 992754507} + - {fileID: 146404238} - {fileID: 608171646} - {fileID: 1213416634} - {fileID: 82825349} @@ -24998,7 +25515,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -266, y: 1.4000244} + m_AnchoredPosition: {x: -266, y: -31.599976} m_SizeDelta: {x: 100, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1291799214 @@ -31353,7 +31870,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -267, y: 35.99997} + m_AnchoredPosition: {x: -491.4, y: 2.9999695} m_SizeDelta: {x: 70, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1615225088 @@ -31631,82 +32148,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} ---- !u!1 &1636137586 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1636137587} - - component: {fileID: 1636137589} - - component: {fileID: 1636137588} - m_Layer: 5 - m_Name: imgMapWidth - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1636137587 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1636137586} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0.0000014050165} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1839851983} - m_Father: {fileID: 586896005} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -487, y: 36.299973} - m_SizeDelta: {x: 70, y: 30} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1636137588 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1636137586} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.8537882, g: 0.9339623, b: 0.59474015, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!222 &1636137589 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1636137586} - m_CullTransparentMesh: 1 --- !u!1 &1636463581 GameObject: m_ObjectHideFlags: 0 @@ -34222,7 +34663,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -327.8, y: 26} + m_AnchoredPosition: {x: -327.2, y: 26.3} m_SizeDelta: {x: 110, y: 48} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1734532367 @@ -36265,85 +36706,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1831714160} m_CullTransparentMesh: 1 ---- !u!1 &1839851982 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1839851983} - - component: {fileID: 1839851985} - - component: {fileID: 1839851984} - m_Layer: 5 - m_Name: Text (Legacy) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1839851983 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1839851982} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1636137587} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1839851984 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1839851982} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 20 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 2 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: ---- !u!222 &1839851985 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1839851982} - m_CullTransparentMesh: 1 --- !u!1 &1839881634 GameObject: m_ObjectHideFlags: 0 @@ -37613,7 +37975,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -586, y: 36} + m_AnchoredPosition: {x: -586, y: 40.100098} m_SizeDelta: {x: 100, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1896052476 @@ -39052,7 +39414,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -485, y: 2.4000244} + m_AnchoredPosition: {x: -485, y: -30.599976} m_SizeDelta: {x: 100, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1961181750 diff --git a/Assets/Scripts/Map/MapManager.Region.cs b/Assets/Scripts/Map/MapManager.Region.cs index d2154f1..5e4b654 100644 --- a/Assets/Scripts/Map/MapManager.Region.cs +++ b/Assets/Scripts/Map/MapManager.Region.cs @@ -2,12 +2,13 @@ using Cysharp.Threading.Tasks; using HxGame.Data; using System.Collections; using System.Collections.Generic; -using System.Drawing.Imaging; using System.Drawing; +using System.Drawing.Imaging; using System.IO; +using System.Linq; +using System.Runtime.Remoting.Metadata.W3cXsd2001; using System.Threading; using UnityEngine; -using System.Linq; public partial class MapManager : MonoBehaviour { @@ -21,7 +22,7 @@ public partial class MapManager : MonoBehaviour public Transform mapTeleportArea; public Transform mapReliveArea; public Transform mapAudioTrigger; - public Dictionary allMaps = new Dictionary(); + public Dictionary allMaps = new Dictionary(); /// /// 当前地图区域 @@ -44,6 +45,11 @@ public partial class MapManager : MonoBehaviour public void SaveAtlasToFile() { + if (MapManager.Instance.map == null) + { + UIWindow.Instance.ShowMessage("请先打开地图"); + return; + } int atlasWidth = _curMapRegions.regionRowNum * (int)_curMapRegions.regionWidth; int atlasHeight = _curMapRegions.regionColNum * (int)_curMapRegions.regionHeight; if (atlasWidth < 8192) @@ -148,7 +154,11 @@ public partial class MapManager : MonoBehaviour } public void LoadMapRegionSprites(int mapId) { - if (!allMaps.TryGetValue(mapId.ToString(),out var mapInfo)) + OldRegionSprites(mapId); + } + public void OldRegionSprites(int mapId) + { + if (!allMaps.TryGetValue(mapId.ToString(), out var mapInfo)) { UIWindow.Instance.ShowMessage("地图不存在。。。"); return; @@ -186,7 +196,7 @@ public partial class MapManager : MonoBehaviour _curMapRegions.regions[row, col].indexY = col; multithreadLoadTextrue(spPath, sr, _curMapRegions.regions[row, col]); _curMapRegions.regions[row, col].regionName = filename; - } + } } MapManager.Instance.ReseCamera(jpgscenew * mapColumn, jpgscenew * mapRownum); } diff --git a/Assets/Scripts/UI/UICellInfo.cs b/Assets/Scripts/UI/UICellInfo.cs index 5a127df..36cc4c0 100644 --- a/Assets/Scripts/UI/UICellInfo.cs +++ b/Assets/Scripts/UI/UICellInfo.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Runtime.Remoting.Metadata.W3cXsd2001; using UnityEngine; using UnityEngine.UI; using UnityEngine.VFX; @@ -11,7 +12,7 @@ using static GridSelector; public class UICellInfo : MonoBehaviour { public static UICellInfo Instance; - public Text txtMapWidth; + public InputField txtMapWidth; public Text txtMapHeight; public Text txtTotalCells; public Text txtMoveCells; @@ -31,6 +32,7 @@ public class UICellInfo : MonoBehaviour { Cleanup(); } + public int CustomMapWidth => int.Parse(txtMapWidth.text); void Cleanup() { @@ -65,7 +67,7 @@ public class UICellInfo : MonoBehaviour { if (MapManager.Instance.map == null || MapManager.Instance.map.selector == null) return; - if(MapManager.Instance._curMapRegions == null) return; + if (MapManager.Instance._curMapRegions == null) return; txtMapWidth.text = MapManager.Instance._curMapRegions.regionRowNum.ToString(); txtMapHeight.text = MapManager.Instance._curMapRegions.regionColNum.ToString(); txtCellRows.text = MapManager.Instance.map.selector.horizontalNumber.ToString(); @@ -75,6 +77,17 @@ public class UICellInfo : MonoBehaviour txtCellHeight.text = MapManager.heightPixel.ToString(); txtMoveCells.text = MapManager.Instance.map.selector.moveNum.ToString(); } + + public void ShowMapWidthAndHeight(int mapId) + { + if (!MapManager.Instance.allMaps.TryGetValue(mapId.ToString(), out var mapInfo)) + { + UIWindow.Instance.ShowMessage("地图不存在。。。"); + return; + } + txtMapWidth.text = mapInfo.maxRow.ToString(); + txtMapHeight.text = mapInfo.maxCol.ToString(); + } /// /// 加载格子 /// diff --git a/Assets/Scripts/UI/UIMapPanel.cs b/Assets/Scripts/UI/UIMapPanel.cs index 7d4528d..27a136d 100644 --- a/Assets/Scripts/UI/UIMapPanel.cs +++ b/Assets/Scripts/UI/UIMapPanel.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Data.Common; using System.IO; +using System.Linq; using System.Text.RegularExpressions; using UnityEditor; using UnityEngine; @@ -19,8 +20,14 @@ public class UIMapPanel : MonoBehaviour void Start() { _saving = false; + dropMap.onValueChanged.AddListener(delegate { + if (dropMap.options.Count > 0) + { + int mapId = Convert.ToInt32(dropMap.options[dropMap.value].text); + UICellInfo.Instance.ShowMapWidthAndHeight(mapId); + } + }); } - void OnDataLoaded() { // 获取所有地图文件夹 @@ -30,7 +37,7 @@ public class UIMapPanel : MonoBehaviour Debug.LogError($"Maps directory not found: {mapsDirectory}"); return; } - + MapManager.Instance.allMaps.Clear(); string[] mapFolders = Directory.GetDirectories(mapsDirectory); foreach (string folderPath in mapFolders) { @@ -62,23 +69,179 @@ public class UIMapPanel : MonoBehaviour { Debug.LogWarning($"Filename {fileName} does not match expected pattern: {pattern}"); } - } - - if (maxRow > 0 && maxCol > 0) - { - MapManager.Instance.allMaps[mapId] = (maxCol, maxRow); - Debug.Log($"Map {mapId} loaded with max dimensions: {maxCol}x{maxRow}"); - } - else - { - Debug.LogWarning($"No valid dimensions found for map {mapId}"); - } + } + + MapManager.Instance.allMaps[mapId] = (maxCol, maxRow, imageFiles.Length); } else { Debug.LogWarning($"Texture directory not found for map {mapId}: {textureDirectory}"); } } + } + /// + /// 重命名图片格式从 map_x 到 v{mapId}_rx_cx 格式(包含重复检查) + /// + public void ReNamePicFormat() + { + int mapId = Convert.ToInt32(dropMap.options[dropMap.value].text); + int width = UICellInfo.Instance.CustomMapWidth; // 地图宽度(列数) + string mapsDirectory = Path.Combine(Application.dataPath, "GameAssets", "Maps", $"{mapId}", "Texture"); + + if (!Directory.Exists(mapsDirectory)) + { + Debug.LogError($"Maps directory not found: {mapsDirectory}"); + return; + } + + // 获取所有jpg文件 + string[] imageFiles = Directory.GetFiles(mapsDirectory, "*.jpg"); + int totalFiles = imageFiles.Length; + + if (totalFiles == 0) + { + UIWindow.Instance.ShowMessage($"No jpg files found in directory: {mapsDirectory}"); + return; + } + + // 检查是否已经是目标命名格式 + if (IsAlreadyRenamed(imageFiles, mapId)) + { + UIWindow.Instance.ShowMessage($"文件夹 {mapId} 已经是目标命名格式,跳过重命名"); + return; + } + + // 检查是否混合格式(部分已重命名,部分未重命名) + if (IsMixedFormat(imageFiles, mapId)) + { + UIWindow.Instance.ShowMessage($"文件夹 {mapId} 包含混合格式的文件,请先清理文件夹"); + return; + } + + // 按数字排序map_格式的文件 + var mapFiles = imageFiles + .Where(file => Path.GetFileNameWithoutExtension(file).StartsWith("map_")) + .OrderBy(file => + { + string fileName = Path.GetFileNameWithoutExtension(file); + if (int.TryParse(fileName.Substring(4), out int number)) + { + return number; + } + return int.MaxValue; + }) + .ToArray(); + + if (mapFiles.Length == 0) + { + UIWindow.Instance.ShowMessage($"没有找到map_格式的文件,但也不是目标格式"); + return; + } + + // 计算行数 + int height = Mathf.CeilToInt((float)mapFiles.Length / width); + UIWindow.Instance.ShowMessage($"Renaming {mapFiles.Length} files with grid size: {width}x{height}"); + + int renamedCount = 0; + int errorCount = 0; + + // 执行重命名操作 + for (int index = 0; index < mapFiles.Length; index++) + { + string oldFilePath = mapFiles[index]; + string fileName = Path.GetFileNameWithoutExtension(oldFilePath); + string fileExtension = Path.GetExtension(oldFilePath); + + try + { + // 计算行列位置(从1开始) + int row = (index / width) + 1; + int col = (index % width) + 1; + + // 生成新文件名(使用地图ID) + string newFileName = $"v{mapId}_r{row}_c{col}"; + string newFilePath = Path.Combine(mapsDirectory, newFileName + fileExtension); + + // 重命名文件 + File.Move(oldFilePath, newFilePath); + renamedCount++; + + Debug.Log($"Renamed: {fileName} -> {newFileName}"); + } + catch (Exception ex) + { + errorCount++; + Debug.LogError($"Error renaming file {fileName}: {ex.Message}"); + } + } + + Debug.Log($"Rename completed. Success: {renamedCount}, Errors: {errorCount}"); + + // 刷新AssetDatabase +#if UNITY_EDITOR + UnityEditor.AssetDatabase.Refresh(); +#endif + OnDataLoaded(); + } + + /// + /// 检查是否已经是目标命名格式 + /// + private bool IsAlreadyRenamed(string[] imageFiles, int mapId) + { + // 目标格式的正则表达式:v{mapId}_r数字_c数字 + string pattern = $"^v{mapId}_r\\d+_c\\d+$"; + var regex = new System.Text.RegularExpressions.Regex(pattern); + + foreach (string filePath in imageFiles) + { + string fileName = Path.GetFileNameWithoutExtension(filePath); + + // 如果发现任何非目标格式的文件,就不是已重命名状态 + if (!regex.IsMatch(fileName) && !fileName.StartsWith("map_")) + { + return false; + } + } + + // 检查是否至少有一个目标格式的文件 + bool hasTargetFormat = imageFiles.Any(file => + regex.IsMatch(Path.GetFileNameWithoutExtension(file))); + + return hasTargetFormat; + } + + /// + /// 检查是否混合格式(既有目标格式又有map_格式) + /// + private bool IsMixedFormat(string[] imageFiles, int mapId) + { + bool hasMapFormat = false; + bool hasTargetFormat = false; + string pattern = $"^v{mapId}_r\\d+_c\\d+$"; + var regex = new System.Text.RegularExpressions.Regex(pattern); + + foreach (string filePath in imageFiles) + { + string fileName = Path.GetFileNameWithoutExtension(filePath); + + if (fileName.StartsWith("map_")) + { + hasMapFormat = true; + } + else if (regex.IsMatch(fileName)) + { + hasTargetFormat = true; + } + + // 如果同时存在两种格式,就是混合状态 + if (hasMapFormat && hasTargetFormat) + { + return true; + } + } + + return false; } public void ExportMap() {