Skip to main content

Every User Callback in Lua Scripts.

The Lua scripts are executed by functions called User Callbacks. Some of these functions are called by the Unity Engine, and some other are called by Massive Loop. The User callbacks are referred as Message in API documentations. Each component might introduce a series of messages, but all these messages called in you Lua script.

Here are the list of all available User Callbacks implemented in Massive loop.

OnEnable: Called before the start, after initial pass, or after disable object enabled back on.

Start: In this phase, the start function in your code will be called.

FixedUpdate: Fixed update may called multiple time per frame. This sub loop often called physics loop, which makes Fixed Update useful for physics calculation.

Update: The update function gets called on every frame.

LateUpdate: Called latest on the frame.

OnDisabled: Called when the object becomes disabled.

OnTriggerEnter

OnTriggerExit

OnTriggerStay

OnCollisionEnter

OnCollisionExit

OnCollisionStay

OnAnimatorIK

OnAnimatorMove

  • Called by Particle System

OnParticleCollision

OnBecameVisible

OnBecameInvisible

OnOwnerChanged

OnBecomeOwner

OnLostOwnership

Note: The Animator callback may called on both physics loop and game logic.

You may define a function for any of these tasks. You don't have to define a function for any of these callbacks. Use the script variable from LUA.script to define a function for these callbacks.

do

local MyScript = LUA.script;

function MyScript.OnEnable()
-- OnEnable callback
end

function MyScript.Start()
-- Start callback.
end

function MyScript.FixedUpdate()
-- fixed update
end

-- @param other: Collider
function MyScript.OnTriggerEnter(other)
-- On Trigger Enter
end

-- @param other: Collider
function MyScript.OnTriggerExit(other)
-- On trigger Exit
end

-- @param other: Collider
function MyScript.OnTriggerStay(other)
-- On trigger stay
end

-- @param other: Collision
function MyScript.OnCollisionEnter(other)
-- On Collision enter
end

-- @param other: Collision
function MyScript.OnCollisionExit(other)
-- On Collision exit
end

-- @param other: Collision
function MyScript.OnCollisionStay(other)
-- On collision stay
end

-- @param gameObject: GameObject
function MyScript.OnParticleCollision(gameObject)
-- On Particle collision
end

function MyScript.Update()
-- Update
end

function MyScript.OnAnimatorMove()
-- On Animator Move
end

--@param layerIndex: number
function MyScript.OnAnimatorIK(layerIndex)
-- On Animator IK
end

function MyScript.LateUpdate()
-- Late Update
end

-- @param newOwner: MLPlayer
function MyScript.OnOwnerChanged(newOwner)
-- On Owner changed
end

function MyScript.OnBecomeOwner()
-- On become owner
end

function MyScript.OnLostOwnership()
-- On Lost ownership
end

function MyScript.OnBecameVisible()
-- On Became visible
end

function MyScript.OnBecameInvisible()
-- On became invisible
end

function MyScript.OnDisable()
-- On Disable
end

end