Skip to content

Script function events

SDraw edited this page Apr 11, 2024 · 11 revisions

Those are script events that are called at runtime.

Unity's events

  • function Start()
  • function Update()
  • function LateUpdate()
  • function FixedUpdate()
  • function OnEnable()
  • function OnDisable()
  • function OnDestroy()
  • function OnCollisionEnter(Collision col)
  • function OnCollisionExit(Collision col)
  • function OnCollisionStay(Collision col)
  • function OnTriggerEnter(Collider col, bool internal): internal shows if Collider is internal game component.
  • function OnTriggerExit(Collider col, bool internal): internal shows if Collider is internal game component.
  • function OnTriggerStay(Collider col, bool internal): internal shows if Collider is internal game component.
  • function OnAnimatorIK(int layer)

Additional events

  • function OnMessage(...): message called by another script via LuaScript:SendMessage method; arguments count is variable.
  • function OnInteractableGrab(): called when attached CVRInteractable is grabbed; no parameters.
  • function OnInteractableDrop(): called when attached CVRInteractable is dropped; no parameters.
  • function OnInteractableUp(): called when attached CVRInteractable is clicked; no parameters.
  • function OnInteractableDown(): called when attached CVRInteractable is unclicked; no parameters.
  • function OnInteractableHoverEnter(): called when attached CVRInteractable gaze is started; no parameters.
  • function OnInteractableHoverExit(): called when attached CVRInteractable gaze is stopped; no parameters.
  • function OnEnterSeat(): called when local player sits on CVRInteractable that is configured as seat.
  • function OnExitSeat(): called when local player leaves CVRInteractable that is configured as seat.
  • function OnPlayerJoin(Player player): called when remote player has joined.
    • Note: No call if remote player is blocked by local player.
  • function OnPlayerExit(Player player): called when remote player has left.
    • Note: No call if remote player is blocked by local player.
  • function OnButtonClick(): called when attached UI.Button is clicked.
  • function OnToggleChange(bool state): called when attached UI.Toggle is toggled.
  • function OnSliderChange(float newValue): called when attached UI.Slider is slided.

Example

function Start()
    Log("I'm working, yay!")
end