using System; using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 特效基类 /// public abstract class Effect : MonoBehaviour { public Transform followTarget; public bool isFollow = false; public void ChangeEffectPos(Vector3 pos) { isFollow = false; followTarget = null; transform.position = pos; } public void ChangeEffectPos(Transform transform) { followTarget = transform; if (followTarget) { isFollow = true; } } private void Update() { if (isFollow && Camera.main.WorldToScreenPoint(followTarget.position).z>=0) { transform.position = Camera.main.WorldToScreenPoint(followTarget.position); } } }