diff --git a/Assets/Prefabs/Panels/LayersPanel.prefab b/Assets/Prefabs/Panels/LayersPanel.prefab index 225f071824..4c7781fd88 100644 --- a/Assets/Prefabs/Panels/LayersPanel.prefab +++ b/Assets/Prefabs/Panels/LayersPanel.prefab @@ -181,8 +181,9 @@ Transform: - {fileID: 1602526624714584052} - {fileID: 5784257269716051532} - {fileID: 7563585633729571511} - - {fileID: 2948504533129078189} - {fileID: 8501872200189977526} + - {fileID: 8004785674552786393} + - {fileID: 8004785674552864887} - {fileID: 6273472629259780946} - {fileID: 1442615980906467047} - {fileID: 416416} @@ -264,7 +265,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 496394} - m_RootOrder: 15 + m_RootOrder: 16 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!33 &3365058 MeshFilter: @@ -309,7 +310,6 @@ Transform: - {fileID: 4000013861244948} - {fileID: 440944} - {fileID: 496394} - - {fileID: 5145689874473423946} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -322,7 +322,7 @@ MonoBehaviour: m_GameObject: {fileID: 176644} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: a7d0b1933e6839443a2050b4306ef453, type: 3} + m_Script: {fileID: 11500000, guid: 3707fbc432bd4875bb62411d9cb5dc60, type: 3} m_Name: m_EditorClassIdentifier: m_PanelType: 15000 @@ -464,6 +464,8 @@ MonoBehaviour: m_FallbackState: 0 m_WaitForCompletion: 0 m_LocalVariables: [] + m_PreviousPageButton: {fileID: 8004785674545934389} + m_NextPageButton: {fileID: 8004785674546027427} m_Widgets: - {fileID: 8931799926426736621} - {fileID: 8049365247439104534} @@ -472,7 +474,6 @@ MonoBehaviour: - {fileID: 8757977741134147876} - {fileID: 4607754664015214748} - {fileID: 522565082401551463} - - {fileID: 5142255780986780541} references: version: 2 RefIds: [] @@ -592,7 +593,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 496394} - m_RootOrder: 14 + m_RootOrder: 15 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!33 &1476682871784013101 MeshFilter: @@ -948,7 +949,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 496394} - m_RootOrder: 13 + m_RootOrder: 14 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!33 &6504244258606918893 MeshFilter: @@ -1077,7 +1078,7 @@ MonoBehaviour: references: version: 2 RefIds: [] ---- !u!1 &7912276510237571414 +--- !u!1 &8004785674553011133 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -1085,87 +1086,300 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 5145689874473423946} - - component: {fileID: 1868760599541160895} - - component: {fileID: 8614755795430006044} + - component: {fileID: 8004785674552864887} + - component: {fileID: 8004785674554171393} + - component: {fileID: 8004785674554744181} + - component: {fileID: 8004785674551013973} + - component: {fileID: 8004785674546027427} m_Layer: 16 - m_Name: EventSystem + m_Name: NextPage m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &5145689874473423946 +--- !u!4 &8004785674552864887 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7912276510237571414} - 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_GameObject: {fileID: 8004785674553011133} + m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068} + m_LocalPosition: {x: 0.724, y: -0.785, z: 0.041} + m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 449684} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1868760599541160895 + m_Father: {fileID: 496394} + m_RootOrder: 13 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90} +--- !u!33 &8004785674554171393 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8004785674553011133} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &8004785674554744181 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8004785674553011133} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 0 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 5ba3c7f8df6e87543a356f17f88601fe, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!65 &8004785674551013973 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8004785674553011133} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 0.01} + m_Center: {x: 0, y: 0, z: -0.01} +--- !u!114 &8004785674546027427 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7912276510237571414} + m_GameObject: {fileID: 8004785674553011133} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Script: {fileID: 11500000, guid: dbae3ff4457df6f4ea3af0389871cb9c, type: 3} m_Name: m_EditorClassIdentifier: - m_FirstSelected: {fileID: 0} - m_sendNavigationEvents: 1 - m_DragThreshold: 10 ---- !u!114 &8614755795430006044 + m_DescriptionType: -1 + m_DescriptionYOffset: 0 + m_DescriptionText: + m_LocalizedDescription: + m_TableReference: + m_TableCollectionName: + m_TableEntryReference: + m_KeyId: 0 + m_Key: + m_FallbackState: 0 + m_WaitForCompletion: 0 + m_LocalVariables: [] + m_DescriptionTextExtra: + m_LocalizedDescriptionExtra: + m_TableReference: + m_TableCollectionName: + m_TableEntryReference: + m_KeyId: 0 + m_Key: + m_FallbackState: 0 + m_WaitForCompletion: 0 + m_LocalVariables: [] + m_DescriptionActivateSpeed: 12 + m_DescriptionZScale: 1 + m_ButtonTexture: {fileID: 2800000, guid: ab8b9a0b96b6cb74ca1e518f3c56b425, type: 3} + m_AtlasTexture: 1 + m_ToggleButton: 0 + m_LongPressReleaseButton: 0 + m_ButtonHasPressedAudio: 1 + m_ZAdjustHover: -0.02 + m_ZAdjustClick: 0.05 + m_HoverScale: 1.1 + m_HoverBoxColliderGrow: 0.2 + m_AddOverlay: 0 + m_SelectionTexture: {fileID: 0} + m_ButtonType: 0 + m_GotoPage: 0 + m_InactiveColor: {r: 0, g: 0, b: 0, a: 0} + references: + version: 2 + RefIds: [] +--- !u!1 &8004785674553013047 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8004785674552786393} + - component: {fileID: 8004785674554065423} + - component: {fileID: 8004785674554755561} + - component: {fileID: 8004785674550985467} + - component: {fileID: 8004785674545934389} + m_Layer: 16 + m_Name: PrevPage + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8004785674552786393 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8004785674553013047} + m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068} + m_LocalPosition: {x: 0.498, y: -0.785, z: 0.041} + m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 496394} + m_RootOrder: 12 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90} +--- !u!33 &8004785674554065423 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8004785674553013047} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &8004785674554755561 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8004785674553013047} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 0 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 5ba3c7f8df6e87543a356f17f88601fe, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!65 &8004785674550985467 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8004785674553013047} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 0.01} + m_Center: {x: 0, y: 0, z: -0.01} +--- !u!114 &8004785674545934389 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7912276510237571414} + m_GameObject: {fileID: 8004785674553013047} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} + m_Script: {fileID: 11500000, guid: dbae3ff4457df6f4ea3af0389871cb9c, type: 3} m_Name: m_EditorClassIdentifier: - m_SendPointerHoverToParent: 1 - m_MoveRepeatDelay: 0.5 - m_MoveRepeatRate: 0.1 - m_XRTrackingOrigin: {fileID: 0} - m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, - type: 3} - m_DeselectOnBackgroundClick: 1 - m_PointerBehavior: 0 - m_CursorLockBehavior: 0 + m_DescriptionType: -1 + m_DescriptionYOffset: 0 + m_DescriptionText: + m_LocalizedDescription: + m_TableReference: + m_TableCollectionName: + m_TableEntryReference: + m_KeyId: 0 + m_Key: + m_FallbackState: 0 + m_WaitForCompletion: 0 + m_LocalVariables: [] + m_DescriptionTextExtra: + m_LocalizedDescriptionExtra: + m_TableReference: + m_TableCollectionName: + m_TableEntryReference: + m_KeyId: 0 + m_Key: + m_FallbackState: 0 + m_WaitForCompletion: 0 + m_LocalVariables: [] + m_DescriptionActivateSpeed: 12 + m_DescriptionZScale: 1 + m_ButtonTexture: {fileID: 2800000, guid: f74f6eac3e3e3c640b1a343ec46ba2dd, type: 3} + m_AtlasTexture: 1 + m_ToggleButton: 0 + m_LongPressReleaseButton: 0 + m_ButtonHasPressedAudio: 1 + m_ZAdjustHover: -0.02 + m_ZAdjustClick: 0.05 + m_HoverScale: 1.1 + m_HoverBoxColliderGrow: 0.2 + m_AddOverlay: 0 + m_SelectionTexture: {fileID: 0} + m_ButtonType: 1 + m_GotoPage: 0 + m_InactiveColor: {r: 0, g: 0, b: 0, a: 0} + references: + version: 2 + RefIds: [] --- !u!1001 &763918250215930736 PrefabInstance: m_ObjectHideFlags: 0 @@ -1454,67 +1668,6 @@ GameObject: type: 3} m_PrefabInstance: {fileID: 2222750886918293131} m_PrefabAsset: {fileID: 0} ---- !u!1001 &2481513017685043739 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 496394} - m_Modifications: - - target: {fileID: 764252602712346550, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, - type: 3} - propertyPath: m_RootOrder - value: 11 - objectReference: {fileID: 0} - - target: {fileID: 764252602712346550, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, - type: 3} - propertyPath: m_LocalPosition.x - value: -0.011 - objectReference: {fileID: 0} - - target: {fileID: 764252602712346550, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, - type: 3} - propertyPath: m_LocalPosition.y - value: -0.76 - objectReference: {fileID: 0} - - target: {fileID: 764252602712346550, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, - type: 3} - propertyPath: m_LocalPosition.z - value: 0.041 - objectReference: {fileID: 0} - - target: {fileID: 764252602712346550, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, - type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 764252602712346550, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, - type: 3} - propertyPath: m_LocalRotation.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 764252602712346550, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, - type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 7290462010586009958, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, - type: 3} - propertyPath: m_Name - value: LayerWidget 7 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, type: 3} ---- !u!4 &2948504533129078189 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 764252602712346550, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, - type: 3} - m_PrefabInstance: {fileID: 2481513017685043739} - m_PrefabAsset: {fileID: 0} ---- !u!1 &5142255780986780541 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 7290462010586009958, guid: 11ea7c56cbc37e944bb9fcd3cdb20b8a, - type: 3} - m_PrefabInstance: {fileID: 2481513017685043739} - m_PrefabAsset: {fileID: 0} --- !u!1001 &4426943955357017194 PrefabInstance: m_ObjectHideFlags: 0 @@ -1586,7 +1739,7 @@ PrefabInstance: - target: {fileID: 4122287848348296494, guid: e6acd08b146ccc146820104c9d4e48fd, type: 3} propertyPath: m_RootOrder - value: 12 + value: 11 objectReference: {fileID: 0} - target: {fileID: 4122287848348296494, guid: e6acd08b146ccc146820104c9d4e48fd, type: 3} diff --git a/Assets/Scripts/GUI/LayersPanel.cs b/Assets/Scripts/GUI/LayersPanel.cs new file mode 100644 index 0000000000..0886e5e6a4 --- /dev/null +++ b/Assets/Scripts/GUI/LayersPanel.cs @@ -0,0 +1,39 @@ +// Copyright 2024 The Open Brush Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using TiltBrush.Layers; + +namespace TiltBrush +{ + public class LayersPanel : BasePanel + { + + private LayerUI_Manager m_LayerUI_Manager; + + void Awake() + { + m_LayerUI_Manager = GetComponent(); + } + + public override void GotoPage(int iIndex) + { + m_LayerUI_Manager.GotoPage(iIndex); + } + + public override void AdvancePage(int iAmount) + { + m_LayerUI_Manager.AdvancePage(iAmount); + } + } +} diff --git a/Assets/Scripts/GUI/LayersPanel.cs.meta b/Assets/Scripts/GUI/LayersPanel.cs.meta new file mode 100644 index 0000000000..e5c1299a19 --- /dev/null +++ b/Assets/Scripts/GUI/LayersPanel.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3707fbc432bd4875bb62411d9cb5dc60 +timeCreated: 1714469355 \ No newline at end of file diff --git a/Assets/Scripts/Layers/AddLayerButton.cs b/Assets/Scripts/Layers/AddLayerButton.cs index f2613348d3..7bf74ea97c 100644 --- a/Assets/Scripts/Layers/AddLayerButton.cs +++ b/Assets/Scripts/Layers/AddLayerButton.cs @@ -21,7 +21,6 @@ public class AddLayerButton : BaseButton protected override void OnButtonPressed() { var UiManager = GetComponentInParent(); - if (App.Scene.LayerCanvases.Count() >= UiManager.m_Widgets.Count) return; base.OnButtonPressed(); UiManager.AddLayer(); } diff --git a/Assets/Scripts/Layers/FocusLayerButton.cs b/Assets/Scripts/Layers/FocusLayerButton.cs index daff8747e9..59f65ef77e 100644 --- a/Assets/Scripts/Layers/FocusLayerButton.cs +++ b/Assets/Scripts/Layers/FocusLayerButton.cs @@ -36,6 +36,7 @@ protected override void OnButtonPressed() public void SyncButtonStateWithWidget(GameObject activeLayerWidget) { + if (activeLayerWidget == null) return; SetButtonActivation(activeLayerWidget == transform.parent.gameObject); } diff --git a/Assets/Scripts/Layers/LayerUI_Manager.cs b/Assets/Scripts/Layers/LayerUI_Manager.cs index 6ccc5b36e1..d7664f3417 100644 --- a/Assets/Scripts/Layers/LayerUI_Manager.cs +++ b/Assets/Scripts/Layers/LayerUI_Manager.cs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -26,47 +27,67 @@ public class LayerUI_Manager : MonoBehaviour [SerializeField] private LocalizedString m_MainLayerName; [SerializeField] private LocalizedString m_AdditionalLayerName; + [SerializeField] private NavButton m_PreviousPageButton; + [SerializeField] private NavButton m_NextPageButton; public List m_Widgets; private List m_Canvases; + private int m_StartingCanvasIndex; + private bool m_RefreshNavButtons; + + private int WidgetsPerPage => m_Widgets.Count; + private int LastPageIndex => (m_Canvases.Count + WidgetsPerPage - 1) / WidgetsPerPage - 1; + private int CurrentPageIndex => m_StartingCanvasIndex / WidgetsPerPage; private void Start() { + m_StartingCanvasIndex = 0; ResetUI(); + m_RefreshNavButtons = true; } private void ResetUI() { - m_Canvases = new List(); - var canvases = App.Scene.LayerCanvases.ToArray(); + m_Canvases = App.Scene.LayerCanvases.ToList(); + for (int i = 0; i < m_Widgets.Count; i++) { var widget = m_Widgets[i]; - if (i >= canvases.Length) + int canvasIndex = i + m_StartingCanvasIndex; + if (canvasIndex >= m_Canvases.Count) { widget.SetActive(false); continue; } widget.SetActive(true); - var canvas = canvases[i]; - widget.GetComponentInChildren().text = canvas.name; - if (i == 0) - { - widget.GetComponentInChildren().text = $"{m_MainLayerName.GetLocalizedStringAsync().Result}"; - widget.GetComponentInChildren()?.gameObject.SetActive(false); - widget.GetComponentInChildren()?.gameObject.SetActive(false); - widget.GetComponentInChildren()?.gameObject.SetActive(false); - widget.GetComponentInChildren()?.gameObject.SetActive(false); - } - widget.GetComponentInChildren().SetButtonActivation(canvas == App.ActiveCanvas); - widget.GetComponentInChildren().SetButtonActivation(canvas == App.ActiveCanvas); + + var canvas = m_Canvases[canvasIndex]; + + string layerName = canvasIndex > 0 ? canvas.name : $"{m_MainLayerName.GetLocalizedStringAsync().Result}"; + widget.GetComponentInChildren().text = layerName; + // Active button means hidden layer widget.GetComponentInChildren().SetButtonActivation(!canvas.isActiveAndEnabled); + widget.GetComponentInChildren().SetButtonActivation(canvas == App.ActiveCanvas); + + widget.GetComponentInChildren(includeInactive: true).gameObject.SetActive(canvasIndex != 0); + widget.GetComponentInChildren(includeInactive: true).gameObject.SetActive(canvasIndex != 0); + foreach (var btn in widget.GetComponentsInChildren()) { - btn.m_CommandParam = i; + btn.m_CommandParam = canvasIndex; } - m_Canvases.Add(canvas); + } + } + + private void LateUpdate() + { + if (m_RefreshNavButtons) + { + // Can't do this in RefreshUI because the it doesn't take effect if the button is being interacted with + m_PreviousPageButton.SetButtonAvailable(CurrentPageIndex > 0); + m_NextPageButton.SetButtonAvailable(CurrentPageIndex < LastPageIndex); + m_RefreshNavButtons = false; } } @@ -130,18 +151,19 @@ public void SetActiveLayer(GameObject widget) private void ActiveSceneChanged(CanvasScript prev, CanvasScript current) { - onActiveSceneChanged?.Invoke(GetWidgetFromCanvas(current)); + int canvasIndex = m_Canvases.IndexOf(current); + int widgetIndex = canvasIndex - m_StartingCanvasIndex; + if (widgetIndex > 0 && widgetIndex < m_Widgets.Count) + { + onActiveSceneChanged?.Invoke(m_Widgets[widgetIndex]); + } + var desiredPageIndex = canvasIndex / WidgetsPerPage; + GotoPage(desiredPageIndex); } private CanvasScript GetCanvasFromWidget(GameObject widget) { - return m_Canvases[m_Widgets.IndexOf(widget)]; - } - - private GameObject GetWidgetFromCanvas(CanvasScript canvas) - { - var index = m_Canvases.IndexOf(canvas); - return index >= 0 ? m_Widgets[index] : null; + return m_Canvases[m_Widgets.IndexOf(widget) + m_StartingCanvasIndex]; } public void HandleCopySelectionToCurrentLayer() @@ -163,5 +185,17 @@ public void HandleMoveSelectionToCurrentLayer() ) ); } + + public void GotoPage(int iIndex) + { + m_StartingCanvasIndex = Mathf.Clamp(iIndex, 0, LastPageIndex) * WidgetsPerPage; + ResetUI(); + m_RefreshNavButtons = true; + } + + public void AdvancePage(int iAmount) + { + GotoPage(CurrentPageIndex + iAmount); + } } }