Skip to main content

StaticEnvironmentPieceInstance

A class in Root.Township, Alta.Static.

A pooled copy of a static environment piece (rock, plant and so on) placed by world generation. It's the result of a spawn instruction, so undoing the instruction sends it back to the pool.

Constructors​

MemberWhat it is
StaticEnvironmentPieceInstance()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

3 private and internal fields
MemberWhat it is
private GameObject gameObjectCached GameObject, set in Initialize so later calls skip the Unity property.
private StaticEnvironmentPiece pieceThe StaticEnvironmentPiece definition this instance came from; Release returns the instance to its pool.
private Transform transformCached Transform, set in Initialize and used by MoveAndEnable and SetScale.

Properties​

MemberWhat it is
SurfaceMaterial Material { get; }Surface material of the piece, for sounds and effects.

Events​

MemberWhat it is
event Action ReleasedEvent declared for when the instance is released; not raised in this class.

Methods​

MemberWhat it is
StaticEnvironmentPiece CreatePiece()Returns the piece definition, logging an error if it's missing.
void Initialize(StaticEnvironmentPiece piece)Binds the instance to its piece definition.
void MoveAndEnable(Vector3 position, Quaternion rotation, Vector3 scale)Places, scales and turns on the instance.
virtual void Release()Turns the instance off and returns it to the piece's pool.
void SetScale(Vector3 scale)Sets the instance's scale.
protected virtual void OnValidate()Editor hook. Empty here.
1 private and internal method
MemberWhat it is
private void Alta.Static.IInstructionResult.Undo()Explicit IInstructionResult implementation: undoing the placement just calls Release.

Used in​

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