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.

66 lines
1.4 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ZoneUI : MonoBehaviour
{
public Camera _camera;
public Transform target;
public Vector3 offset=Vector3.zero;
private Vector3 startScale;
public bool isScreen = true;
public bool isCameraDistance = false;
private float distanceScale;
Vector3 pos;
private void Start()
{
if (_camera == null)
{
_camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
}
startScale = transform.localScale;
}
public void Update()
{
if (isScreen)
{
if (isCameraDistance)
{
distanceScale = Vector3.Distance(_camera.transform.position, target.transform.position) * Level3Manager.Instance.KuangDistanceValue;
pos = _camera.WorldToScreenPoint(target.position);
this.transform.localScale = distanceScale * startScale;
}
else
{
pos = _camera.WorldToScreenPoint(target.position);
}
}
else
{
pos = target.position;
transform.localScale = startScale;
transform.LookAt(_camera.transform);
}
transform.position = pos + offset;
//transform.LookAt(_camera.transform);
}
}