using Unity.FPS.Game; using Unity.FPS.Gameplay; using UnityEngine; using UnityEngine.UI; namespace Unity.FPS.UI { public class StanceHUD : MonoBehaviour { [Tooltip("Image component for the stance sprites")] public Image StanceImage; [Tooltip("Sprite to display when standing")] public Sprite StandingSprite; [Tooltip("Sprite to display when crouching")] public Sprite CrouchingSprite; void Start() { PlayerCharacterController character = FindObjectOfType(); DebugUtility.HandleErrorIfNullFindObject(character, this); character.OnStanceChanged += OnStanceChanged; OnStanceChanged(character.IsCrouching); } void OnStanceChanged(bool crouched) { StanceImage.sprite = crouched ? CrouchingSprite : StandingSprite; } } }