Files
Alex38Lyon 878ea46cac update
2025-06-03 12:00:47 +02:00

33 lines
961 B
C#

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 = FindFirstObjectByType<PlayerCharacterController>();
DebugUtility.HandleErrorIfNullFindObject<PlayerCharacterController, StanceHUD>(character, this);
character.OnStanceChanged += OnStanceChanged;
OnStanceChanged(character.IsCrouching);
}
void OnStanceChanged(bool crouched)
{
StanceImage.sprite = crouched ? CrouchingSprite : StandingSprite;
}
}
}