Definition
SetPrefabInstanceTransparency(string prefabInstanceName, float transparency)
Description
This function sets the transparency of prefab instance prefabInstanceName. In order for this function to change the transparency of prefab instance, you must enable the material of prefab instance prefabInstanceName. For this purpose, you can click on the prefab instance prefabInstanceName in the Prefabs and GUIs section of Vanda Engine editor and click the Edit button to activate the Enable Prefab Instance Material option in the dialog that appears. You can also use the EnablePrefabInstanceMaterial function to enable the prefab instance material at runtime. In this case, prefab instance material is used instead of its prefab material.
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.
transparency
Specifies the transparency of prefab instance. This value must be in the range [0.0,1.0].
Example 1
function Init() EnablePrefabInstanceMaterial("1_VandaEngine17-SamplePack1_f1_barrel") SetPrefabInstanceTransparency("1_VandaEngine17-SamplePack1_f1_barrel", 0.5) end function Update() end
First we enable the material of prefab instance “1_VandaEngine17-SamplePack1_f1_barrel”. Then we set the transparency of prefab instance “1_VandaEngine17-SamplePack1_f1_barrel” to 0.5.
Example 2
--Script name is SetPrefabInstanceTransparency2.lua function Init() EnablePrefabInstanceMaterial("this") SetPrefabInstanceTransparency("this", 0.5) end function Update() end
If, in the Prefab Editor, you attach SetPrefabInstanceTransparency2.lua script to a Prefab, then “this” parameter in the SetPrefabInstanceTransparency 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 a to which this script is attached, “this” in SetPrefabInstanceTransparency function refers to the name instance1_a.
In this example, we enable the material of current prefab instance (for example, instance1_a). Then we set the transparency of current prefab instance (for example, instance1_a) to 0.5.
SetPrefabInstanceTransparency