GetPrefabInstanceScale

Definition

double,double,double GetPrefabInstanceScale(string prefabInstanceName)

Description

This function receives the name of the prefab instance prefabInstanceName and returns its scale as three values x, y and z.

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.

Return Value

This function returns the prefab instance scale as three values x, y and z.

Example 1

scaleX = 0.0
scaleY = 0.0
scaleZ = 0.0

function Init()
    scaleX, scaleY, scaleZ = GetPrefabInstanceScale("1_VandaEngine17-SamplePack1_well")

    message = string.format("\nPrefab instance scale is > (%.2f, %.2f, %.2f)" , scaleX, scaleY, scaleZ)
    PrintConsole(message)
end

function Update()

end
First, GetPrefabInstanceScale function returns the scale of “1_VandaEngine17-SamplePack1_well”. Then we display the scale values in the console using the PrintConsole function.

Example 2

--Name of script is GetPrefabInstanceScale2.lua

scaleX = 0.0
scaleY = 0.0
scaleZ = 0.0

function Init()
    scaleX, scaleY, scaleZ = GetPrefabInstanceScale("this")

    message = string.format("\nPrefab instance scale is > (%.2f, %.2f, %.2f)" , scaleX, scaleY, scaleZ)
    PrintConsole(message)
end

function Update()

end
If, in the Prefab Editor, you attach GetPrefabInstanceScale2.lua script to a Prefab, then “this” parameter in the GetPrefabInstanceScale 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 GetPrefabInstanceScale function refers to the name instance1_a.
In this example, GetPrefabInstanceScale function returns the scale of current prefab instance (for example, instance1_a). Then we display the scale values in the console using the PrintConsole function.
adminGetPrefabInstanceScale