Skip to main content

LeverToEvents

A class in Root.Township, the global namespace.

Raises a UnityEvent when a SelectionLever on the same object changes position, optionally on the server only.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private bool isServerOnlyIf set, the events only run on the server.
private UnityEvent onPosition0Event raised when the lever moves to position 0.
private UnityEvent onPosition1Event raised when the lever moves to any other position.

Methods​

2 private and internal methods
MemberWhat it is
private void Awake()Hooks the lever's SelectionChanged, unless isServerOnly is set and this isn't the server.
private void TriggerEvents(SelectionLever lever, int oldIndex, int newIndex)Raises onPosition0 for index 0 and onPosition1 for any other index.