コード例 #1
0
ファイル: ObjectPool.cs プロジェクト: TopKekstar/IAV
        /// <summary>
        /// Return the specified GameObject back to the ObjectPool.
        /// </summary>
        /// <param name="instantiatedObject">The GameObject to return to the pool.</param>
        /// <param name="originalInstanceID">The instance ID of the original GameObject.</param>
        private void DestroyLocal(GameObject instantiatedObject, int originalInstanceID)
        {
            // This GameObject may have a collider and that collider may be ignoring the collision with other colliders. Revert this setting because the object is going
            // back into the pool.
            Collider instantiatedObjectCollider;

            if ((instantiatedObjectCollider = Utility.GetComponentForType <Collider>(instantiatedObject)) != null)
            {
                LayerManager.RevertCollision(instantiatedObjectCollider);
            }
            instantiatedObject.SetActive(false);
            instantiatedObject.transform.parent = transform;

            Stack <GameObject> pool;

            if (m_GameObjectPool.TryGetValue(originalInstanceID, out pool))
            {
                pool.Push(instantiatedObject);
            }
            else
            {
                // The pool for this GameObject type doesn't exist yet so it has to be created.
                pool = new Stack <GameObject>();
                pool.Push(instantiatedObject);
                m_GameObjectPool.Add(originalInstanceID, pool);
            }

#if ENABLE_MULTIPLAYER
            // NetworkServer.Unspawn will pool the object on the clients through the ClientUnspawnHandler.
            if (isServer && m_NetworkSpawnedGameObjects.Contains(instantiatedObject))
            {
                NetworkServer.UnSpawn(instantiatedObject);
            }
#endif
        }
コード例 #2
0
ファイル: Health.cs プロジェクト: TopKekstar/IAV
        /// <summary>
        /// The object doesn't have any health or shield left and should be deactivated.
        /// </summary>
        private void Deactivate()
        {
            Collider objCollider;

            if ((objCollider = Utility.GetComponentForType <Collider>(m_GameObject)) != null)
            {
                LayerManager.RevertCollision(objCollider);
            }

            m_GameObject.SetActive(false);
        }
コード例 #3
0
ファイル: Destructable.cs プロジェクト: TopKekstar/IAV
 /// <summary>
 /// Revert any object collisions after the component is disabled.
 /// </summary>
 private void OnDisable()
 {
     LayerManager.RevertCollision(m_Collider);
 }