Material.RemoveTextureLayer

Introduced

v4.0

Description

Removes a texture layer from the container. If this container is the only owner of the layer, then the layer will be deleted from the scene, otherwise it is simply removed from this container (but still owned by other containers).

A Shader can also be a texture layer container, and has the same set of related methods.

C# Syntax

Material.RemoveTextureLayer( Object in_varLayerToRemove );

Scripting Syntax

Material.RemoveTextureLayer( Layer );

Parameters

Parameter Type Description
Layer TextureLayer or String Texture layer to remove from this container.

Examples

1. JScript Example

/*
	This example shows how to create texture layers on
	a material, plus enumerating and removing them.
*/
oRoot = ActiveProject.ActiveScene.Root;
oSph = oRoot.AddGeometry( "Sphere", "MeshSurface" );
oMat = oSph.AddMaterial( "Phong" );
// Add a layer at the end (since there are no others the "After"
// flag is irrelevant).
oLayers = new Array(3);
oLayers[0] = oMat.CreateTextureLayer( "B", true );
// Add another layer before the other one.
oLayers[1] = oMat.CreateTextureLayer( "A", false, oLayers[0] );
// Create a third layer at the very start.
oLayers[2] = oMat.CreateTextureLayer( "base", false );
Application.LogMessage( "Created " + oMat.TextureLayers.Count + " layers." );
for ( i = 0; i < oMat.TextureLayers.Count; i++ )
{
	oLayer = oMat.TextureLayers(i);
	Application.LogMessage( (i+1) + ": " + oLayer );
}
oMat.RemoveTextureLayer( oLayers[1] );
oMat.RemoveTextureLayer( oMat.FullName + "." + oLayers[2].Name );
count = oMat.TextureLayers.Count;
Application.LogMessage( "Only " + count + " remains after removal." );
for ( i = 0; i < count; i++ )
{
	Application.LogMessage( (i+1) + ": " + oMat.TextureLayers.Item(i) );
}
// This example should log something like:
//INFO : "Created 3 layers."
//INFO : "1: sphere.Material.base"
//INFO : "2: sphere.Material.A"
//INFO : "3: sphere.Material.B"
//INFO : "Only 1 remains after removal."
//INFO : "1: sphere.Material.B"

2. VBScript Example

'
' This example shows how to create texture layers on
' a material, plus enumerating and removing them.
'
set oRoot = ActiveProject.ActiveScene.Root
set oSph = oRoot.AddGeometry( "Sphere", "MeshSurface" )
set oMat = oSph.AddMaterial( "Phong" )
' Add a layer at the end (since there are no others the "After"
' flag is irrelevant).
dim oLayers(2)
set oLayers(0) = oMat.CreateTextureLayer( "B", True )
' Add another layer before the other one.
set oLayers(1) = oMat.CreateTextureLayer( "A", False, oLayers(0) )
' Create a third layer at the very start.
set oLayers(2) = oMat.CreateTextureLayer( "base", False )
Application.LogMessage "Created " & oMat.TextureLayers.Count & " layers."
i = 1
for each oLayer in oMat.TextureLayers
	Application.LogMessage i & ": " & oLayer
	i = i + 1
next
oMat.RemoveTextureLayer oLayers(1)
oMat.RemoveTextureLayer oMat.FullName & "." & oLayers(2).Name
count = oMat.TextureLayers.Count
Application.LogMessage "Only " & count & " remains after removal."
for i = 0 to count - 1
	Application.LogMessage i + 1 & ": " & oMat.TextureLayers.Item(i)
next
' This example should log something like:
'INFO : "Created 3 layers."
'INFO : "1: sphere.Material.base"
'INFO : "2: sphere.Material.A"
'INFO : "3: sphere.Material.B"
'INFO : "Only 1 remains after removal."
'INFO : "1: sphere.Material.B"

See Also

RemoveTextureLayers Shader.RemoveTextureLayer