Browse Source

Layout-System

bolt_update
laurids 3 years ago
parent
commit
ef561c12d7
13 changed files with 299 additions and 248 deletions
  1. +14
    -39
      Assets/GWConquest/Prefabs/UI/ItemIcon.prefab
  2. +32
    -41
      Assets/GWConquest/Prefabs/UI/TransportUIElement.prefab
  3. +28
    -110
      Assets/GWConquest/Scenes/GalaxyMap.unity
  4. +12
    -0
      Assets/GWConquest/Scripts/Editor/ContextMenuHooks.cs
  5. +28
    -38
      Assets/GWConquest/Scripts/UI/ChildrenSizeFit.cs
  6. +45
    -15
      Assets/GWConquest/Scripts/UI/FlowLayout.cs
  7. +41
    -0
      Assets/GWConquest/Scripts/UI/GWLayout.cs
  8. +11
    -0
      Assets/GWConquest/Scripts/UI/GWLayout.cs.meta
  9. +10
    -2
      Assets/GWConquest/Scripts/UI/TransportUI.cs
  10. +6
    -2
      Assets/GWConquest/Scripts/UI/TransportUIElement.cs
  11. +58
    -0
      Assets/GWConquest/Scripts/UI/VerticalLayout.cs
  12. +11
    -0
      Assets/GWConquest/Scripts/UI/VerticalLayout.cs.meta
  13. +3
    -1
      Assets/GWConquest/Scripts/Util.cs

+ 14
- 39
Assets/GWConquest/Prefabs/UI/ItemIcon.prefab View File

@ -33,11 +33,11 @@ RectTransform:
m_Father: {fileID: 6815987390155653560} m_Father: {fileID: 6815987390155653560}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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: 40, y: 0} m_AnchoredPosition: {x: 40, y: 0}
m_SizeDelta: {x: 0, y: 35} m_SizeDelta: {x: 0, y: 35}
m_Pivot: {x: 0, y: 1}
m_Pivot: {x: 0, y: 0.5}
--- !u!222 &6815987389502116017 --- !u!222 &6815987389502116017
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -106,8 +106,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 6815987390155653560} - component: {fileID: 6815987390155653560}
- component: {fileID: 6815987390155653558} - component: {fileID: 6815987390155653558}
- component: {fileID: 5791924757031699370}
- component: {fileID: 244878247843148808}
- component: {fileID: 1138806303401438636}
m_Layer: 5 m_Layer: 5
m_Name: ItemIcon m_Name: ItemIcon
m_TagString: Untagged m_TagString: Untagged
@ -131,10 +130,10 @@ RectTransform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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_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} m_Pivot: {x: 0, y: 0.5}
--- !u!222 &6815987390155653558 --- !u!222 &6815987390155653558
CanvasRenderer: CanvasRenderer:
@ -144,7 +143,7 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815987390155653563} m_GameObject: {fileID: 6815987390155653563}
m_CullTransparentMesh: 0 m_CullTransparentMesh: 0
--- !u!114 &5791924757031699370
--- !u!114 &1138806303401438636
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -153,36 +152,12 @@ MonoBehaviour:
m_GameObject: {fileID: 6815987390155653563} m_GameObject: {fileID: 6815987390155653563}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: 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 --- !u!1 &6815987390313110547
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -215,8 +190,8 @@ RectTransform:
m_Father: {fileID: 6815987390155653560} m_Father: {fileID: 6815987390155653560}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 35, y: 35} m_SizeDelta: {x: 35, y: 35}
m_Pivot: {x: 0, y: 0.5} m_Pivot: {x: 0, y: 0.5}


+ 32
- 41
Assets/GWConquest/Prefabs/UI/TransportUIElement.prefab View File

