using System.Collections; using System.Collections.Generic; using UnityEngine; public class ToolTipsController : MonoBehaviour { public Camera mainCamera; private TextMesh tipsText; public bool isActive; public void Awake() { mainCamera = Camera.main; if (mainCamera == null) { mainCamera = GameObject.FindObjectOfType(); } tipsText = this.transform.GetComponentInChildren(); } private void Update() { if (!isActive) return; Vector3 dir = (mainCamera.transform.position - this.transform.position).normalized; this.transform.forward = new Vector3(dir.x, 0, dir.z); } public void Active() { isActive = true; tipsText.gameObject.SetActive(true); } public void DisActive() { isActive = false; tipsText.gameObject.SetActive(false); } public void ResetInfo(string tips, Transform targetPos) { this.transform.position = targetPos.transform.position; tipsText.text = tips; } }