using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 侦查地形时展示 侦查相机的位置 /// 该图标需要以地图左下角为锚点 地图尺寸和场景大小必须保持一致 不一致时 改变定位算法 /// public class CameraPosIcon : MonoBehaviour { RectTransform thisRect; Transform cameraTransform; // Start is called before the first frame update void Start() { thisRect = this.GetComponent(); cameraTransform = Camera.main.transform; } // Update is called once per frame void Update() { if (cameraTransform) { thisRect.anchoredPosition = new Vector2(cameraTransform.position.x, cameraTransform.position.z); } } }