@ -10,7 +10,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 2673194343061756521} - component: {fileID: 2673194343061756521}
- component: {fileID: 2673194343061756527} - component: {fileID: 2673194343061756527}
- component: {fileID: 2673194343061756520}
- component: {fileID: 5407586027641697039}
m_Layer: 5 m_Layer: 5
m_Name: ItemIcons m_Name: ItemIcons
m_TagString: Untagged m_TagString: Untagged
@ -32,10 +32,10 @@ RectTransform:
m_Father: {fileID: 2673194343769095890} m_Father: {fileID: 2673194343769095890}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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} m_Pivot: {x: 0.5, y: 1}
--- !u!114 &2673194343061756527 --- !u!114 &2673194343061756527
MonoBehaviour: MonoBehaviour:
@ -49,14 +49,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 048208b8918c3c74c821e2e69e3d613d, type: 3} m_Script: {fileID: 11500000, guid: 048208b8918c3c74c821e2e69e3d613d, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Padding:
m_Left: 10
m_Right: 10
padding:
m_Left: 0
m_Right: 0
m_Top: 0 m_Top: 0
m_Bottom: 0 m_Bottom: 0
m_ChildAlignment: 0
Spacing: {x: 15, y: 15} Spacing: {x: 15, y: 15}
--- !u!114 &2673194343061756520
--- !u!114 &5407586027641697039
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -65,11 +64,12 @@ MonoBehaviour:
m_GameObject: {fileID: 2673194343061756522} m_GameObject: {fileID: 2673194343061756522}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
Padding: 0
Horizontal: 0
Vertical: 1
--- !u!1 &2673194343256469681 --- !u!1 &2673194343256469681
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -134,7 +134,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 21300000, guid: bd93e35d8eadb9844adef76ee7beacee, type: 3}
m_Sprite: {fileID: 0}
m_Type: 0 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
@ -221,7 +221,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0 m_HorizontalOverflow: 0
m_VerticalOverflow: 0 m_VerticalOverflow: 0
m_LineSpacing: 1 m_LineSpacing: 1
m_Text: Agri District
m_Text: Group Name
--- !u!1 &2673194343700811292 --- !u!1 &2673194343700811292
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -305,8 +305,8 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 2673194343769095890} - component: {fileID: 2673194343769095890}
- component: {fileID: 2673194343769095888}
- component: {fileID: 2673194343769095889}
- component: {fileID: 4672820892231590445}
- component: {fileID: 9046570603510387992}
m_Layer: 5 m_Layer: 5
m_Name: Children m_Name: Children
m_TagString: Untagged m_TagString: Untagged
@ -331,10 +331,10 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, 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} m_Pivot: {x: 0.5, y: 1}
--- !u!114 &2673194343769095888
--- !u!114 &4672820892231590445
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -343,23 +343,11 @@ MonoBehaviour:
m_GameObject: {fileID: 2673194343769095891} m_GameObject: {fileID: 2673194343769095891}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
m_Script: {fileID: 11500000, guid: b0cffe833675a2942be0665d6d259496, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: 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: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -368,11 +356,12 @@ MonoBehaviour:
m_GameObject: {fileID: 2673194343769095891} m_GameObject: {fileID: 2673194343769095891}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
Padding: 0
Horizontal: 0
Vertical: 1
--- !u!1 &2673194344194583624 --- !u!1 &2673194344194583624
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -410,7 +399,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -10} 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} m_Pivot: {x: 0.5, y: 1}
--- !u!114 &2673194344194583630 --- !u!114 &2673194344194583630
MonoBehaviour: MonoBehaviour:
@ -424,7 +413,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3} m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
Padding: 20
Padding: 0
Horizontal: 0
Vertical: 1
--- !u!114 &8452816462676908967 --- !u!114 &8452816462676908967
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -642,6 +633,6 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, 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_SizeDelta: {x: -20, y: 60}
m_Pivot: {x: 0.5, y: 1} m_Pivot: {x: 0.5, y: 1}

+ 28
- 110
Assets/GWConquest/Scenes/GalaxyMap.unity View File

