1234567891011121314151617181920212223 |
- using UnityEngine;
- using System.Collections;
- /// <summary>
- /// This component is used by the loading background sperms. They despawn when they go out of screen.
- /// </summary>
- public class DespawnWhenOutOfScreen : MonoBehaviour
- {
- PoolObject _poolObject;
- void Awake()
- {
- _poolObject = GetComponent<PoolObject>();
- }
- void Update()
- {
- if (transform.localPosition.x > GameConstants.GAME_WIDTH)
- {
- _poolObject.Despawn();
- }
- }
- }
|