Shader.AddProperty

Introduced

v4.0

Description

Creates and adds a UserDataBlob or CustomProperty to a Shader object.

C# Syntax

Property Shader.AddProperty( Object in_Preset, Boolean in_Branch, String in_name );

Scripting Syntax

oReturn = Shader.AddProperty( Preset, [BranchFlag], [Name] );

Return Value

CustomProperty, UserDataBlob or UserDataMap, depending on the preset that was used.

Parameters

Parameter Type Description
Preset String This argument contains either the name of a Property Preset or a string with the filename or full path to a Preset file.

Note: Only CustomProperty Presets, UserDataBlob Presets, and UserDataMap Presets are valid for shaders.

The type of property that is created is determined by this argument. For example, "CustomProperty" creates an empty CustomProperty and "UserDataBlob" creates a UserDataBlob.
BranchFlag Boolean False is the only supported value.

Default Value: false

Name String Represents the name of the new property (see SIObject.Name). If not specified the object is named based on the Preset argument.

Examples

JScript Example

/*
	This example demonstrates how to add CustomProperties under a Shader.
*/
NewScene( null,false ); 
var oCone = ActiveSceneRoot.AddGeometry( "Cone", "MeshSurface" );
var oMaterial = oCone.AddMaterial( "Phong" );
var oPhongShader = oMaterial.Shaders(0);
var oPhongPSet = oPhongShader.AddProperty( "CustomProperty",false ,"ShaderNested" );
oPhongPSet.AddParameter3( "Bar", siInt4 ) ;
var oPhongPSet = oPhongShader.AddProperty( "CustomProperty",false ,"AnotherPSet" );
var oPhongProperties = oPhongShader.Properties
LogMessage( "There are " + oPhongProperties.Count + " Properties under " + oPhongShader.FullName );
for ( i = 0 ; i < oPhongProperties.Count ; i++ )
{
	LogMessage( oPhongProperties.Item(i).Name ) ;
}
// INFO : "There are 2 Properties under cone.Material.Phong"
// INFO : "ShaderNested"
// INFO : "AnotherPSet"

See Also

SceneItem.AddProperty Shader.Properties