@ -15239,7 +15239,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, 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_SizeDelta: {x: -169.53058, y: 35}
m_Pivot: {x: 0.5, y: 1} m_Pivot: {x: 0.5, y: 1}
--- !u!114 &256267753 --- !u!114 &256267753
@ -36699,7 +36699,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1658066164} m_TargetGraphic: {fileID: 1658066164}
m_HandleRect: {fileID: 1658066163} m_HandleRect: {fileID: 1658066163}
m_Direction: 2 m_Direction: 2
m_Value: 1
m_Value: 0
m_Size: 1 m_Size: 1
m_NumberOfSteps: 0 m_NumberOfSteps: 0
m_OnValueChanged: m_OnValueChanged:
@ -54930,8 +54930,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, 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} m_Pivot: {x: 0, y: 1}
--- !u!114 &936520234 --- !u!114 &936520234
MonoBehaviour: MonoBehaviour:
@ -54942,11 +54942,12 @@ MonoBehaviour:
m_GameObject: {fileID: 936520232} m_GameObject: {fileID: 936520232}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Script: {fileID: 11500000, guid: 68d57de996f29404f8d57bdeb85ab942, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
Padding: 0
Horizontal: 0
Vertical: 1
--- !u!114 &936520235 --- !u!114 &936520235
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -54956,22 +54957,11 @@ MonoBehaviour:
m_GameObject: {fileID: 936520232} m_GameObject: {fileID: 936520232}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
m_Script: {fileID: 11500000, guid: b0cffe833675a2942be0665d6d259496, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: 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 --- !u!1 &939647887
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -69576,20 +69566,13 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 2673194344500550916} m_TransformParent: {fileID: 2673194344500550916}
m_Modifications: 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} 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} objectReference: {fileID: 0}
- target: {fileID: 6815987389502116018, guid: 06641392b6ebf5645b031c3f0700a917, - target: {fileID: 6815987389502116018, guid: 06641392b6ebf5645b031c3f0700a917,
type: 3} type: 3}
@ -69654,17 +69637,17 @@ PrefabInstance:
- target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: 10
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: 0
value: -17.5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917,
type: 3} type: 3}
propertyPath: m_SizeDelta.x propertyPath: m_SizeDelta.x
value: 0
value: 70
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917,
type: 3} type: 3}
@ -69679,7 +69662,7 @@ PrefabInstance:
- target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917,
type: 3} type: 3}
propertyPath: m_AnchorMin.y propertyPath: m_AnchorMin.y
value: 0
value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917,
type: 3} type: 3}
@ -69689,7 +69672,7 @@ PrefabInstance:
- target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917,
type: 3} type: 3}
propertyPath: m_AnchorMax.y propertyPath: m_AnchorMax.y
value: 0
value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917, - target: {fileID: 6815987390155653560, guid: 06641392b6ebf5645b031c3f0700a917,
type: 3} type: 3}
@ -69711,21 +69694,6 @@ PrefabInstance:
propertyPath: m_IsActive propertyPath: m_IsActive
value: 1 value: 1
objectReference: {fileID: 0} 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_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 06641392b6ebf5645b031c3f0700a917, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 06641392b6ebf5645b031c3f0700a917, type: 3}
--- !u!1001 &1172288249 --- !u!1001 &1172288249
@ -129611,51 +129579,16 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 936520233} m_TransformParent: {fileID: 936520233}
m_Modifications: 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, - target: {fileID: 2673194343061756521, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
propertyPath: m_SizeDelta.y 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} objectReference: {fileID: 0}
- target: {fileID: 2673194343061756527, guid: f3a5c8bf38a7dfa408f601a424edb92d, - target: {fileID: 2673194343061756527, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
propertyPath: m_Padding.m_Top propertyPath: m_Padding.m_Top
value: 0 value: 0
objectReference: {fileID: 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, - target: {fileID: 2673194344194583624, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
propertyPath: m_Name propertyPath: m_Name
@ -129666,11 +129599,6 @@ PrefabInstance:
propertyPath: m_IsActive propertyPath: m_IsActive
value: 1 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2673194344194583630, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -129729,22 +129657,22 @@ PrefabInstance:
- target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: 478.125
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: -5
value: -20
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
propertyPath: m_SizeDelta.x propertyPath: m_SizeDelta.x
value: 946.25
value: -10
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
propertyPath: m_SizeDelta.y propertyPath: m_SizeDelta.y
value: 0
value: 105
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
@ -129759,7 +129687,7 @@ PrefabInstance:
- target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
propertyPath: m_AnchorMax.x propertyPath: m_AnchorMax.x
value: 0
value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d, - target: {fileID: 2673194344194583631, guid: f3a5c8bf38a7dfa408f601a424edb92d,
type: 3} type: 3}
@ -129776,16 +129704,6 @@ PrefabInstance:
propertyPath: m_Pivot.y propertyPath: m_Pivot.y
value: 1 value: 1
objectReference: {fileID: 0} 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_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3} m_SourcePrefab: {fileID: 100100000, guid: f3a5c8bf38a7dfa408f601a424edb92d, type: 3}
--- !u!224 &2673194344500550916 stripped --- !u!224 &2673194344500550916 stripped


+ 12
- 0
Assets/GWConquest/Scripts/Editor/ContextMenuHooks.cs View File

@ -17,5 +17,17 @@ public class ContextMenuHooks
PrefabUtility.RecordPrefabInstancePropertyModifications(rt); 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);
}
} }

