Skip to main content

ScalePulsator

A class in Root.Township, the global namespace.

Component that pulses an object's scale up and down from its starting size. Add one at runtime with StartPulsator.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private float baseSizeScale at the bottom of the pulse, as a multiple of the starting scale.
private bool isStartingOnAwakeStarts pulsing on Awake when set.
private float pulseSpeedBacking field for PulseSpeed.
private float sizeMultiplierBacking field for SizeMultiplier.
private Vector3 startSizeBacking field for StartSize.

Properties​

MemberWhat it is
float PulseSpeed { get; set; }Pulses per second, roughly (half a cosine cycle per unit). Can be changed while running.
float SizeMultiplier { get; set; }Scale at the top of the pulse, as a multiple of the starting scale. Can be changed while running.
Vector3 StartSize { get; }The local scale the object had on Awake.

Methods​

MemberWhat it is
static void StartPulsator(GameObject gameobject)Adds a ScalePulsator to the object if needed and starts it.
void StartPulsing()Restarts the pulse coroutine, if the component is active.
static void StopPulsator(GameObject gameobject)Stops the pulsator on the object, if it has one.
void StopPulsing()Stops the pulse and puts the starting scale back.
2 private and internal methods
MemberWhat it is
private void Awake()Saves the starting scale and starts pulsing if isStartingOnAwake is set.
private IEnumerator UpdateScale() (iterator)Coroutine that moves the scale between baseSize and SizeMultiplier on a cosine each frame.

Used in​

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