SetPrefabInstanceEmission(string prefabInstanceName, float red, float green, float blue)


This function sets the emission color of prefab instance prefabInstanceName. In order for this function to change the emission 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.


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 emission color. Each value is in the range [0.0,1.0].

Example 1

function Init()
    SetPrefabInstanceEmission("1_VandaEngine17-SamplePack1_f1_barrel", 0.75, 0.5, 0.25)

function Update()

First we enable the material of prefab instance “1_VandaEngine17-SamplePack1_f1_barrel”. Then we set the emission color of prefab instance “1_VandaEngine17-SamplePack1_f1_barrel” to (0.75, 0.5, 0.25).

Example 2

--Script name is SetPrefabInstanceEmission2.lua

function Init()
    SetPrefabInstanceEmission("this", 0.75, 0.5, 0.25)

function Update()

If, in the Prefab Editor, you attach SetPrefabInstanceEmission2.lua script to a Prefab, then “this” parameter in the SetPrefabInstanceEmission 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 SetPrefabInstanceEmission 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 emission color of current prefab instance (for example, instance1_a) to (0.75, 0.5, 0.25).