PathSign.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using Unity.Mathematics;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class PathSign : MonoBehaviour
  7. {
  8. public GameObject bindObj;
  9. public Vector3 bindPos;
  10. // Update is called once per frame
  11. void LateUpdate()
  12. {
  13. if (bindObj != null)
  14. {
  15. this.GetComponent<RectTransform>().anchoredPosition = CameraManager.instance.secondCamera.WorldToScreenPoint(bindPos) / Screen.width * 1920.0f;
  16. float alpha = this.GetComponent<RectTransform>().anchoredPosition.y < 1000 ? 1 : (1 - (this.GetComponent<RectTransform>().anchoredPosition.y - 1000) / 16);
  17. this.GetComponent<Image>().color = new Color(1, 1, 1, alpha);
  18. float dyScale = 72 / CameraManager.instance.secondCamera.GetComponent<CameraBirdSec>().currentDistance;
  19. dyScale = math.clamp(dyScale, 1, 4);
  20. this.transform.localScale = new Vector3(dyScale, dyScale, dyScale);
  21. if (!bindObj.activeSelf || !bindObj.transform.parent.gameObject.activeSelf || !bindObj.transform.parent.parent.gameObject.activeSelf)
  22. {
  23. this.GetComponent<Image>().enabled = false;
  24. }
  25. else {
  26. this.GetComponent<Image>().enabled = true;
  27. }
  28. }
  29. }
  30. }