Skip to main content

ScaleLerpPooledObject

A class in Root.Township, the global namespace.

A pooled object that grows from tiny to its start size when taken from the pool and shrinks away before it goes back. Client-side visual effect.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private float fadeSpeedLerp speed for growing and shrinking. Default 0.05.
private LerpingFloatValue scaleLerping value that drives the uniform local scale.
private float startSizeScale it grows to when requested. Default 1.
private IUnityUpdateMethod updateRegistered update method that steps the scale lerp, or null when idle.

Properties​

MemberWhat it is
protected virtual bool IsAlwaysUpdating { get; }When true, subclasses keep UpdateLerp registered themselves, so this class does not register or deregister it. False by default.
protected bool IsReleasing { get; private set; }True while the object is shrinking on its way back to the pool.

Methods​

MemberWhat it is
override void Release()Unparents the object and starts shrinking it. The real pool release happens in FadeFinished once the shrink ends.
protected virtual void Awake()Sets up the scale lerp, snaps the scale to 0.01 and hooks the grow animation to the pool's Requested event.
protected virtual void FadeFinished()Called when the shrink finishes. Stops updating and returns the object to the pool.
protected void Lerp(float target, float speed)Starts a scale lerp to a target size at the given speed, registering the update if needed.
protected override void OnDestroy()Deregisters the update method before the base clean-up.
protected virtual void UpdateLerp()Steps the scale lerp each frame and deregisters itself when the lerp ends (unless IsAlwaysUpdating).
1 private and internal method
MemberWhat it is
private void AnimateStart(PooledObject pooledObject)Runs when the object is taken from the pool: clears the releasing flag, starts growing to startSize and registers the update.