update
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user