示例代码:
using UnityEngine; public class Skode_Test : MonoBehaviour { public GameObject cube; public float speed = 1; void Update () { transform.RotateAround(cube.transform.position, new Vector3(0, 1, 0), speed); } private void OnBecameVisible() { print("摄像机视野内"); } private void OnBecameInvisible() { print("在摄像机视野外"); } }
效果展示: