GetPrefabInstanceSpecular

Definition

double, double, double GetPrefabInstanceSpecular(string prefabInstanceName)

Description

This function returns the specular color of prefab instance prefabInstanceName.

Parameter

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.

Return Values

This function returns the red, green, and blue components of prefab instance specular color. Each value is in the range [0.0,1.0].

Example 1

r = 0.0
g = 0.0
b = 0.0

function Init()
    r, g, b = GetPrefabInstanceSpecular("1_VandaEngine17-SamplePack1_wood_pile")

    message = string.format("\nSpecular color is : (%.2f, %.2f, %.2f)", r, g, b)
    PrintConsole(message)
end

function Update()

end
First we  get the specular color of prefab instance “1_VandaEngine17-SamplePack1_wood_pile”. Then we display the result in the console using PrintConsole function.

Example 2

--Name of script is GetPrefabInstanceSpecular2.lua

r = 0.0
g = 0.0
b = 0.0

function Init()
    r, g, b = GetPrefabInstanceSpecular("this")

    message = string.format("\nSpecular color is : (%.2f, %.2f, %.2f)", r, g, b)
    PrintConsole(message)
end

function Update()

end
If, in the Prefab Editor, you attach GetPrefabInstanceSpecular2.lua script to a Prefab, then “this” parameter in the GetPrefabInstanceSpecular 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 GetPrefabInstanceSpecular function refers to the name instance1_a.
In this example, we get the specular color of current prefab instance (for example, instance1_a). Then we display the result in the console using PrintConsole function.
adminGetPrefabInstanceSpecular