Skip to main content

StaticEnvironmentPiece

A class in Root.Township, Alta.Static.

An asset for a non-networked environment piece, with its prefab and surface material. Instances are pooled and spawned by ID.

Constructors​

MemberWhat it is
StaticEnvironmentPiece()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

6 private and internal fields
MemberWhat it is
private bool btnChildInspector button. Holds no data.
private SurfaceMaterial materialBacking field for Material.
private static Dictionary<uint, StaticEnvironmentPiece> pieceMapStatic cache of pieces by index, filled by Load and Spawn.
private static Transform pooledParentShared do-not-destroy transform that new instances are created under.
private StaticEnvironmentPieceInstance prefabBacking field for Prefab.
private Stack<StaticEnvironmentPieceInstance> stackPool of released instances waiting to be reused.

Properties​

MemberWhat it is
SurfaceMaterial Material { get; }The piece's surface material, for impacts and sounds.
StaticEnvironmentPieceInstance Prefab { get; }The instance prefab spawned for this piece.

Methods​

MemberWhat it is
static StaticEnvironmentPiece Load(uint id)Gets the piece with this ID, loading it from Resources/StaticEnvironmentPiece the first time.
void SetPrefab(StaticEnvironmentPieceInstance prefab)Editor: sets the prefab.
StaticEnvironmentPieceInstance Spawn(Vector3 position, Quaternion rotation, Vector3 scale)Places an instance at the given position, rotation and scale, reusing a released one if there is one.
1 private and internal method
MemberWhat it is
private void Alta.Static.IStaticEnvironmentPiecePool.Release(StaticEnvironmentPieceInstance instance)Explicit IStaticEnvironmentPiecePool method: returns an instance to this piece's pool for reuse by Spawn.

Used in​

Members of other types that take, return or hold a StaticEnvironmentPiece: