From 2e8717f5d9c5553ee278191286933ee22c12dfe8 Mon Sep 17 00:00:00 2001 From: soul Date: Tue, 1 Dec 2026 05:09:09 +0100 Subject: [PATCH] Inventory grid migration (one shot) and its output: Inventory.prefab and the HUD and enemy panels of ARPG.unity InventoryGridMigration.Run, exit 0, four scene panels logged (HUD, enemy, the two prefab instances) beside the prefab: a last child `Cells` holding an InventoryGrid (cell size, padding, orientation, IconTexel, BgTexel, raycastTarget from the prototype), GridLayoutGroup removed (a VerticalLayoutGroup beside the menu Content's ContentSizeFitter), panel.Grid and Interactive set, CargoBackgroundColor from the prototype, prototypes deactivated, an inactive Drag Ghost on the prefab. Deleted in the next commit; it stays in history. Co-Authored-By: Claude Sonnet 5.5 --- Assets/Prefabs/UI/Inventory.prefab | 237 ++++++++++++++-- Assets/Scenes/ARPG.unity | 259 +++++++++++++----- .../Scripts/Editor/InventoryGridMigration.cs | 141 ++++++++++ .../Editor/InventoryGridMigration.cs.meta | 2 + 4 files changed, 549 insertions(+), 90 deletions(-) create mode 100644 Assets/Scripts/Editor/InventoryGridMigration.cs create mode 100644 Assets/Scripts/Editor/InventoryGridMigration.cs.meta diff --git a/Assets/Prefabs/UI/Inventory.prefab b/Assets/Prefabs/UI/Inventory.prefab index dd6baefd6..77dcd608b 100644 --- a/Assets/Prefabs/UI/Inventory.prefab +++ b/Assets/Prefabs/UI/Inventory.prefab @@ -1384,8 +1384,8 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2279630453710142155} - - component: {fileID: 2279630453710142156} - component: {fileID: 2279630453710142157} + - component: {fileID: 1183808590500264648} m_Layer: 5 m_Name: Content m_TagString: Untagged @@ -1407,6 +1407,7 @@ RectTransform: m_Children: - {fileID: 5904147203112258852} - {fileID: 2279630454000268454} + - {fileID: 4656423476911625754} m_Father: {fileID: 2279630452951644481} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -1414,30 +1415,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &2279630453710142156 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2279630453710142154} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8a8695521f0d02e499659fee002a26c2, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Padding: - m_Left: 8 - m_Right: 8 - m_Top: 8 - m_Bottom: 8 - m_ChildAlignment: 4 - m_StartCorner: 2 - m_StartAxis: 0 - m_CellSize: {x: 32, y: 32} - m_Spacing: {x: 0, y: 0} - m_Constraint: 1 - m_ConstraintCount: 4 --- !u!114 &2279630453710142157 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1452,6 +1429,32 @@ MonoBehaviour: m_EditorClassIdentifier: m_HorizontalFit: 2 m_VerticalFit: 2 +--- !u!114 &1183808590500264648 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2279630453710142154} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.VerticalLayoutGroup + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 4 + m_Spacing: 0 + m_ChildForceExpandWidth: 0 + m_ChildForceExpandHeight: 0 + m_ChildControlWidth: 1 + m_ChildControlHeight: 1 + m_ChildScaleWidth: 0 + m_ChildScaleHeight: 0 + m_ReverseArrangement: 0 --- !u!1 &2279630453886260052 GameObject: m_ObjectHideFlags: 0 @@ -1486,6 +1489,7 @@ RectTransform: - {fileID: 6584545650613466935} - {fileID: 2279630452842594753} - {fileID: 4075091371340814903} + - {fileID: 3802566270667120158} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} @@ -1507,7 +1511,6 @@ MonoBehaviour: m_EditorClassIdentifier: Dialog: {fileID: 0} DragParent: {fileID: 0} - Flip: 0 Settings: {fileID: 0} GameManager: {fileID: 0} ContextMenu: {fileID: 0} @@ -1519,7 +1522,9 @@ MonoBehaviour: EditName: {fileID: 6472679976588045056} Current: {fileID: 3016612072679339612} Thermal: {fileID: 5512238094018694157} - Grid: {fileID: 2279630453710142156} + Grid: {fileID: 5716919501835380617} + Interactive: 1 + DragGhost: {fileID: 3983611517049603912} NodeBackgroundTextures: - {fileID: -7421115223572569992, guid: d826c67011a143148bb7f6129549ef38, type: 3} - {fileID: 2115398974705819552, guid: d826c67011a143148bb7f6129549ef38, type: 3} @@ -2324,10 +2329,10 @@ MonoBehaviour: ToggleEnabledColor: {r: 1, g: 0.44583336, b: 0.050000012, a: 1} ToggleDisabledColor: {r: 0.638, g: 0.638, b: 0.638, a: 1} CellBackgroundColor: {r: 0, g: 0, b: 0, a: 0.9019608} + CargoBackgroundColor: {r: 0, g: 0, b: 0, a: 0.8509804} MinTempRange: 1 DoubleClickTime: 0.5 HitDamageThreshold: 1 - EmptyCells: [] --- !u!222 &6932930312706461541 CanvasRenderer: m_ObjectHideFlags: 0 @@ -2383,7 +2388,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &2279630454000268454 RectTransform: m_ObjectHideFlags: 0 @@ -2910,6 +2915,93 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 +--- !u!1 &4673406189861854462 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4656423476911625754} + - component: {fileID: 6623574649663699363} + - component: {fileID: 5716919501835380617} + m_Layer: 5 + m_Name: Cells + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4656423476911625754 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4673406189861854462} + 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: 2279630453710142155} + 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!222 &6623574649663699363 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4673406189861854462} + m_CullTransparentMesh: 1 +--- !u!114 &5716919501835380617 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4673406189861854462} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3b9e6d41c7a24f08b15d2e9a60c4f7a1, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::InventoryGrid + 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: [] + Shader: {fileID: 4800000, guid: 7d1f3c0a5b2e4f6a9c8d0e1f2a3b4c5d, type: 3} + RuleInset: 1.5 + RuleWidth: 1 + ArmTexels: 1 + FillInset: 3 + Softness: 1 + RuleAlpha: 0.2 + BracketAlpha: 1 + FillAlpha: 0.050980393 + BlobRadius: 0.1272 + PipeHalfWidth: 0.1261 + Fillet: 0.1172 + PipeSoft: 1.212 + IconTexel: 1.5151515 + BgTexel: 1 + _cellSize: 32 + _padding: + m_Left: 8 + m_Right: 8 + m_Top: 8 + m_Bottom: 8 + _orientation: 0 --- !u!1 &5451249918807071883 GameObject: m_ObjectHideFlags: 0 @@ -3222,6 +3314,93 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: [] +--- !u!1 &5970608462419707546 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3802566270667120158} + - component: {fileID: 6435412584211243779} + - component: {fileID: 3983611517049603912} + m_Layer: 5 + m_Name: Drag Ghost + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &3802566270667120158 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5970608462419707546} + 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: 2279630453886260053} + 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: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &6435412584211243779 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5970608462419707546} + m_CullTransparentMesh: 1 +--- !u!114 &3983611517049603912 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5970608462419707546} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3b9e6d41c7a24f08b15d2e9a60c4f7a1, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::InventoryGrid + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0.5} + m_RaycastTarget: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + Shader: {fileID: 4800000, guid: 7d1f3c0a5b2e4f6a9c8d0e1f2a3b4c5d, type: 3} + RuleInset: 1.5 + RuleWidth: 1 + ArmTexels: 1 + FillInset: 3 + Softness: 1 + RuleAlpha: 0.2 + BracketAlpha: 1 + FillAlpha: 0.050980393 + BlobRadius: 0.1272 + PipeHalfWidth: 0.1261 + Fillet: 0.1172 + PipeSoft: 1.212 + IconTexel: 1.5151515 + BgTexel: 1 + _cellSize: 32 + _padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + _orientation: 0 --- !u!1 &7041853550605465833 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity index f583a38ec..c97ecdf5b 100644 --- a/Assets/Scenes/ARPG.unity +++ b/Assets/Scenes/ARPG.unity @@ -4583,6 +4583,7 @@ MonoBehaviour: Transform: {fileID: 332734006} Fill: {fileID: 965868421} Place: {fileID: 332734007} + Label: {fileID: 0} --- !u!114 &332734009 MonoBehaviour: m_ObjectHideFlags: 0 @@ -5921,7 +5922,6 @@ MonoBehaviour: m_EditorClassIdentifier: Dialog: {fileID: 0} DragParent: {fileID: 0} - Flip: 1 Settings: {fileID: 11400000, guid: cd2344e2001a37544aab0960c164d4ff, type: 2} GameManager: {fileID: 1009503729} ContextMenu: {fileID: 1157981993} @@ -5933,7 +5933,9 @@ MonoBehaviour: EditName: {fileID: 0} Current: {fileID: 0} Thermal: {fileID: 0} - Grid: {fileID: 1359207440} + Grid: {fileID: 1567254556} + Interactive: 0 + DragGhost: {fileID: 0} NodeBackgroundTextures: - {fileID: -7421115223572569992, guid: d826c67011a143148bb7f6129549ef38, type: 3} - {fileID: 2115398974705819552, guid: d826c67011a143148bb7f6129549ef38, type: 3} @@ -6722,10 +6724,10 @@ MonoBehaviour: ToggleEnabledColor: {r: 0, g: 0, b: 0, a: 0} ToggleDisabledColor: {r: 0, g: 0, b: 0, a: 0} CellBackgroundColor: {r: 0, g: 0, b: 0, a: 0.9490196} + CargoBackgroundColor: {r: 0, g: 0, b: 0, a: 0.8509804} MinTempRange: 0 DoubleClickTime: 0.5 HitDamageThreshold: 1 - EmptyCells: [] --- !u!1 &415301830 GameObject: m_ObjectHideFlags: 0 @@ -16231,6 +16233,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Settings: {fileID: 11400000, guid: cd2344e2001a37544aab0960c164d4ff, type: 2} + OwnSignatureFullScale: 10 DeathPostTransitionTime: 1 DeathPost: {fileID: 803284856} HeatstrokePost: {fileID: 1404901906} @@ -16247,7 +16250,6 @@ MonoBehaviour: ZoneRenderer: {fileID: 1009503731} DockCamera: {fileID: 393266593} FollowCamera: {fileID: 887677622} - WormholeCamera: {fileID: 1644480539} SectorMap: {fileID: 2132980328} MainMenu: {fileID: 588628536} Menu: {fileID: 1726632268} @@ -16266,6 +16268,8 @@ MonoBehaviour: ViewDot: {fileID: 146394778} LockIndicator: {fileID: 1876420642} IncomingLockIndicatorDistance: 30 + BearingMarkerDistance: 40 + SearchFlashSeconds: 0.6 Crosshairs: - {fileID: 1914685583} - {fileID: 1284802339} @@ -16287,6 +16291,7 @@ MonoBehaviour: NoShieldColor: {r: 0.6, g: 0.6, b: 0.6, a: 1} ShieldIcon: {fileID: 21300000, guid: 2a61aee34fcf7e640a093cb4c4fa56bc, type: 3} NoShieldIcon: {fileID: 21300000, guid: bc1017eafc2627f4aaa4e247f14347fd, type: 3} + KeyboardTurnRampTime: 0.4 --- !u!4 &1009503730 Transform: m_ObjectHideFlags: 0 @@ -20926,7 +20931,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1359207439} - - component: {fileID: 1359207440} m_Layer: 5 m_Name: Schematic m_TagString: Untagged @@ -20947,6 +20951,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1889622743} + - {fileID: 1567254555} m_Father: {fileID: 410701128} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -20954,30 +20959,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1359207440 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1359207438} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8a8695521f0d02e499659fee002a26c2, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Padding: - m_Left: 8 - m_Right: 8 - m_Top: 8 - m_Bottom: 8 - m_ChildAlignment: 4 - m_StartCorner: 1 - m_StartAxis: 0 - m_CellSize: {x: 16, y: 16} - m_Spacing: {x: 0, y: 0} - m_Constraint: 1 - m_ConstraintCount: 4 --- !u!1 &1367229140 GameObject: m_ObjectHideFlags: 0 @@ -24453,6 +24434,93 @@ Transform: m_Children: [] m_Father: {fileID: 2132980329} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1567254554 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1567254555} + - component: {fileID: 1567254557} + - component: {fileID: 1567254556} + m_Layer: 5 + m_Name: Cells + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1567254555 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1567254554} + 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: 1359207439} + 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 &1567254556 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1567254554} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3b9e6d41c7a24f08b15d2e9a60c4f7a1, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::InventoryGrid + 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: [] + Shader: {fileID: 4800000, guid: 7d1f3c0a5b2e4f6a9c8d0e1f2a3b4c5d, type: 3} + RuleInset: 1.5 + RuleWidth: 1 + ArmTexels: 1 + FillInset: 3 + Softness: 1 + RuleAlpha: 0.2 + BracketAlpha: 1 + FillAlpha: 0.050980393 + BlobRadius: 0.1272 + PipeHalfWidth: 0.1261 + Fillet: 0.1172 + PipeSoft: 1.212 + IconTexel: 1.010101 + BgTexel: 1 + _cellSize: 16 + _padding: + m_Left: 8 + m_Right: 8 + m_Top: 8 + m_Bottom: 8 + _orientation: 1 +--- !u!222 &1567254557 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1567254554} + m_CullTransparentMesh: 1 --- !u!1 &1570686534 GameObject: m_ObjectHideFlags: 0 @@ -24703,7 +24771,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: "" + m_text: m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 53555f7a2d5e745428813f1b1118734f, type: 2} m_sharedMaterial: {fileID: -2804126062856497447, guid: 53555f7a2d5e745428813f1b1118734f, @@ -25726,6 +25794,93 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1669395624} m_CullTransparentMesh: 0 +--- !u!1 &1677276968 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1677276969} + - component: {fileID: 1677276971} + - component: {fileID: 1677276970} + m_Layer: 5 + m_Name: Cells + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1677276969 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1677276968} + 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: 7628189704016736659} + 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, y: 0.5} +--- !u!114 &1677276970 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1677276968} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3b9e6d41c7a24f08b15d2e9a60c4f7a1, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::InventoryGrid + 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: [] + Shader: {fileID: 4800000, guid: 7d1f3c0a5b2e4f6a9c8d0e1f2a3b4c5d, type: 3} + RuleInset: 1.5 + RuleWidth: 1 + ArmTexels: 1 + FillInset: 3 + Softness: 1 + RuleAlpha: 0.2 + BracketAlpha: 1 + FillAlpha: 0.050980393 + BlobRadius: 0.1272 + PipeHalfWidth: 0.1261 + Fillet: 0.1172 + PipeSoft: 1.212 + IconTexel: 1.010101 + BgTexel: 1 + _cellSize: 16 + _padding: + m_Left: 8 + m_Right: 8 + m_Top: 8 + m_Bottom: 8 + _orientation: 0 +--- !u!222 &1677276971 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1677276968} + m_CullTransparentMesh: 1 --- !u!1 &1691348881 GameObject: m_ObjectHideFlags: 0 @@ -27583,6 +27738,7 @@ MonoBehaviour: Transform: {fileID: 1787772780} Fill: {fileID: 582989122} Place: {fileID: 1787772781} + Label: {fileID: 0} --- !u!114 &1787772783 MonoBehaviour: m_ObjectHideFlags: 0 @@ -28545,7 +28701,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &1889622743 RectTransform: m_ObjectHideFlags: 0 @@ -30769,7 +30925,11 @@ MonoBehaviour: m_BeforeStackBundles: - assemblyQualifiedName: UnityEngine.Rendering.PostProcessing.DepthOfField, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - m_AfterStackBundles: [] + m_AfterStackBundles: + - assemblyQualifiedName: TacticalFade, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + - assemblyQualifiedName: WormholeWarp, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null --- !u!114 &2115559092 MonoBehaviour: m_ObjectHideFlags: 0 @@ -37222,7 +37382,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!224 &7628189703197605886 RectTransform: m_ObjectHideFlags: 0 @@ -37265,7 +37425,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 7628189704016736659} - - component: {fileID: 7628189704016736660} m_Layer: 5 m_Name: Schematic m_TagString: Untagged @@ -37289,6 +37448,7 @@ RectTransform: - {fileID: 7628189703197605886} - {fileID: 1576705657} - {fileID: 19222412} + - {fileID: 1677276969} m_Father: {fileID: 7628189704109037581} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -37296,30 +37456,6 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 254, y: 0} m_Pivot: {x: 0, y: 0.5} ---- !u!114 &7628189704016736660 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7628189704016736658} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8a8695521f0d02e499659fee002a26c2, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Padding: - m_Left: 8 - m_Right: 8 - m_Top: 8 - m_Bottom: 8 - m_ChildAlignment: 4 - m_StartCorner: 2 - m_StartAxis: 0 - m_CellSize: {x: 16, y: 16} - m_Spacing: {x: 0, y: 0} - m_Constraint: 1 - m_ConstraintCount: 4 --- !u!1 &7628189704109037580 GameObject: m_ObjectHideFlags: 0 @@ -37381,7 +37517,6 @@ MonoBehaviour: m_EditorClassIdentifier: Dialog: {fileID: 0} DragParent: {fileID: 0} - Flip: 0 Settings: {fileID: 11400000, guid: cd2344e2001a37544aab0960c164d4ff, type: 2} GameManager: {fileID: 1009503729} ContextMenu: {fileID: 1157981993} @@ -37393,7 +37528,9 @@ MonoBehaviour: EditName: {fileID: 0} Current: {fileID: 0} Thermal: {fileID: 0} - Grid: {fileID: 7628189704016736660} + Grid: {fileID: 1677276970} + Interactive: 0 + DragGhost: {fileID: 0} NodeBackgroundTextures: - {fileID: -7421115223572569992, guid: d826c67011a143148bb7f6129549ef38, type: 3} - {fileID: 2115398974705819552, guid: d826c67011a143148bb7f6129549ef38, type: 3} @@ -38182,10 +38319,10 @@ MonoBehaviour: ToggleEnabledColor: {r: 0, g: 0, b: 0, a: 0} ToggleDisabledColor: {r: 0, g: 0, b: 0, a: 0} CellBackgroundColor: {r: 0, g: 0, b: 0, a: 0.9490196} + CargoBackgroundColor: {r: 0, g: 0, b: 0, a: 0.8509804} MinTempRange: 0 DoubleClickTime: 0.5 HitDamageThreshold: 1 - EmptyCells: [] --- !u!114 &7628189704109037583 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Editor/InventoryGridMigration.cs b/Assets/Scripts/Editor/InventoryGridMigration.cs new file mode 100644 index 000000000..3d1dcfa7c --- /dev/null +++ b/Assets/Scripts/Editor/InventoryGridMigration.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.UI; + +// One shot (map IG-S, cut inventory-grid-switch): moves the inventory panels from a GridLayoutGroup over sprite cells to an InventoryGrid. +// +// Unity -batchmode -projectPath -executeMethod InventoryGridMigration.Run -logFile +// +// Over Inventory.prefab and the two scene panels of ARPG.unity (the HUD's and the enemy's; the scene's two instances of the prefab take it +// from the prefab). Per panel it reads the old GridLayoutGroup (on the object the cell prototype lives under: Prototype.Instantiate parents +// cells there) and the prototype's own values, adds a last child `Cells` holding the InventoryGrid, removes the group, deactivates the +// prototype, and on the prefab adds the drag ghost. Four scene panels are logged: the two scene objects and the two prefab instances. It logs every object it changed and exits 0, or 1 on any failure. Deleted in the next +// commit; it stays in history. +public static class InventoryGridMigration +{ + private const string PrefabPath = "Assets/Prefabs/UI/Inventory.prefab"; + private const string ScenePath = "Assets/Scenes/ARPG.unity"; + private const string ShaderPath = "Assets/Shaders/InventoryGrid.shader"; + private static int _panels; + + private static void Log(string line) => Debug.Log("[InventoryGridMigration] " + line); + + public static void Run() + { + try + { + var shader = AssetDatabase.LoadAssetAtPath(ShaderPath) ?? throw new InvalidOperationException("No " + ShaderPath); + + var root = PrefabUtility.LoadPrefabContents(PrefabPath); + try + { + Migrate(root.GetComponentInChildren(true), shader, true); + PrefabUtility.SaveAsPrefabAsset(root, PrefabPath); + } + finally { PrefabUtility.UnloadPrefabContents(root); } + + var scene = EditorSceneManager.OpenScene(ScenePath, OpenSceneMode.Single); + var canvas = scene.GetRootGameObjects().First(o => o.name == "Canvas"); + foreach (var path in new[] { "Gameplay/Hud Schematic/Inventory", "Gameplay/Enemy Inventory" }) + { + var panel = (canvas.transform.Find(path) ?? throw new InvalidOperationException("No " + path)).GetComponent(); + Migrate(panel, shader, false); + } + // The scene's two instances of the prefab take the grid from it; they are listed so the count is four. + foreach (var panel in canvas.GetComponentsInChildren(true).Where(p => PrefabUtility.IsPartOfPrefabInstance(p))) + { + if (!panel.Grid || !panel.DragGhost || !panel.Interactive) throw new InvalidOperationException($"Instance {panel.name} did not take the migration from the prefab."); + _panels++; + Log($"panel {_panels}: prefab instance {Path(panel.transform)} takes Grid {panel.Grid.name}, DragGhost {panel.DragGhost.name}, Interactive {panel.Interactive} from the prefab"); + } + EditorSceneManager.MarkSceneDirty(scene); + if (!EditorSceneManager.SaveScene(scene)) throw new InvalidOperationException("The scene did not save."); + Log($"done: {_panels} panels"); + if (_panels != 4) throw new InvalidOperationException($"Migrated {_panels} panels, want 4."); + EditorApplication.Exit(0); + } + catch (Exception exception) + { + Debug.LogException(exception); + EditorApplication.Exit(1); + } + } + + private static string Path(Transform transform) => string.Join("/", transform.GetComponentsInParent(true).Reverse().Select(t => t.name)); + + private static void Migrate(InventoryPanel panel, Shader shader, bool prefab) + { + var prototype = panel.NodePrototype.GetComponent() ?? throw new InvalidOperationException("No cell prototype on " + Path(panel.transform)); + var container = panel.NodePrototype.transform.parent; + var layout = container.GetComponent() ?? throw new InvalidOperationException("No GridLayoutGroup where the prototype lives: " + Path(container)); + var iconMultiplier = prototype.Icon.pixelsPerUnitMultiplier; + var backgroundMultiplier = prototype.Background.pixelsPerUnitMultiplier; + var orientation = layout.startCorner == GridLayoutGroup.Corner.UpperRight ? GridOrientation.UpperRight : GridOrientation.LowerLeft; + var interactive = prototype.PointerClickTrigger != null; + Log($"{(prefab ? "prefab panel" : $"panel {_panels + 1}")}: {Path(panel.transform)}: group on {Path(container)} cell {layout.cellSize} padding {layout.padding.left},{layout.padding.right},{layout.padding.top},{layout.padding.bottom} start corner {layout.startCorner}; prototype icon multiplier {iconMultiplier}, background multiplier {backgroundMultiplier}, raycastTarget {prototype.Background.raycastTarget}, click trigger {interactive}, background colour {prototype.Background.color}"); + + var cells = NewGrid("Cells", container, shader, iconMultiplier, backgroundMultiplier, prototype.Background.raycastTarget); + var rect = (RectTransform) cells.transform; + rect.anchorMin = Vector2.zero; + rect.anchorMax = Vector2.one; + rect.offsetMin = rect.offsetMax = Vector2.zero; + rect.pivot = ((RectTransform) container).pivot; + rect.SetAsLastSibling(); + var so = new SerializedObject(cells); + so.FindProperty("_cellSize").floatValue = layout.cellSize.x; + so.FindProperty("_orientation").enumValueIndex = (int) orientation; + var padding = so.FindProperty("_padding"); + padding.FindPropertyRelative("m_Left").intValue = layout.padding.left; + padding.FindPropertyRelative("m_Right").intValue = layout.padding.right; + padding.FindPropertyRelative("m_Top").intValue = layout.padding.top; + padding.FindPropertyRelative("m_Bottom").intValue = layout.padding.bottom; + so.ApplyModifiedPropertiesWithoutUndo(); + Log($" added {Path(rect)}: cell size {layout.cellSize.x}, padding {layout.padding.left}/{layout.padding.top}, orientation {orientation}, IconTexel {cells.IconTexel:F5}, BgTexel {cells.BgTexel:F5}"); + + UnityEngine.Object.DestroyImmediate(layout); + Log($" removed GridLayoutGroup from {Path(container)}"); + if (container.GetComponent()) + { + var vertical = container.gameObject.AddComponent(); + vertical.childAlignment = TextAnchor.MiddleCenter; + vertical.padding = new RectOffset(); + vertical.childControlWidth = vertical.childControlHeight = true; + vertical.childForceExpandWidth = vertical.childForceExpandHeight = false; + Log($" added VerticalLayoutGroup (middle centre, control child size, no force expand) to {Path(container)} beside its ContentSizeFitter"); + } + + panel.Grid = cells; + panel.Interactive = interactive; + panel.CargoBackgroundColor = prototype.Background.color; + panel.NodePrototype.gameObject.SetActive(false); + Log($" panel.Grid = {cells.name}, Interactive = {interactive}, CargoBackgroundColor = {panel.CargoBackgroundColor}; deactivated {Path(panel.NodePrototype.transform)}"); + + if (prefab) + { + var ghost = NewGrid("Drag Ghost", panel.transform, shader, iconMultiplier, backgroundMultiplier, false); + ghost.color = new Color(1, 1, 1, .5f); + ghost.gameObject.SetActive(false); + panel.DragGhost = ghost; + Log($" added inactive {Path(ghost.transform)} with the same look, raycastTarget off, colour (1,1,1,.5), as panel.DragGhost"); + } + EditorUtility.SetDirty(panel); + EditorUtility.SetDirty(cells); + if (!prefab) _panels++; + } + + private static InventoryGrid NewGrid(string name, Transform parent, Shader shader, float iconMultiplier, float backgroundMultiplier, bool raycastTarget) + { + var go = new GameObject(name, typeof(RectTransform), typeof(CanvasRenderer)) { layer = LayerMask.NameToLayer("UI") }; + go.transform.SetParent(parent, false); + var grid = go.AddComponent(); + grid.Shader = shader; + grid.IconTexel = InventoryGrid.TexelOf(66f, iconMultiplier); + grid.BgTexel = InventoryGrid.TexelOf(100f, backgroundMultiplier); + grid.raycastTarget = raycastTarget; + return grid; + } +} diff --git a/Assets/Scripts/Editor/InventoryGridMigration.cs.meta b/Assets/Scripts/Editor/InventoryGridMigration.cs.meta new file mode 100644 index 000000000..757f6db03 --- /dev/null +++ b/Assets/Scripts/Editor/InventoryGridMigration.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 212e5feafdf3bcd4aad99fc039e89ddc \ No newline at end of file