2021년 4학년 1학기 기업연계프로젝트2 컴퓨터소프트웨어공학과 <원광투어팀> 팀장 : 송유진 팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
956 B

5 years ago
  1. using Unity.FPS.Game;
  2. using Unity.FPS.Gameplay;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace Unity.FPS.UI
  6. {
  7. public class StanceHUD : MonoBehaviour
  8. {
  9. [Tooltip("Image component for the stance sprites")]
  10. public Image StanceImage;
  11. [Tooltip("Sprite to display when standing")]
  12. public Sprite StandingSprite;
  13. [Tooltip("Sprite to display when crouching")]
  14. public Sprite CrouchingSprite;
  15. void Start()
  16. {
  17. PlayerCharacterController character = FindObjectOfType<PlayerCharacterController>();
  18. DebugUtility.HandleErrorIfNullFindObject<PlayerCharacterController, StanceHUD>(character, this);
  19. character.OnStanceChanged += OnStanceChanged;
  20. OnStanceChanged(character.IsCrouching);
  21. }
  22. void OnStanceChanged(bool crouched)
  23. {
  24. StanceImage.sprite = crouched ? CrouchingSprite : StandingSprite;
  25. }
  26. }
  27. }