TaskPointIcon.cs 857 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class TaskPointIcon : MonoBehaviour
  7. {
  8. public Material mat;
  9. public Camera _Camera;
  10. public Transform quadT;
  11. public Transform root;
  12. private void Awake()
  13. {
  14. quadT = root.transform.Find("Quad");
  15. mat = quadT.GetComponent<MeshRenderer>().material;
  16. _Camera=Camera.main;
  17. }
  18. private void Update()
  19. {
  20. quadT.LookAt(_Camera.transform);
  21. float distance = Vector3.Distance(CameraManager.instance.mainCamera.transform.position, this.transform.position);
  22. root.transform.localScale = Vector3.one * distance / 20;
  23. }
  24. public void SetHeightLight(bool isHeightLight)
  25. {
  26. mat.SetColor("_Color",isHeightLight?new Color(1,1,1,1):new Color(1,1,1,0.5f));
  27. }
  28. }