/************************************************************************* * Copyright © 2018-2023 Liwen All rights reserved. *------------------------------------------------------------------------ * File : TileObjectPool.cs * Description : PagedLod tile object pool. *------------------------------------------------------------------------ * Author : Liwen * Version : 1.0.0 * Date : 1/5/2019 * Description : Initial development version. *************************************************************************/ using System.Collections; using System.Collections.Generic; using UnityEngine; namespace AIPagedLod { public class TileObjectPool : MonoBehaviour { public static TileObjectPool mInstance = null; private List mTileObjectList = new List(); private int mCreateTileCount = 0; void Awake() { mInstance = this; } public void PushTileObject(GameObject tileObj) { tileObj.SetActive(false); mTileObjectList.Add(tileObj); tileObj.transform.parent = transform; } public GameObject GetTileObject() { if (mTileObjectList.Count > 0) { GameObject targetObj = mTileObjectList[0]; mTileObjectList.RemoveAt(0); return targetObj; } mCreateTileCount++; return null; } } }