Behaviours¶
All behaviours created with behaviour()
can access the following member and implement the following callback functions.
Members¶
Member |
Description |
---|---|
A list of objects assigned in the Unity Editor |
|
The |
|
The GameObject’s |
-
ScriptedBehaviour
script
¶ The
ScriptedBehaviour
component in which the Ravenscript is executed.
-
table
targets
¶ A Lua table with references to other Unity objects such as GameObjects, Transforms, and prefabs. These targets are assigned and named in the Unity Editor.
-- In this example a UiCanvas is stored under the name `canvas`. It was -- assigned in the Unity Editor. self.targets.canvas.gameObject.SetActive(true) -- We can also print all stored targets: for key,value in pairs(self.targets) do print(tostring(key) .. " = " .. tostring(value)) end
-
GameObject
gameObject
¶ The script’s
GameObject
. Use primary to access theGetComponent()
method.
Callback methods¶
Method |
Description |
---|---|
Called once |
|
Called once |
|
Called every frame |
|
|
Called every frame after animations and game logic update |
|
Called every time the physics engine updates, typically used for applying forces over time |
|
Called every time the animation engine updates, typically used for updating animation IK targets |
|
Called when the ScriptedBehaviour is enabled (from activating its GameObject) |
|
Called when the ScriptedBehaviour is disabled (from deactivating its GameObject) |
|
Called when the ScriptedBehaviour is destroyed |
-
void
Awake
()¶ Called once when the Ravenscript component is instantiated. Use
Awake()
to store references to other Ravenscripts and Components. UseAwake()
for setup and initialization of internal variables.function Rachael:Awake() self.line = self.gameObject.GetComponent(LineRenderer) end
Awake()
is called prior toStart()
.Awake()
is called if-and-only-if its GameObject is active.
-
void
Start
()¶ Called once when the Ravenscript component is instantiated. It should be safe to interact with other components and scripts which references you gathered in
Awake()
.function Rachael:Start() local p = Vector3(0, 0, range) self.line.SetPosition(1, p) end
Start()
is called afterAwake()
.Start()
is called if-and-only-if its GameObject is active.Many developer use
Start()
exclusively and ignoreAwake()
. Reserving the use ofAwake()
solely to solve order dependent initialization problems.
-
void
Update
()¶ Called once every frame. The bulk of all game logic goes here.
function Rachael:Update() local position = self.transform.position position = position + Vector3.one * Time.deltaTime self.transform.position = position end
Update()
is called afterStart()
.Update()
is called if-and-only-if its GameObject is active and enabled.