Files
test/Assets/PerfectWorld/Scripts/_Doc/PrefabPoolManager .md
T
Tungdv df23868b40 feat: Add prefabs pooling manager.
fix: update spawn NPC.
2026-05-06 15:33:28 +07:00

23 lines
1002 B
Markdown

# 🤖 AI SYSTEM INSTRUCTION: PrefabPoolManager Usage Rules
## 1. System Context
- **Environment:** Unity 3D (C#)
- **Target Platform:** Mobile (Android, iOS) - Requires strict optimization.
- **Concept:** The project uses a centralized Object Pooling system called `PrefabPoolManager` (built on `UnityEngine.Pool.ObjectPool`).
- **AI Task:** When writing scripts that involve creating or destroying GameObjects, the AI **MUST** use this manager instead of Unity's default methods.
---
## 2. Available API (Do NOT implement this, just use it)
The `PrefabPoolManager` is a Singleton accessible via `PrefabPoolManager.Instance`. It provides the following methods:
```csharp
// Pre-warms a pool (Optional, used during loading)
public void InitPool(GameObject prefab, int defaultCapacity = 10, int maxSize = 50);
// Spawns an object from the pool
public GameObject Spawn(GameObject prefab, Vector3 position, Quaternion rotation);
// Returns an object to the pool
public void Despawn(GameObject obj);