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
33 lines
1.2 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using CodeMonkey.Utils;
|
|
|
|
public class WindowQuest_Pointer : MonoBehaviour
|
|
{
|
|
private Vector3 targetPosition;
|
|
public GameObject target_;
|
|
private Transform pointerRecTransform;
|
|
// Start is called before the first frame update
|
|
private void Awake()
|
|
{
|
|
targetPosition = target_.transform.position;
|
|
pointerRecTransform = transform.Find("Pointer").GetComponent<Transform>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
Vector3 toPosition = targetPosition;
|
|
Vector3 fromPostion = Camera.main.transform.position;
|
|
fromPostion.z = 0f;
|
|
Vector3 dir = (toPosition - fromPostion).normalized;
|
|
float angle= UtilsClass.GetAngleFromVector(dir);
|
|
pointerRecTransform.localEulerAngles = new Vector3(0, 0, angle);
|
|
|
|
Vector3 targetPositionScreenPoint = Camera.main.WorldToScreenPoint(targetPosition);
|
|
bool isOffScreen = targetPositionScreenPoint.x >= Screen.width || targetPositionScreenPoint.y <= 0 || targetPositionScreenPoint.y <= 0 || targetPositionScreenPoint.y >= Screen.height;
|
|
Debug.Log(isOffScreen + " " + targetPositionScreenPoint);
|
|
|
|
}
|
|
}
|