internal void WasDespawned()
 {
     CancelInvoke();
     IsSpawned = false;
     Despawned?.Invoke(this);
     BroadcastMessage("OnDespawned", SendMessageOptions.DontRequireReceiver);
 }
Beispiel #2
0
    private IEnumerator DieAsync()
    {
        Vector3     startScale = transform.localScale;
        const float duration   = 1;

        for (float time = 0; time < 1; time += Time.deltaTime)
        {
            float t = time / duration;
            transform.localScale = Vector3.Lerp(startScale, Vector3.zero, t);
            yield return(null);
        }

        Destroy(gameObject);
        Despawned?.Invoke();
        Destroy(gameObject);
    }
Beispiel #3
0
        /// <summary>
        /// 是否包含实例
        /// </summary>
        /// <param name="transform">实例对象</param>
        /// <returns>true包含</returns>
        public bool Contains(Transform transform)
        {
            if (PrefabGO == null)
            {
                Debug.LogError("预制体是空的");
            }

            bool contains;

            contains = Spawned.Contains(transform);
            if (contains)
            {
                return(true);
            }

            contains = Despawned.Contains(transform);
            if (contains)
            {
                return(true);
            }

            return(false);
        }
Beispiel #4
0
 /// <summary>
 /// Despawn a tree into the pool
 /// </summary>
 /// <param name="obj"></param>
 public void Despawn(GameObject obj)
 {
     Despawned?.Invoke();
     obj.SetActive(false);
     m_TreePool.Push(obj);
 }
Beispiel #5
0
 public void Despawn()
 {
     _despawnTimer?.Dispose();
     Despawned?.Invoke(this, null);
 }
Beispiel #6
0
 protected void OnDespawned()
 {
     Despawned.Raise();
 }
Beispiel #7
0
 public void Despawn()
 {
     gameObject.SetActive(false);
     Despawned?.Invoke();
 }