+ 28
- 38
Assets/GWConquest/Scripts/UI/ChildrenSizeFit.cs View File

@ -4,14 +4,16 @@ using UnityEngine.EventSystems;
namespace GWConquest namespace GWConquest
{ {
[ExecuteAlways] [ExecuteAlways]
[RequireComponent(typeof(RectTransform))] [RequireComponent(typeof(RectTransform))]
public class ChildrenSizeFit : UIBehaviour, ILayoutSelfController
public class ChildrenSizeFit : MonoBehaviour, ILayoutElement
{ {
public float Padding; public float Padding;
private DrivenRectTransformTracker Tracker;
public bool Horizontal = false;
public bool Vertical = true;
[System.NonSerialized] private RectTransform _rt; [System.NonSerialized] private RectTransform _rt;
private RectTransform rt private RectTransform rt
@ -24,49 +26,34 @@ namespace GWConquest
} }
} }
public void SetDirty()
public void UpdateLayout()
{ {
if (!IsActive())
if (!isActiveAndEnabled)
return; 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 #if UNITY_EDITOR
protected override void OnValidate()
protected void OnValidate()
{ {
SetDirty();
UpdateLayout();
} }
#endif #endif
public void SetLayoutHorizontal()
{
}
public void SetLayoutVertical()
public void SetLayoutAlongAxis(int axis)
{ {
Tracker.Clear();
float minY = 0f; float minY = 0f;
float maxY = 0f; float maxY = 0f;
@ -75,35 +62,38 @@ namespace GWConquest
RectTransform child = rt.GetChild(i) as RectTransform; RectTransform child = rt.GetChild(i) as RectTransform;
//Rect rect = child.rect; //Rect rect = child.rect;
//float childHeight = LayoutUtility.GetPreferredHeight(child); //float childHeight = LayoutUtility.GetPreferredHeight(child);
float childHeight = child.sizeDelta.y;
float childHeight = child.sizeDelta[axis];
if(childHeight <= 0) if(childHeight <= 0)
{ {
continue; continue;
} }
if(axis == 1)
{
childHeight *= -1;
}
var pos = child.localPosition[axis];
if(maxY - minY == 0f) 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 { 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); 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); Debug.LogFormat("Setting height to {0}", height);
rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
rt.SetSizeWithCurrentAnchors(axis == 0 ? RectTransform.Axis.Horizontal : RectTransform.Axis.Vertical, height);
} }
} }


+ 45
- 15
Assets/GWConquest/Scripts/UI/FlowLayout.cs View File

