AttachPrefabInstanceToWater

Definition

AttachPrefabInstanceToWater(string prefabInstanceName, string waterObjectName)

Description

This function attaches the prefab instance prefabInstanceName to the water waterObjectName. In this case, you can see the reflection of the prefab instance in the water.

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 that this script is attached to.

waterObjectName
Specifies the name of the water. You can also use the name “this” for this parameter. In this case, “this” refers to the water object that this script is attached to.
Note: You can’t use “this” string for both prefabInstanceName and waterObjectName at the same time.

Example 1

function Init()
    AttachPrefabInstanceToWater("1_VandaEngine17-SamplePack1_house2""water1")
end

function Update()

end
Attaches prefab instance “1_VandaEngine17-SamplePack1_house2” to water object “water1”.

Example 2

--name of script is AttachPrefabInstanceToWater2.lua
function Init()
    AttachPrefabInstanceToWater("this""water1")
end

function Update()

end
If, in the Prefab Editor, you attach AttachPrefabInstanceToWater2.lua script to a Prefab, then “this” parameter in the AttachPrefabInstanceToWater 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 AttachPrefabInstanceToWater function refers to the name instance1_a.
This script attaches current prefab instance to the water object “water1”.

Example 3

--name of script is AttachPrefabInstanceToWater3.lua
function Init()
    AttachPrefabInstanceToWater("1_VandaEngine17-SamplePack1_house2""this")
end

function Update()

end
Attaches prefab instance “1_VandaEngine17-SamplePack1_house2” to current water object. For example, if you attach the AttachPrefabInstanceToWater3.lua script to a water named “water1”, then the name “this” will be equivalent to “water1”.
adminAttachPrefabInstanceToWater