EnablePrefabInstanceMaterial

Definition

EnablePrefabInstanceMaterial(string prefabInstanceName)

Description

This function enables the material of prefab instance prefabInstanceName. In this case, prefab instance material is used instead of its prefab material. By default, prefab instance material is disabled.

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.

Example 1

function Init()
    EnablePrefabInstanceMaterial("1_VandaEngine17-SamplePack1_f1_barrel")
end

function Update()

end
This script enables the material of prefab instance “1_VandaEngine17-SamplePack1_f1_barrel”.

Example 2

--Script name is EnablePrefabInstanceMaterial2.lua

function Init()
    EnablePrefabInstanceMaterial("this")
end

function Update()

end
If, in the Prefab Editor, you attach EnablePrefabInstanceMaterial2.lua script to a Prefab, then “this” parameter in the EnablePrefabInstanceMaterial 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 EnablePrefabInstanceMaterial function refers to the name instance1_a.
This script enables the material of current prefab instance (for example, instance1_a).
adminEnablePrefabInstanceMaterial