From 6180ceae8099ab1128a99e81d5b33e565b931f62 Mon Sep 17 00:00:00 2001 From: Tore Bergebakken Date: Fri, 7 Jun 2024 23:41:25 +0200 Subject: [PATCH] Downscale HUD when only one local input --- Assets/Prefabs/Input/Player.prefab | 9 +++++---- Assets/Scripts/UI/PlayerHUDController.cs | 13 ++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Assets/Prefabs/Input/Player.prefab b/Assets/Prefabs/Input/Player.prefab index cfeb4eb87..b24523ebf 100644 --- a/Assets/Prefabs/Input/Player.prefab +++ b/Assets/Prefabs/Input/Player.prefab @@ -447,6 +447,7 @@ MonoBehaviour: maxRadius: 5 minRadius: 1 collisionOffset: 0.3 + lookSensitivity: 5 InputManager: {fileID: 0} --- !u!1 &345906872987025452 GameObject: @@ -1111,7 +1112,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 + m_ConstrainProportionsScale: 1 m_Children: - {fileID: 6629533919243205533} - {fileID: 8513528357214213258} @@ -1120,7 +1121,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 400, y: 225} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} --- !u!210 &4673711381798312254 @@ -1171,7 +1172,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -319.1, y: -165} + m_AnchoredPosition: {x: 80.9, y: 60} m_SizeDelta: {x: 150.42, y: 150} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &3455060718068446809 @@ -1541,7 +1542,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -203.1, y: -194.9} + m_AnchoredPosition: {x: 196.9, y: 30.1} m_SizeDelta: {x: 253.6, y: 60} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &1876285937171696916 diff --git a/Assets/Scripts/UI/PlayerHUDController.cs b/Assets/Scripts/UI/PlayerHUDController.cs index bc585600c..f49e29b79 100644 --- a/Assets/Scripts/UI/PlayerHUDController.cs +++ b/Assets/Scripts/UI/PlayerHUDController.cs @@ -127,25 +127,28 @@ void Start() ammoBar.material = ammoCapacityMaterial; ammoCapacityMaterial.SetFloat("_Arc2", 0); - healthBarScaleX = healthBar.transform.localScale.x; - healthBar.color = healthMax; - healthTextPosition = healthText.transform.localPosition; defaultCrosshairScale = crosshair.localScale; originalChipY = chipBox.anchoredPosition.y; - // Anchor to top right if there's only one player. - // This keeps the chip counter from conflicting with the timer if (!MatchController.Singleton || PlayerInputManagerController.Singleton.LocalPlayerInputs.Count() == 1) { + // Anchor to top right if there's only one player. + // This keeps the chip counter from conflicting with the timer chipBox.anchorMin = Vector2.one; chipBox.anchorMax = Vector2.one; originalChipX = -chipBox.sizeDelta.x / 2f - 10; + // Also scale down the health bar stuff + hudParent.localScale = .6f * Vector3.one; } else { originalChipX = 0; } chipBox.anchoredPosition = new Vector2(originalChipX, -originalChipY); + + healthBarScaleX = healthBar.transform.localScale.x; + healthBar.color = healthMax; + healthTextPosition = healthText.transform.localPosition; } public void SetSpeedLines(Vector3 velocity)