| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | /************************************************************************* *  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<GameObject> mMeshObjectList = new List<GameObject>();        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;        }    }}
 |