redDotBehaviour.cs 705 B

123456789101112131415161718192021222324252627
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using HQFPSWeapons;
  5. public class redDotBehaviour : MonoBehaviour
  6. {
  7. public Player player;
  8. public Material redDotMaterial;
  9. public weaponAttachmentsMgr attachmentsMgr;
  10. void Start()
  11. {
  12. player.Aim.AddStartListener(OnAimStart);
  13. player.Aim.AddStopListener(OnAimStop);
  14. }
  15. void Update() {
  16. redDotMaterial.color = new Color(redDotMaterial.color.r, redDotMaterial.color.g, redDotMaterial.color.b, attachmentsMgr.aimed);
  17. }
  18. void OnAimStart(){
  19. attachmentsMgr.focus(true);
  20. }
  21. void OnAimStop(){
  22. attachmentsMgr.focus(false);
  23. }
  24. }