Skip to main content

TransformScriptAnimation

An abstract class in Root.Township, the global namespace.

Base for simple code-driven transform animations that tick through the budgeted update module. By default they don't run on a dedicated server.

Constructors​

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

Fields​

MemberWhat it is
protected Transform animatingTransformThe transform being animated, cached from this object.
4 private and internal fields
MemberWhat it is
private bool autoStartWhen true, the animation starts in Start if it is allowed to run.
private bool isAllowedToRunSet in Start: false on a dedicated server when isDisabledOnServer is on. Note it stays false (never auto-starts) when isDisabledOnServer is off.
private bool isDisabledOnServerWhen true (default), the animation does not run on a server unless it is a local test.
private IUnityUpdateMethod updaterHandle for the budgeted update callback while animating.

Properties​

MemberWhat it is
bool IsActive { get; private set; }True while the animation is registered for updates.

Methods​

MemberWhat it is
async void AnimateOnce()Restarts the animation and stops it again after GetLengthOfAnimationInSeconds.
virtual float GetLengthOfAnimationInSeconds()Length of one run, used by AnimateOnce. Returns 0 unless overridden.
virtual void ResetState()Called when the animation stops, to put the transform back. Does nothing unless overridden.
void StartAnimating()Registers UpdateAnimation with the budgeted updater if not already running.
void StopAnimating()Unregisters the update and calls ResetState.
protected virtual void Start()Works out whether it may run on this side and starts animating if auto start is on.
protected abstract void UpdateAnimation()Called each budgeted update while active. Subclasses move the transform here.
1 private and internal method
MemberWhat it is
private void OnDestroy()Stops the animation so its update is deregistered.