using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using DG.Tweening; namespace BuildSystem { public class BuildTip : MonoBehaviour { public GameObject tipPrfab; public void ShowTip(string text="放置失败") { StartCoroutine(Show(text)); } IEnumerator Show(string text) { GameObject tip = Instantiate(tipPrfab, transform); tip.SetActive(true); tip.GetComponentInChildren().text = text; tip.transform.position = new Vector3(Screen.width / 2, 0, 0); tip.transform.DOMove(new Vector3(Screen.width / 2, Screen.height / 2, 0),2); yield return new WaitForSeconds(3); Destroy(tip); } } }