SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.2 KiB

4 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using CodeMonkey.Utils;
  5. public class WindowQuest_Pointer : MonoBehaviour
  6. {
  7. private Vector3 targetPosition;
  8. public GameObject target_;
  9. private Transform pointerRecTransform;
  10. // Start is called before the first frame update
  11. private void Awake()
  12. {
  13. targetPosition = target_.transform.position;
  14. pointerRecTransform = transform.Find("Pointer").GetComponent<Transform>();
  15. }
  16. // Update is called once per frame
  17. void Update()
  18. {
  19. Vector3 toPosition = targetPosition;
  20. Vector3 fromPostion = Camera.main.transform.position;
  21. fromPostion.z = 0f;
  22. Vector3 dir = (toPosition - fromPostion).normalized;
  23. float angle= UtilsClass.GetAngleFromVector(dir);
  24. pointerRecTransform.localEulerAngles = new Vector3(0, 0, angle);
  25. Vector3 targetPositionScreenPoint = Camera.main.WorldToScreenPoint(targetPosition);
  26. bool isOffScreen = targetPositionScreenPoint.x >= Screen.width || targetPositionScreenPoint.y <= 0 || targetPositionScreenPoint.y <= 0 || targetPositionScreenPoint.y >= Screen.height;
  27. Debug.Log(isOffScreen + " " + targetPositionScreenPoint);
  28. }
  29. }