using System.Collections; using System.Collections.Generic; using UnityEngine; public abstract class FollowerBase : MonoBehaviour { [SerializeField] private float followTime = 2; private Coroutine followCoroutine; public abstract void SetTransform(Transform transform); protected virtual void OnEnable() { followCoroutine = StartCoroutine(Following(followTime)); } protected virtual void OnDisable() { if (followCoroutine != null) { StopCoroutine(followCoroutine); } } IEnumerator Following(float time) { while (true) { yield return new WaitForSeconds(time); yield return null; if (SvrManager.Instance && SvrManager.Instance.IsRunning) { Follow(); } } } protected abstract void Follow(); }