Skip to main content

ServerMultiCommandAction

A class in Root.Township, Alta.Menu.

Client menu control that builds one button per option of a multi-option server command and sends the chosen option. Base for AssistedSpawnCommandAction.

Constructors​

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

Fields​

MemberWhat it is
protected bool isSetUpSet once the buttons are built, so SetSettings only runs once.
8 private and internal fields
MemberWhat it is
private Transform buttonParentTransform the buttons are spawned under.
private TextButton buttonPrefabPrefab for each option button.
private TextRenderer buttonTextText showing the command's name.
private float minDelayBetweenCommandsCooldown in seconds after a command. Default 0.5.
private static float nextCommandStatic time before which no control of this type can send again.
private ServerMultiOptionCommandDefinition optionCommandsThe multi-option command definition.
private const string pressableLayerLayer name OnlyOnPlayerHMD. The code passes the same string directly.
private float widthLength of the row the buttons are spread across.

Methods​

MemberWhat it is
override void SetSettings(ISettingsFieldAccess newSettingToDisplay)First call only: takes the multi-option command and builds its buttons.
protected virtual void DynamicButtonSetup(TextButton textButton, int buttonIndex)Wires a button to send the command with its option index. Overridden by subclasses.
protected void SetupControlView(IUsesMultipleButtons multiCommandOptions)Shows the command name and spawns a button per label, spaced evenly along width and on the OnlyOnPlayerHMD layer.
2 private and internal methods
MemberWhat it is
private void OnDrawGizmos()Editor: draws the line the buttons are laid out along.
private void SendCommand(int commandIndex)Sets the option index and runs the command, unless the shared cooldown is running.