PathSign.cs 1.1 KB

12345678910111213141516171819202122232425262728293031
  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 dyScale = 72 / CameraManager.instance.secondCamera.GetComponent<CameraBirdSec>().currentDistance;
  17. dyScale = math.clamp(dyScale, 1, 6);
  18. this.transform.localScale = new Vector3(dyScale, dyScale, dyScale);
  19. if (!bindObj.activeSelf || !bindObj.transform.parent.gameObject.activeSelf || !bindObj.transform.parent.parent.gameObject.activeSelf)
  20. {
  21. this.GetComponent<Image>().enabled = false;
  22. }
  23. else {
  24. this.GetComponent<Image>().enabled = true;
  25. }
  26. }
  27. }
  28. }