@ -1,17 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine;
namespace GWConquest { namespace GWConquest {
public class FlowLayout : LayoutGroup
[RequireComponent(typeof(RectTransform))]
[ExecuteInEditMode]
public class FlowLayout : MonoBehaviour, ILayoutElement
{ {
public RectOffset padding;
public Vector2 Spacing; public Vector2 Spacing;
float SetLayoutAlongAxis(int axis)
private RectTransform _rectTransform;
private RectTransform rectTransform {
get {
if(_rectTransform == null)
{
_rectTransform = GetComponent<RectTransform>();
}
return _rectTransform;
}
}
public void UpdateLayout()
{ {
if(!isActiveAndEnabled)
return;
var size = rectTransform.rect.size; var size = rectTransform.rect.size;
@ -20,9 +35,13 @@ namespace GWConquest {
float currentLineHeight = 0f; 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; var childSize = child.sizeDelta;
if(currentX + childSize.x > size.x - padding.right) if(currentX + childSize.x > size.x - padding.right)
@ -32,32 +51,41 @@ namespace GWConquest {
currentLineHeight = 0f; currentLineHeight = 0f;
} }
/*
if(axis == 0) if(axis == 0)
{ {
SetChildAlongAxis(child, 0, currentX); SetChildAlongAxis(child, 0, currentX);
} }
else if(axis == 1){ else if(axis == 1){
SetChildAlongAxis(child, 1, currentY); SetChildAlongAxis(child, 1, currentY);
}
}*/
GWLayout.SetChildAlongAxis(child, 0, currentX);
GWLayout.SetChildAlongAxis(child, 1, currentY);
currentX += childSize.x + Spacing.x; currentX += childSize.x + Spacing.x;
currentLineHeight = Mathf.Max(currentLineHeight, childSize.y); 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) void CalcAlongAxis(int axis)
{ {
float totalMin = 0f; float totalMin = 0f;
@ -96,5 +124,7 @@ namespace GWConquest {
CalcAlongAxis(1); CalcAlongAxis(1);
} }
*/
} }
} }

+ 41
- 0
Assets/GWConquest/Scripts/UI/GWLayout.cs View File

@ -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<ILayoutElement>();
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;
}
}
}

+ 11
- 0
Assets/GWConquest/Scripts/UI/GWLayout.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2bce9fd83820e6040b248c16d2bc4181
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 10
- 2
Assets/GWConquest/Scripts/UI/TransportUI.cs View File

@ -40,7 +40,13 @@ namespace GWConquest
{ {
var elementGO = Instantiate(ElementPrefab); var elementGO = Instantiate(ElementPrefab);
elementGO.GetComponent<RectTransform>().SetParent(GroundPanel.ContentTransform);
var elementRT = elementGO.GetComponent<RectTransform>();
elementRT.SetParent(GroundPanel.ContentTransform);
elementRT.anchoredPosition = Vector2.zero;
var size = elementRT.sizeDelta;
size.x = 0f;
elementRT.sizeDelta = size;
var elementComp = elementGO.GetComponent<TransportUIElement>(); var elementComp = elementGO.GetComponent<TransportUIElement>();
elementComp.IsDistrict = true; 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); //LayoutRebuilder.ForceRebuildLayoutImmediate(GroundPanel.ContentTransform);


+ 6
- 2
Assets/GWConquest/Scripts/UI/TransportUIElement.cs View File

@ -43,6 +43,7 @@ namespace GWConquest
{ {
foreach(var child in ChildrenList) foreach(var child in ChildrenList)
{ {
child.gameObject.SetActive(false);
Destroy(child.gameObject); Destroy(child.gameObject);
} }
@ -61,9 +62,10 @@ namespace GWConquest
itemIconGO.GetComponentInChildren<Text>().text = stack.Amount.ToString(); itemIconGO.GetComponentInChildren<Text>().text = stack.Amount.ToString();
itemIconGO.GetComponent<RectTransform>().SetParent(ItemIconsTransform); itemIconGO.GetComponent<RectTransform>().SetParent(ItemIconsTransform);
itemIconGO.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
} }
LayoutRebuilder.MarkLayoutForRebuild(ItemIconsTransform);
//LayoutRebuilder.MarkLayoutForRebuild(ItemIconsTransform);
if(IsDistrict) if(IsDistrict)
{ {
@ -74,7 +76,9 @@ namespace GWConquest
} }
LayoutRebuilder.MarkLayoutForRebuild(GetComponent<RectTransform>());
//LayoutRebuilder.MarkLayoutForRebuild(GetComponent<RectTransform>());
//LayoutRebuilder.ForceRebuildLayoutImmediate(GetComponent<RectTransform>());
} }


+ 58
- 0
Assets/GWConquest/Scripts/UI/VerticalLayout.cs View File

@ -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<RectTransform>();
}
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
}
}

+ 11
- 0
Assets/GWConquest/Scripts/UI/VerticalLayout.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b0cffe833675a2942be0665d6d259496
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 3
- 1
Assets/GWConquest/Scripts/Util.cs View File

@ -146,7 +146,9 @@ namespace GWConquest
{ {
for(int i = 0; i < transform.childCount; i++) 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);
} }
} }


Loading…
Cancel
Save