UGUI跟随物体移动缩放
最近有个需求,要实现UI跟随着建筑移动和缩放,类似于下面这个效果

做法很简单,创建一个canvas,设置canvas的旋转和主摄像机一样,Render Mode 为 World Space

然后挂个脚本,设置UI的位置即可
using Lean.Touch; using System.Collections; using System.Collections.Generic; using UnityEngine; public class txtTest : MonoBehaviour { public Transform tsf; //3D位置 public Transform txtTsf; //UI位置 void Start() { txtTsf.transform.position = tsf.position; } }
浙公网安备 33010602011771号