ResumeUpdateEventOfPrefabInstance

Definition

ResumeUpdateEventOfPrefabInstance(string prefabInstanceName)

Description

This function resumes the script’s Update() event of prefab instance prefabInstanceName.

Parameters

prefabInstanceName
Specifies the name of the prefab instance. You can also use the name “this” for this parameter. In this case, “this” refers to the prefab instance name that this script is attached to.

Example 1

function OnTriggerEnter(otherActorName)
    --nil means main character controller
    if otherActorName == nil then
          PauseUpdateEventOfPrefabInstance("1_animation_test_plane")
    end
end

function OnTriggerStay(otherActorName)

end

function OnTriggerExit(otherActorName)
    --nil means main character controller
    if otherActorName == nil then
          ResumeUpdateEventOfPrefabInstance("1_animation_test_plane")
    end
end
Assume that the above script is attached to a trigger named “trigger1”. Whenever the main character enters “trigger1”, script’s Update() event of prefab instance “1_animation_test_plane” will be paused. Whenever the main character exits “trigger1”, script’s Update() event of prefab instance “1_animation_test_plane” will be resumed.

Example 2

--Name of script is ResumeUpdateEventOfPrefabInstance2.lua

function Init()
    PauseUpdateEventOfPrefabInstance("this")
    ResumeUpdateEventOfPrefabInstance("this")
end

function Update()
    PrintConsole("\nUpdate")
end
If, in the Prefab Editor, you attach ResumeUpdateEventOfPrefabInstance2.lua script to a Prefab, then “this” parameter in the ResumeUpdateEventOfPrefabInstance function will point to instances of that Prefab in current VScene. For example, if you have an Instance named instance1_a from a Prefab named to which this script is attached, “this” in ResumeUpdateEventOfPrefabInstance function refers to the name instance1_a.
In this example, we use PauseUpdateEventOfPrefabInstance to pause the script’s Update() event of current prefab instance (for example, instance1_a). Then we use ResumeUpdateEventOfPrefabInstance to resume the script’s Update() event of current prefab instance (for example, instance1_a).
adminResumeUpdateEventOfPrefabInstance