using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class UIMove : MonoBehaviour
{
public Transform _Camera;
public float speed = 0.5f;//速度
GameObject go;
void Start()
{
go = new GameObject();
go.transform.parent = _Camera;
go.transform.localPosition = new Vector3(0, 0, 1f);//预期位置
}
void FixedUpdate()
{
transform.position = Vector3.Lerp(transform.position, go.transform.position, speed * Time.deltaTime);
Quaternion q = Quaternion.identity;
q.SetLookRotation(_Camera.transform.forward, _Camera.transform.up);
gameObject.transform.rotation = q;
}
}
UI跟随相机(延迟并面向)
最新推荐文章于 2024-11-13 12:14:54 发布