Eyepatcher.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Eyepatcher : MonoBehaviour
  5. {
  6. // Start is called before the first frame update
  7. public bool blindLeftEye;
  8. public bool blindRightEye;
  9. GameObject leftEyeBlock;
  10. GameObject rightEyeBlock;
  11. public GameObject eyePatchBlock;
  12. void Start()
  13. {
  14. GameObject leftEyeAnchor = GameObject.Find("LeftEyeAnchor");
  15. GameObject rightEyeAnchor = GameObject.Find("RightEyeAnchor");
  16. leftEyeBlock = Instantiate(eyePatchBlock,leftEyeAnchor.transform);
  17. leftEyeBlock.transform.localPosition = new Vector3(0,0,0.5f);
  18. leftEyeBlock.layer = LayerMask.NameToLayer("LeftEye");
  19. rightEyeBlock = Instantiate(eyePatchBlock,rightEyeAnchor.transform);
  20. rightEyeBlock.transform.localPosition = new Vector3(0,0,0.5f);
  21. rightEyeBlock.layer = LayerMask.NameToLayer("RightEye");
  22. }
  23. // Update is called once per frame
  24. void Update()
  25. {
  26. if(blindLeftEye){
  27. leftEyeBlock.SetActive(true);
  28. }else{
  29. leftEyeBlock.SetActive(false);
  30. }
  31. if(blindRightEye){
  32. rightEyeBlock.SetActive(true);
  33. }else{
  34. rightEyeBlock.SetActive(false);
  35. }
  36. }
  37. }