两个页面接入完成

This commit is contained in:
2026-05-19 22:40:52 +08:00
parent 3daebf56ab
commit 369783939b
32 changed files with 1165 additions and 590 deletions

View File

@@ -0,0 +1,37 @@
using UnityEngine;
using System.Collections.Generic;
public class GameObjectPool : MonoBehaviour
{
[Tooltip("预制体")] public GameObject prefab;
[Tooltip("初始预加载数量")] public int preload = 10;
private Stack<GameObject> _pool = new();
public Transform parent;
private void Start()
{
for (var i = 0; i < preload; i++)
{
var go = Instantiate(prefab, transform);
go.SetActive(false);
_pool.Push(go);
}
}
public GameObject Get()
{
var go = _pool.Count > 0 ? _pool.Pop() : Instantiate(prefab, parent);
go.transform.parent = parent;
go.SetActive(true);
return go;
}
public void Release(GameObject go)
{
if (go == null) return;
go.SetActive(false);
go.transform.SetParent(transform, false);
_pool.Push(go);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1970feb7fdb702645b753cd8ed1be4ea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: