/************************************************************************* * 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 MeshPool : MonoBehaviour { public static MeshPool mInstance = null; private List mMeshObjectList = new List(); private int mCreateMeshCount = 0; void Awake() { mInstance = this; } public void PushMeshObject(GameObject tileObj) { tileObj.SetActive(false); mMeshObjectList.Add(tileObj); tileObj.transform.parent = transform; } public GameObject GetMeshObject() { if (mMeshObjectList.Count > 0) { GameObject targetObj = mMeshObjectList[0]; mMeshObjectList.RemoveAt(0); return targetObj; } mCreateMeshCount++; return null; } } }