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 TileObjectPool : MonoBehaviour
- {
- public static TileObjectPool mInstance = null;
- private List<GameObject> mTileObjectList = new List<GameObject>();
- 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;
- }
- }
- }
|