A class in Root.Township, the global namespace.
Simple pool of plain (non-networked) prefab instances, keyed by prefab. Used by forest fill to place and recycle objects.
Constructors
| Member | What it is |
|---|
InstancedPrefab() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
3 private and internal fields
| Member | What it is |
|---|
private GameObject gameObject | Cached game object. |
private static Dictionary<GameObject, Stack<InstancedPrefab>> instances | Static pools of free instances per prefab. |
private Transform transform | Cached transform. |
Properties
| Member | What it is |
|---|
GameObject Prefab { get; private set; } | The prefab this instance came from, used as its pool key. |
Methods
| Member | What it is |
|---|
void Disable() | Hides the instance and pushes it back onto its prefab's pool. |
static InstancedPrefab Get(InstancedPrefab prefab) | Pops a pooled instance of the prefab, or creates one (adding the component if needed). It comes back inactive or as instantiated. |
static InstancedPrefab Get(GameObject prefab) | Pops a pooled instance of the prefab, or creates one (adding the component if needed). It comes back inactive or as instantiated. |
void Initialize(GameObject prefab) | Stores the source prefab and caches the transform and game object. |
void MoveAndEnable(Vector3 position, Quaternion rotation, Vector3 scale) | Sets position, rotation and scale, then activates the instance. |
Used in
Members of other types that take, return or hold a InstancedPrefab: