Definition
SetPrefabInstanceSpecular(string prefabInstanceName, float red, float green, float blue)
Description
This function sets the specular color of prefab instance prefabInstanceName. In order for this function to change the specular color 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.
red, green, blue
Specify the red, green, and blue components of prefab instance specular color. Each value is in the range [0.0,1.0].
Example 1
function Init() EnablePrefabInstanceMaterial("1_VandaEngine17-SamplePack1_f1_barrel") SetPrefabInstanceSpecular("1_VandaEngine17-SamplePack1_f1_barrel", 0.75, 0.5, 0.25) end function Update() end
First we enable the material of prefab instance “1_VandaEngine17-SamplePack1_f1_barrel”. Then we set the specular color of prefab instance “1_VandaEngine17-SamplePack1_f1_barrel” to (0.75, 0.5, 0.25).
Example 2
--Script name is SetPrefabInstanceSpecular2.lua function Init() EnablePrefabInstanceMaterial("this") SetPrefabInstanceSpecular("this", 0.75, 0.5, 0.25) end function Update() end
If, in the Prefab Editor, you attach SetPrefabInstanceSpecular2.lua script to a Prefab, then “this” parameter in the SetPrefabInstanceSpecular 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 SetPrefabInstanceSpecular 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 specular color of current prefab instance (for example, instance1_a) to (0.75, 0.5, 0.25).
SetPrefabInstanceSpecular