diff --git a/Assets/GWConquest/Prefabs/UI/ItemIcon.prefab b/Assets/GWConquest/Prefabs/UI/ItemIcon.prefab index cb83ced..57b639f 100644 --- a/Assets/GWConquest/Prefabs/UI/ItemIcon.prefab +++ b/Assets/GWConquest/Prefabs/UI/ItemIcon.prefab @@ -33,11 +33,11 @@ RectTransform: m_Father: {fileID: 6815987390155653560} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} m_AnchoredPosition: {x: 40, y: 0} m_SizeDelta: {x: 0, y: 35} - m_Pivot: {x: 0, y: 1} + m_Pivot: {x: 0, y: 0.5} --- !u!222 &6815987389502116017 CanvasRenderer: m_ObjectHideFlags: 0 @@ -106,8 +106,7 @@ GameObject: m_Component: - component: {fileID: 6815987390155653560} - component: {fileID: 6815987390155653558} - - component: {fileID: 5791924757031699370} - - component: {fileID: 244878247843148808} + - component: {fileID: 1138806303401438636} m_Layer: 5 m_Name: ItemIcon m_TagString: Untagged @@ -131,10 +130,10 @@ RectTransform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} m_AnchoredPosition: {x: 10, y: 0} - m_SizeDelta: {x: 0, y: 35} + m_SizeDelta: {x: 70, y: 52.5} m_Pivot: {x: 0, y: 0.5} --- !u!222 &6815987390155653558 CanvasRenderer: @@ -144,7 +143,7 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 6815987390155653563} m_CullTransparentMesh: 0 ---- !u!114 &5791924757031699370 +--- !u!114 &1138806303401438636 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -153,36 +152,12 @@ MonoBehaviour: m_GameObject: {fileID: 6815987390155653563} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3} + m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3} m_Name: m_EditorClassIdentifier: - m_Padding: - m_Left: 0 - m_Right: 0 - m_Top: 0 - m_Bottom: 0 - m_ChildAlignment: 0 - m_Spacing: 5 - m_ChildForceExpandWidth: 0 - m_ChildForceExpandHeight: 0 - m_ChildControlWidth: 0 - m_ChildControlHeight: 0 - m_ChildScaleWidth: 0 - m_ChildScaleHeight: 0 ---- !u!114 &244878247843148808 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6815987390155653563} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} - m_Name: - m_EditorClassIdentifier: - m_HorizontalFit: 2 - m_VerticalFit: 0 + Padding: 0 + Horizontal: 1 + Vertical: 0 --- !u!1 &6815987390313110547 GameObject: m_ObjectHideFlags: 0 @@ -215,8 +190,8 @@ RectTransform: m_Father: {fileID: 6815987390155653560} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 35, y: 35} m_Pivot: {x: 0, y: 0.5} diff --git a/Assets/GWConquest/Prefabs/UI/TransportUIElement.prefab b/Assets/GWConquest/Prefabs/UI/TransportUIElement.prefab index 763a4af..067ad7b 100644 --- a/Assets/GWConquest/Prefabs/UI/TransportUIElement.prefab +++ b/Assets/GWConquest/Prefabs/UI/TransportUIElement.prefab @@ -10,7 +10,7 @@ GameObject: m_Component: - component: {fileID: 2673194343061756521} - component: {fileID: 2673194343061756527} - - component: {fileID: 2673194343061756520} + - component: {fileID: 5407586027641697039} m_Layer: 5 m_Name: ItemIcons m_TagString: Untagged @@ -32,10 +32,10 @@ RectTransform: m_Father: {fileID: 2673194343769095890} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 455.90826, y: 0} - m_SizeDelta: {x: 911.8165, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!114 &2673194343061756527 MonoBehaviour: @@ -49,14 +49,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 048208b8918c3c74c821e2e69e3d613d, type: 3} m_Name: m_EditorClassIdentifier: - m_Padding: - m_Left: 10 - m_Right: 10 + padding: + m_Left: 0 + m_Right: 0 m_Top: 0 m_Bottom: 0 - m_ChildAlignment: 0 Spacing: {x: 15, y: 15} ---- !u!114 &2673194343061756520 +--- !u!114 &5407586027641697039 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -65,11 +64,12 @@ MonoBehaviour: m_GameObject: {fileID: 2673194343061756522} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} + m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3} m_Name: m_EditorClassIdentifier: - m_HorizontalFit: 0 - m_VerticalFit: 2 + Padding: 0 + Horizontal: 0 + Vertical: 1 --- !u!1 &2673194343256469681 GameObject: m_ObjectHideFlags: 0 @@ -134,7 +134,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: bd93e35d8eadb9844adef76ee7beacee, type: 3} + m_Sprite: {fileID: 0} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -221,7 +221,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: Agri District + m_Text: Group Name --- !u!1 &2673194343700811292 GameObject: m_ObjectHideFlags: 0 @@ -305,8 +305,8 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2673194343769095890} - - component: {fileID: 2673194343769095888} - - component: {fileID: 2673194343769095889} + - component: {fileID: 4672820892231590445} + - component: {fileID: 9046570603510387992} m_Layer: 5 m_Name: Children m_TagString: Untagged @@ -331,10 +331,10 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 39.197, y: -100} - m_SizeDelta: {x: -101.60681, y: 0} + m_AnchoredPosition: {x: 39.197, y: -70} + m_SizeDelta: {x: -101.60681, y: 35} m_Pivot: {x: 0.5, y: 1} ---- !u!114 &2673194343769095888 +--- !u!114 &4672820892231590445 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -343,23 +343,11 @@ MonoBehaviour: m_GameObject: {fileID: 2673194343769095891} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Script: {fileID: 11500000, guid: b0cffe833675a2942be0665d6d259496, type: 3} m_Name: m_EditorClassIdentifier: - m_Padding: - m_Left: 0 - m_Right: 0 - m_Top: 0 - m_Bottom: 0 - m_ChildAlignment: 0 - m_Spacing: 10 - m_ChildForceExpandWidth: 0 - m_ChildForceExpandHeight: 0 - m_ChildControlWidth: 0 - m_ChildControlHeight: 0 - m_ChildScaleWidth: 0 - m_ChildScaleHeight: 0 ---- !u!114 &2673194343769095889 + Spacing: 10 +--- !u!114 &9046570603510387992 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -368,11 +356,12 @@ MonoBehaviour: m_GameObject: {fileID: 2673194343769095891} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} + m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3} m_Name: m_EditorClassIdentifier: - m_HorizontalFit: 0 - m_VerticalFit: 2 + Padding: 0 + Horizontal: 0 + Vertical: 1 --- !u!1 &2673194344194583624 GameObject: m_ObjectHideFlags: 0 @@ -410,7 +399,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} m_AnchoredPosition: {x: 0, y: -10} - m_SizeDelta: {x: -20, y: 0} + m_SizeDelta: {x: -20, y: 145} m_Pivot: {x: 0.5, y: 1} --- !u!114 &2673194344194583630 MonoBehaviour: @@ -424,7 +413,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3} m_Name: m_EditorClassIdentifier: - Padding: 20 + Padding: 0 + Horizontal: 0 + Vertical: 1 --- !u!114 &8452816462676908967 MonoBehaviour: m_ObjectHideFlags: 0 @@ -642,6 +633,6 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -15} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: -20, y: 60} m_Pivot: {x: 0.5, y: 1} diff --git a/Assets/GWConquest/Scenes/GalaxyMap.unity b/Assets/GWConquest/Scenes/GalaxyMap.unity index 5254035..4e7eb5f 100644 --- a/Assets/GWConquest/Scenes/GalaxyMap.unity +++ b/Assets/GWConquest/Scenes/GalaxyMap.unity @@ -15239,7 +15239,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 62.661, y: -284.2} + m_AnchoredPosition: {x: 62.661, y: -170} m_SizeDelta: {x: -169.53058, y: 35} m_Pivot: {x: 0.5, y: 1} --- !u!114 &256267753 @@ -36699,7 +36699,7 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1658066164} m_HandleRect: {fileID: 1658066163} m_Direction: 2 - m_Value: 1 + m_Value: 0 m_Size: 1 m_NumberOfSteps: 0 m_OnValueChanged: @@ -54930,8 +54930,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.000061035156} - m_SizeDelta: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 205} m_Pivot: {x: 0, y: 1} --- !u!114 &936520234 MonoBehaviour: @@ -54942,11 +54942,12 @@ MonoBehaviour: m_GameObject: {fileID: 936520232} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} + m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3} m_Name: m_EditorClassIdentifier: - m_HorizontalFit: 0 - m_VerticalFit: 2 + Padding: 0 + Horizontal: 0 + Vertical: 1 --- !u!114 &936520235 MonoBehaviour: m_ObjectHideFlags: 0 @@ -54956,22 +54957,11 @@ MonoBehaviour: m_GameObject: {fileID: 936520232} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} + m_Script: {fileID: 11500000, guid: b0cffe833675a2942be0665d6d259496, type: 3} m_Name: m_EditorClassIdentifier: - m_Padding: - m_Left: 5 - m_Right: 5 - m_Top: 5 - m_Bottom: 5 - m_ChildAlignment: 0 - m_Spacing: 25 - m_ChildForceExpandWidth: 1 - m_ChildForceExpandHeight: 0 - m_ChildControlWidth: 1 - m_ChildControlHeight: 0 - m_ChildScaleWidth: 0 - m_ChildScaleHeight: 0 + Padding: 20 + Spacing: 20 --- !u!1 &939647887 GameObject: m_ObjectHideFlags: 0 @@ -69576,20 +69566,13 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 2673194344500550916} m_Modifications: - - target: {fileID: 6815987389502116018, guid: 06641392b6ebf5645b031c3f0700a917, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 40 - objectReference: {fileID: 0} - - target: {fileID: 6815987389502116018, guid: 06641392b6ebf5645b031c3f0700a917, + - target: {fileID: 6815987389502116016, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6815987389502116018, guid: 06641392b6ebf5645b031c3f0700a917, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 + propertyPath: m_Text + value: '300 + + +' objectReference: {fileID: 0} - target: {fileID: 6815987389502116018, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} @@ -69654,17 +69637,17 @@ PrefabInstance: - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} propertyPath: m_AnchoredPosition.x - value: 10 + value: 0 objectReference: {fileID: 0} - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} propertyPath: m_AnchoredPosition.y - value: 0 + value: -17.5 objectReference: {fileID: 0} - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} propertyPath: m_SizeDelta.x - value: 0 + value: 70 objectReference: {fileID: 0} - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} @@ -69679,7 +69662,7 @@ PrefabInstance: - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} propertyPath: m_AnchorMin.y - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} @@ -69689,7 +69672,7 @@ PrefabInstance: - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} propertyPath: m_AnchorMax.y - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} @@ -69711,21 +69694,6 @@ PrefabInstance: propertyPath: m_IsActive value: 1 objectReference: {fileID: 0} - - target: {fileID: 6815987390313110544, guid: 06641392b6ebf5645b031c3f0700a917, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6815987390313110544, guid: 06641392b6ebf5645b031c3f0700a917, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 6815987390313110544, guid: 06641392b6ebf5645b031c3f0700a917, - type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} --- !u!1001 &1172288249 @@ -129611,51 +129579,16 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 936520233} m_Modifications: - - target: {fileID: 2673194343061756520, guid: f3a5c8bf38a7dfa408f601a424edb92d, - type: 3} - propertyPath: m_Enabled - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 2673194343061756521, guid: f3a5c8bf38a7dfa408f601a424edb92d, - type: 3} - propertyPath: m_AnchoredPosition.x - value: 455.90826 - objectReference: {fileID: 0} - - target: {fileID: 2673194343061756521, guid: f3a5c8bf38a7dfa408f601a424edb92d, - type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2673194343061756521, guid: f3a5c8bf38a7dfa408f601a424edb92d, - type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - target: {fileID: 2673194343061756521, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2673194343061756527, guid: f3a5c8bf38a7dfa408f601a424edb92d, - type: 3} - propertyPath: m_Enabled - value: 1 + value: 35 objectReference: {fileID: 0} - target: {fileID: 2673194343061756527, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} propertyPath: m_Padding.m_Top value: 0 objectReference: {fileID: 0} - - target: {fileID: 2673194343769095888, guid: f3a5c8bf38a7dfa408f601a424edb92d, - type: 3} - propertyPath: m_Enabled - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 2673194343769095890, guid: f3a5c8bf38a7dfa408f601a424edb92d, - type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - target: {fileID: 2673194344194583624, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} propertyPath: m_Name @@ -129666,11 +129599,6 @@ PrefabInstance: propertyPath: m_IsActive value: 1 objectReference: {fileID: 0} - - target: {fileID: 2673194344194583630, guid: f3a5c8bf38a7dfa408f601a424edb92d, - type: 3} - propertyPath: m_Enabled - value: 1 - objectReference: {fileID: 0} - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} propertyPath: m_LocalPosition.x @@ -129729,22 +129657,22 @@ PrefabInstance: - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} propertyPath: m_AnchoredPosition.x - value: 478.125 + value: 0 objectReference: {fileID: 0} - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} propertyPath: m_AnchoredPosition.y - value: -5 + value: -20 objectReference: {fileID: 0} - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} propertyPath: m_SizeDelta.x - value: 946.25 + value: -10 objectReference: {fileID: 0} - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} propertyPath: m_SizeDelta.y - value: 0 + value: 105 objectReference: {fileID: 0} - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} @@ -129759,7 +129687,7 @@ PrefabInstance: - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} propertyPath: m_AnchorMax.x - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} @@ -129776,16 +129704,6 @@ PrefabInstance: propertyPath: m_Pivot.y value: 1 objectReference: {fileID: 0} - - target: {fileID: 5679444454996556218, guid: f3a5c8bf38a7dfa408f601a424edb92d, - type: 3} - propertyPath: m_AnchoredPosition.y - value: -10 - objectReference: {fileID: 0} - - target: {fileID: 5679444454996556218, guid: f3a5c8bf38a7dfa408f601a424edb92d, - type: 3} - propertyPath: m_Pivot.y - value: 1 - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} --- !u!224 &2673194344500550916 stripped diff --git a/Assets/GWConquest/Scripts/Editor/ContextMenuHooks.cs b/Assets/GWConquest/Scripts/Editor/ContextMenuHooks.cs index 23cb743..029839d 100644 --- a/Assets/GWConquest/Scripts/Editor/ContextMenuHooks.cs +++ b/Assets/GWConquest/Scripts/Editor/ContextMenuHooks.cs @@ -17,5 +17,17 @@ public class ContextMenuHooks PrefabUtility.RecordPrefabInstancePropertyModifications(rt); } + [MenuItem("CONTEXT/RectTransform/Update Layout")] + static void UpdateLayout(MenuCommand cmd) + { + RectTransform rt = cmd.context as RectTransform; + + Undo.RecordObject(rt, "Updating Layout"); + + GWLayout.UpdateLayout(rt); + + PrefabUtility.RecordPrefabInstancePropertyModifications(rt); + } + } \ No newline at end of file diff --git a/Assets/GWConquest/Scripts/UI/ChildrenSizeFit.cs b/Assets/GWConquest/Scripts/UI/ChildrenSizeFit.cs index 296a4b8..2c0e34c 100644 --- a/Assets/GWConquest/Scripts/UI/ChildrenSizeFit.cs +++ b/Assets/GWConquest/Scripts/UI/ChildrenSizeFit.cs @@ -4,14 +4,16 @@ using UnityEngine.EventSystems; namespace GWConquest { + [ExecuteAlways] [RequireComponent(typeof(RectTransform))] - public class ChildrenSizeFit : UIBehaviour, ILayoutSelfController + public class ChildrenSizeFit : MonoBehaviour, ILayoutElement { public float Padding; - private DrivenRectTransformTracker Tracker; + public bool Horizontal = false; + public bool Vertical = true; [System.NonSerialized] private RectTransform _rt; private RectTransform rt @@ -24,49 +26,34 @@ namespace GWConquest } } - public void SetDirty() + public void UpdateLayout() { - if (!IsActive()) + if (!isActiveAndEnabled) return; - LayoutRebuilder.MarkLayoutForRebuild(rt); - } + if(Horizontal) + SetLayoutAlongAxis(0); - protected override void OnEnable() - { - base.OnEnable(); - SetDirty(); + if(Vertical) + SetLayoutAlongAxis(1); } - protected override void OnDisable() + protected void OnEnable() { - Tracker.Clear(); - LayoutRebuilder.MarkLayoutForRebuild(rt); - base.OnDisable(); - } - - protected override void OnRectTransformDimensionsChange() - { - SetDirty(); + UpdateLayout(); } #if UNITY_EDITOR - protected override void OnValidate() + protected void OnValidate() { - SetDirty(); + UpdateLayout(); } #endif - public void SetLayoutHorizontal() - { - - } - - public void SetLayoutVertical() + public void SetLayoutAlongAxis(int axis) { - Tracker.Clear(); float minY = 0f; float maxY = 0f; @@ -75,35 +62,38 @@ namespace GWConquest RectTransform child = rt.GetChild(i) as RectTransform; //Rect rect = child.rect; //float childHeight = LayoutUtility.GetPreferredHeight(child); - float childHeight = child.sizeDelta.y; + float childHeight = child.sizeDelta[axis]; if(childHeight <= 0) { continue; } - + if(axis == 1) + { + childHeight *= -1; + } + + var pos = child.localPosition[axis]; if(maxY - minY == 0f) { - minY = child.localPosition.y - childHeight; - maxY = child.localPosition.y; + minY = Mathf.Min(pos + childHeight, pos); + maxY = Mathf.Max(pos + childHeight, pos); } else { - minY = Mathf.Min(child.localPosition.y - childHeight, minY); - maxY = Mathf.Max(child.localPosition.y, maxY); + minY = Mathf.Min(pos + childHeight, pos, minY); + maxY = Mathf.Max(pos + childHeight, pos, maxY); } Debug.LogFormat("Child: {0}, Height: {1}, Miny: {2}, Maxy: {3}", child, childHeight, minY, maxY); } - float height = Mathf.Max(maxY - minY, 0f) + Padding; - - Tracker.Add(this, rt, DrivenTransformProperties.SizeDeltaY); + float height = Mathf.Max(Mathf.Abs(maxY - minY), 0f) + Padding; Debug.LogFormat("Setting height to {0}", height); - rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height); + rt.SetSizeWithCurrentAnchors(axis == 0 ? RectTransform.Axis.Horizontal : RectTransform.Axis.Vertical, height); } } diff --git a/Assets/GWConquest/Scripts/UI/FlowLayout.cs b/Assets/GWConquest/Scripts/UI/FlowLayout.cs index b1d999e..b3c6b93 100644 --- a/Assets/GWConquest/Scripts/UI/FlowLayout.cs +++ b/Assets/GWConquest/Scripts/UI/FlowLayout.cs @@ -1,17 +1,32 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; - +using UnityEngine; namespace GWConquest { - public class FlowLayout : LayoutGroup + + [RequireComponent(typeof(RectTransform))] + [ExecuteInEditMode] + public class FlowLayout : MonoBehaviour, ILayoutElement { + public RectOffset padding; + public Vector2 Spacing; - float SetLayoutAlongAxis(int axis) + + private RectTransform _rectTransform; + private RectTransform rectTransform { + get { + if(_rectTransform == null) + { + _rectTransform = GetComponent(); + } + return _rectTransform; + } + } + + public void UpdateLayout() { + if(!isActiveAndEnabled) + return; var size = rectTransform.rect.size; @@ -20,9 +35,13 @@ namespace GWConquest { float currentLineHeight = 0f; - for(int i = 0; i < rectChildren.Count; i++) + for(int i = 0; i < rectTransform.childCount; i++) { - var child = rectChildren[i]; + var child = rectTransform.GetChild(i) as RectTransform; + + if(!child.gameObject.activeSelf) + continue; + var childSize = child.sizeDelta; if(currentX + childSize.x > size.x - padding.right) @@ -32,32 +51,41 @@ namespace GWConquest { currentLineHeight = 0f; } + /* if(axis == 0) { SetChildAlongAxis(child, 0, currentX); } else if(axis == 1){ SetChildAlongAxis(child, 1, currentY); - } + }*/ + + GWLayout.SetChildAlongAxis(child, 0, currentX); + GWLayout.SetChildAlongAxis(child, 1, currentY); currentX += childSize.x + Spacing.x; currentLineHeight = Mathf.Max(currentLineHeight, childSize.y); } - return currentY + currentLineHeight + padding.bottom; + //return currentY + currentLineHeight + padding.bottom; } - public override void SetLayoutHorizontal() + protected void OnEnable() { - SetLayoutAlongAxis(0); + UpdateLayout(); } - public override void SetLayoutVertical() +#if UNITY_EDITOR + protected void OnValidate() { - SetLayoutAlongAxis(1); + UpdateLayout(); } +#endif + + + /* void CalcAlongAxis(int axis) { float totalMin = 0f; @@ -96,5 +124,7 @@ namespace GWConquest { CalcAlongAxis(1); } + */ + } } diff --git a/Assets/GWConquest/Scripts/UI/GWLayout.cs b/Assets/GWConquest/Scripts/UI/GWLayout.cs new file mode 100644 index 0000000..f1e612d --- /dev/null +++ b/Assets/GWConquest/Scripts/UI/GWLayout.cs @@ -0,0 +1,41 @@ +using UnityEngine; + +namespace GWConquest +{ + public interface ILayoutElement { + void UpdateLayout(); + } + + public class GWLayout + { + public static void UpdateLayout(RectTransform rt) { + for(int i = 0; i < rt.childCount; i++) + { + var child = rt.GetChild(i) as RectTransform; + if(child.gameObject.activeSelf) + { + UpdateLayout(child); + } + } + + var layoutElements = rt.GetComponents(); + foreach(var layoutElement in layoutElements) + { + layoutElement.UpdateLayout(); + } + } + + public static void SetChildAlongAxis(RectTransform rect, int axis, float pos, float scaleFactor = 1f) + { + if (rect == null) + return; + + //rect.anchorMin = Vector2.up; + //rect.anchorMax = Vector2.up; + + Vector2 anchoredPosition = rect.anchoredPosition; + anchoredPosition[axis] = (axis == 0) ? (pos + rect.sizeDelta[axis] * rect.pivot[axis] * scaleFactor) : (-pos - rect.sizeDelta[axis] * (1f - rect.pivot[axis]) * scaleFactor); + rect.anchoredPosition = anchoredPosition; + } + } +} \ No newline at end of file diff --git a/Assets/GWConquest/Scripts/UI/GWLayout.cs.meta b/Assets/GWConquest/Scripts/UI/GWLayout.cs.meta new file mode 100644 index 0000000..8d7b671 --- /dev/null +++ b/Assets/GWConquest/Scripts/UI/GWLayout.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2bce9fd83820e6040b248c16d2bc4181 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GWConquest/Scripts/UI/TransportUI.cs b/Assets/GWConquest/Scripts/UI/TransportUI.cs index cf21690..0295936 100644 --- a/Assets/GWConquest/Scripts/UI/TransportUI.cs +++ b/Assets/GWConquest/Scripts/UI/TransportUI.cs @@ -40,7 +40,13 @@ namespace GWConquest { var elementGO = Instantiate(ElementPrefab); - elementGO.GetComponent().SetParent(GroundPanel.ContentTransform); + var elementRT = elementGO.GetComponent(); + + elementRT.SetParent(GroundPanel.ContentTransform); + elementRT.anchoredPosition = Vector2.zero; + var size = elementRT.sizeDelta; + size.x = 0f; + elementRT.sizeDelta = size; var elementComp = elementGO.GetComponent(); elementComp.IsDistrict = true; @@ -49,7 +55,9 @@ namespace GWConquest } } - LayoutRebuilder.MarkLayoutForRebuild(GroundPanel.ContentTransform); + GWLayout.UpdateLayout(GroundPanel.ContentTransform); + + //LayoutRebuilder.MarkLayoutForRebuild(GroundPanel.ContentTransform); //LayoutRebuilder.ForceRebuildLayoutImmediate(GroundPanel.ContentTransform); diff --git a/Assets/GWConquest/Scripts/UI/TransportUIElement.cs b/Assets/GWConquest/Scripts/UI/TransportUIElement.cs index 53a11dd..3199638 100644 --- a/Assets/GWConquest/Scripts/UI/TransportUIElement.cs +++ b/Assets/GWConquest/Scripts/UI/TransportUIElement.cs @@ -43,6 +43,7 @@ namespace GWConquest { foreach(var child in ChildrenList) { + child.gameObject.SetActive(false); Destroy(child.gameObject); } @@ -61,9 +62,10 @@ namespace GWConquest itemIconGO.GetComponentInChildren().text = stack.Amount.ToString(); itemIconGO.GetComponent().SetParent(ItemIconsTransform); + itemIconGO.GetComponent().anchoredPosition = Vector2.zero; } - LayoutRebuilder.MarkLayoutForRebuild(ItemIconsTransform); + //LayoutRebuilder.MarkLayoutForRebuild(ItemIconsTransform); if(IsDistrict) { @@ -74,7 +76,9 @@ namespace GWConquest } - LayoutRebuilder.MarkLayoutForRebuild(GetComponent()); + //LayoutRebuilder.MarkLayoutForRebuild(GetComponent()); + + //LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent()); } diff --git a/Assets/GWConquest/Scripts/UI/VerticalLayout.cs b/Assets/GWConquest/Scripts/UI/VerticalLayout.cs new file mode 100644 index 0000000..f5288f3 --- /dev/null +++ b/Assets/GWConquest/Scripts/UI/VerticalLayout.cs @@ -0,0 +1,58 @@ +using UnityEngine; + +namespace GWConquest { + + [RequireComponent(typeof(RectTransform))] + [ExecuteInEditMode] + public class VerticalLayout : MonoBehaviour, ILayoutElement + { + public float Padding; + public float Spacing; + + private RectTransform _rectTransform; + private RectTransform rectTransform { + get { + if(_rectTransform == null) + { + _rectTransform = GetComponent(); + } + return _rectTransform; + } + } + + public void UpdateLayout() + { + if(!isActiveAndEnabled) + return; + + float currentY = Padding; + + for(int i = 0; i < rectTransform.childCount; i++) + { + var child = rectTransform.GetChild(i) as RectTransform; + + if(child.gameObject.activeSelf) + { + GWLayout.SetChildAlongAxis(child, 1, currentY); + + currentY += child.sizeDelta.y + Spacing; + } + } + } + + protected void OnEnable() + { + UpdateLayout(); + } + +#if UNITY_EDITOR + protected void OnValidate() + { + UpdateLayout(); + } + +#endif + } +} + + diff --git a/Assets/GWConquest/Scripts/UI/VerticalLayout.cs.meta b/Assets/GWConquest/Scripts/UI/VerticalLayout.cs.meta new file mode 100644 index 0000000..a336590 --- /dev/null +++ b/Assets/GWConquest/Scripts/UI/VerticalLayout.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b0cffe833675a2942be0665d6d259496 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GWConquest/Scripts/Util.cs b/Assets/GWConquest/Scripts/Util.cs index 969284c..93765d8 100644 --- a/Assets/GWConquest/Scripts/Util.cs +++ b/Assets/GWConquest/Scripts/Util.cs @@ -146,7 +146,9 @@ namespace GWConquest { for(int i = 0; i < transform.childCount; i++) { - UnityEngine.Object.Destroy(transform.GetChild(i).gameObject); + var go = transform.GetChild(i).gameObject; + go.SetActive(false); + UnityEngine.Object.Destroy(go); } }