diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index c5af1be..7de18fa 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -148,7 +148,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 132613872} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -12.6, y: 0, z: 0} + m_LocalPosition: {x: -15, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -171,8 +171,8 @@ EdgeCollider2D: m_Offset: {x: 0, y: 0} m_EdgeRadius: 0 m_Points: - - {x: 0, y: 21} - - {x: 0, y: -21} + - {x: 0, y: 30} + - {x: 0, y: -30} m_AdjacentStartPoint: {x: 0, y: 0} m_AdjacentEndPoint: {x: 0, y: 0} m_UseAdjacentStartPoint: 0 @@ -299,6 +299,14 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 948416251} m_Modifications: + - target: {fileID: 786906420117163282, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} + propertyPath: m_Points.Array.data[0].x + value: -15 + objectReference: {fileID: 0} + - target: {fileID: 786906420117163282, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} + propertyPath: m_Points.Array.data[1].x + value: 15 + objectReference: {fileID: 0} - target: {fileID: 786906420117163283, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: side value: 1 @@ -317,7 +325,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 786906420117163285, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_LocalPosition.y - value: -21 + value: -30 objectReference: {fileID: 0} - target: {fileID: 786906420117163285, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_LocalPosition.z @@ -357,7 +365,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3154833278331422328, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_Positions.Array.data[0].x - value: -12.6 + value: -15 objectReference: {fileID: 0} - target: {fileID: 3154833278331422328, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_Positions.Array.data[0].y @@ -365,7 +373,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3154833278331422328, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_Positions.Array.data[1].x - value: 12.6 + value: 15 objectReference: {fileID: 0} - target: {fileID: 3154833278331422328, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_Positions.Array.data[1].y @@ -446,7 +454,7 @@ SpriteRenderer: m_FlipX: 0 m_FlipY: 0 m_DrawMode: 2 - m_Size: {x: 42, y: 25.2} + m_Size: {x: 60, y: 30} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 m_WasSpriteAssigned: 1 @@ -640,7 +648,7 @@ SpriteRenderer: m_FlipX: 0 m_FlipY: 0 m_DrawMode: 2 - m_Size: {x: 36, y: 42} + m_Size: {x: 35.121952, y: 60} m_AdaptiveModeThreshold: 0.5 m_SpriteTileMode: 0 m_WasSpriteAssigned: 1 @@ -714,9 +722,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 572c5b8dd6a94b3585befaa50a883755, type: 3} m_Name: m_EditorClassIdentifier: - panelHeightPercentage: 15 - emptySpacePercentage: 5 - playGroundAspect: 0.6 + updateOnce: 1 + panelHeightPixels: 250 + playGroundSize: {x: 30, y: 60} + emptySpaceHeight: 3 mainCamera: {fileID: 1698696476} topC: {fileID: 1166615027} bottomC: {fileID: 238423618} @@ -726,12 +735,12 @@ MonoBehaviour: playerPanelTop: {fileID: 738870617} playerPanelBottom: {fileID: 2108734120} background: {fileID: 712762093} - top: 21 - bottom: -21 - left: -12.6 - right: 12.6 - boardTop: 18.9 - boardBottom: -18.9 + top: 30 + bottom: -30 + left: -15 + right: 15 + boardTop: 27 + boardBottom: -27 --- !u!1001 &1166615026 PrefabInstance: m_ObjectHideFlags: 0 @@ -739,6 +748,14 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 948416251} m_Modifications: + - target: {fileID: 786906420117163282, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} + propertyPath: m_Points.Array.data[0].x + value: -15 + objectReference: {fileID: 0} + - target: {fileID: 786906420117163282, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} + propertyPath: m_Points.Array.data[1].x + value: 15 + objectReference: {fileID: 0} - target: {fileID: 786906420117163284, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_Name value: TopGate @@ -753,7 +770,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 786906420117163285, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_LocalPosition.y - value: 21 + value: 30 objectReference: {fileID: 0} - target: {fileID: 786906420117163285, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_LocalPosition.z @@ -793,7 +810,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3154833278331422328, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_Positions.Array.data[0].x - value: -12.6 + value: -15 objectReference: {fileID: 0} - target: {fileID: 3154833278331422328, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_Positions.Array.data[0].y @@ -801,7 +818,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3154833278331422328, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_Positions.Array.data[1].x - value: 12.6 + value: 15 objectReference: {fileID: 0} - target: {fileID: 3154833278331422328, guid: 00ae6168f2c5cea79ba751265a06d0ae, type: 3} propertyPath: m_Positions.Array.data[1].y @@ -852,7 +869,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1462314553} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 12.6, y: 0, z: 0} + m_LocalPosition: {x: 15, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -875,8 +892,8 @@ EdgeCollider2D: m_Offset: {x: 0, y: 0} m_EdgeRadius: 0 m_Points: - - {x: 0, y: 21} - - {x: 0, y: -21} + - {x: 0, y: 30} + - {x: 0, y: -30} m_AdjacentStartPoint: {x: 0, y: 0} m_AdjacentEndPoint: {x: 0, y: 0} m_UseAdjacentStartPoint: 0 @@ -926,7 +943,7 @@ Camera: far clip plane: 1000 field of view: 60 orthographic: 1 - orthographic size: 30 + orthographic size: 36.09756 m_Depth: 0 m_CullingMask: serializedVersion: 2 @@ -981,7 +998,7 @@ MonoBehaviour: m_VolumeTrigger: {fileID: 0} m_VolumeFrameworkUpdateModeOption: 2 m_RenderPostProcessing: 1 - m_Antialiasing: 0 + m_Antialiasing: 1 m_AntialiasingQuality: 2 m_StopNaN: 0 m_Dithering: 0 @@ -999,11 +1016,11 @@ PrefabInstance: m_Modifications: - target: {fileID: 4540566536649322900, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Size.x - value: 36 + value: 35.121952 objectReference: {fileID: 0} - target: {fileID: 4540566536649322900, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Size.y - value: 9 + value: 6.097561 objectReference: {fileID: 0} - target: {fileID: 4540566536649322901, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Name @@ -1019,7 +1036,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4540566536649322903, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_LocalPosition.y - value: -25.5 + value: -33.048782 objectReference: {fileID: 0} - target: {fileID: 4540566536649322903, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_LocalPosition.z @@ -1138,11 +1155,11 @@ PrefabInstance: m_Modifications: - target: {fileID: 4540566536649322900, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Size.x - value: 36 + value: 35.121952 objectReference: {fileID: 0} - target: {fileID: 4540566536649322900, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Size.y - value: 9 + value: 6.097561 objectReference: {fileID: 0} - target: {fileID: 4540566536649322901, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_Name @@ -1158,7 +1175,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4540566536649322903, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_LocalPosition.y - value: 25.5 + value: 33.048782 objectReference: {fileID: 0} - target: {fileID: 4540566536649322903, guid: b4033513367475439bfcd048b5d376a6, type: 3} propertyPath: m_LocalPosition.z diff --git a/Assets/Scripts/Dimensions.cs b/Assets/Scripts/Dimensions.cs index a0e34d0..df461df 100644 --- a/Assets/Scripts/Dimensions.cs +++ b/Assets/Scripts/Dimensions.cs @@ -1,14 +1,20 @@ using System; using UnityEngine; +using UnityEngine.Serialization; +[ExecuteInEditMode] public class Dimensions : MonoBehaviour { - [Tooltip("How much height for player panels")] - public float panelHeightPercentage; - [Tooltip("How much height is the empty space between board and death zone")] - public float emptySpacePercentage; - [Tooltip("Aspect ratio of the playground")] - public float playGroundAspect; + [Tooltip("Player panels height")] + public float panelHeightPixels; + + [Tooltip("Size in Unity units")] + public Vector2 playGroundSize; + + [Tooltip("Height of the empty space between board and death zone")] + public float emptySpaceHeight; + + public Camera mainCamera; public EdgeCollider2D topC, bottomC, leftC, rightC; public SpriteRenderer playGround; @@ -20,10 +26,7 @@ public class Dimensions : MonoBehaviour { private void Awake() { Singleton = this; GetComponents(); - } - - private void OnValidate() { - GetComponents(); + SetDimensions(); } private void GetComponents() { @@ -39,17 +42,10 @@ public class Dimensions : MonoBehaviour { private LineRenderer topL, bottomL; - private void Update() { - float height = mainCamera.orthographicSize * 2; - float allWidth = mainCamera.aspect * height; - float panelHeight = height * panelHeightPercentage / 100f; - float playGroundHeight = height - 2 * panelHeight; - float playGroundWidth = playGroundHeight * playGroundAspect; - float emptySpaceHeight = playGroundHeight * emptySpacePercentage / 100f; - - top = playGroundHeight / 2; + private void SetDimensions() { + top = playGroundSize.y / 2; bottom = -top; - right = playGroundWidth / 2; + right = playGroundSize.x / 2; left = -right; boardTop = top - emptySpaceHeight; @@ -68,8 +64,10 @@ public class Dimensions : MonoBehaviour { bottomC.points = new[] {v1, v2}; leftC.points = new[] {v3, v4}; rightC.points = new[] {v3, v4}; - - + + playGround.transform.rotation = Quaternion.Euler(0, 0, 90); + playGround.size = new Vector2(playGroundSize.y, playGroundSize.x); + const float lineWidth = 0.5f; Vector3 offset = Vector3.up * lineWidth / 2; @@ -78,15 +76,24 @@ public class Dimensions : MonoBehaviour { topL.SetPositions(v12); v12 = new[] {(Vector3) v1 + offset, (Vector3) v2 + offset}; bottomL.SetPositions(v12); - - playGround.transform.rotation = Quaternion.Euler(0, 0, 90); - playGround.size = new Vector2(playGroundHeight, playGroundWidth); + + mainCamera.orthographicSize = 0.5f / (1 - 2 * panelHeightPixels / mainCamera.pixelHeight) * playGroundSize.y; + float height = mainCamera.orthographicSize * 2; + float width = mainCamera.aspect * height; + float panelHeight = (height - playGroundSize.y) / 2; playerPanelTop.transform.position = new Vector2(0, (height + Height) / 4); playerPanelBottom.transform.position = new Vector2(0, -(height + Height) / 4); - playerPanelTop.size = playerPanelBottom.size = new Vector2(allWidth, panelHeight); + playerPanelTop.size = playerPanelBottom.size = new Vector2(width, panelHeight); - background.size = new Vector2(allWidth, playGroundHeight); + background.size = new Vector2(width, playGroundSize.y); + } + + private void Update() { + if (Application.isPlaying) + return; + + SetDimensions(); } } diff --git a/Assets/Scripts/GameUI.cs b/Assets/Scripts/GameUI.cs index 0db1e40..5e250c4 100644 --- a/Assets/Scripts/GameUI.cs +++ b/Assets/Scripts/GameUI.cs @@ -47,8 +47,8 @@ public class GameUI : MonoBehaviour { } private void PreparePlayerPanels() { - float heightPercentage = Dimensions.Singleton.panelHeightPercentage; - PlayerPanel(Side.Top).style.height = PlayerPanel(Side.Bottom).style.height = Length.Percent(heightPercentage); + float pixelHeight = Dimensions.Singleton.panelHeightPixels; + PlayerPanel(Side.Top).style.height = PlayerPanel(Side.Bottom).style.height = new Length(pixelHeight, LengthUnit.Pixel); SetupGoButton(Side.Top, "left"); SetupGoButton(Side.Top, "right"); diff --git a/Assets/UI Toolkit/player_panel.uss b/Assets/UI Toolkit/player_panel.uss index 1da1227..0dc0b1c 100644 --- a/Assets/UI Toolkit/player_panel.uss +++ b/Assets/UI Toolkit/player_panel.uss @@ -1,6 +1,5 @@ .go { flex-shrink: 1; - width: auto; font-size: 50px; -unity-text-align: middle-center; border-left-color: rgb(141, 157, 255); @@ -11,10 +10,10 @@ border-right-width: 3px; border-top-width: 3px; border-bottom-width: 3px; - border-top-left-radius: 5px; - border-bottom-left-radius: 5px; - border-top-right-radius: 5px; - border-bottom-right-radius: 5px; + border-top-left-radius: 15px; + border-bottom-left-radius: 15px; + border-top-right-radius: 15px; + border-bottom-right-radius: 15px; margin-left: 10px; margin-right: 10px; margin-top: 10px; diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index ffcf985..c82dce5 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -167,7 +167,7 @@ PlayerSettings: iPhone: 0 tvOS: 0 overrideDefaultApplicationIdentifier: 0 - AndroidBundleVersionCode: 4 + AndroidBundleVersionCode: 5 AndroidMinSdkVersion: 22 AndroidTargetSdkVersion: 33 AndroidPreferredInstallLocation: 1 diff --git a/README.md b/README.md index b7a4eb9..9444864 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ - Collectables: - NewBall - Wormhole -- Ball delayed Spawn with direction indicator - Border visuals - Ball visuals