PluginRegistrar.RegisterProperty

説明

CustomProperty の新しいタイプを登録します。この CustomPropertY のインスタンスを作成するには、SceneItem.AddProperty を使用します。

C#構文

PluginItem PluginRegistrar.RegisterProperty( String in_name );

スクリプト構文

oReturn = PluginRegistrar.RegisterProperty( Name );

戻り値

PluginItem

パラメータ

パラメータ タイプ 説明
Name String プロパティの名前(実際には、このプロパティ用に作成された PluginItem オブジェクトの名前になります)。プロパティのインスタンスには、SIObject.Type としてこの名前が付きます。文字から開始し、英数字とアンダースコア(_)記号のみを使用する必要があります。 会社名やプラグイン名に基づいたプリフィックスを使用することをお勧めします。

プロパティ名にスペースが含まれている場合("My Custom Property"など)は、コールバック関数名ではスペースを削除する必要があります("MyCustomProperty_DefineLayout"など)。

プロパティ名は一意である必要があります。名前の重複を避けるために、会社名またはプラグイン名に基づくプレフィックス("ACME_TornadoKit_Configuration"など)を使用することをお勧めします。

JScript の例

/*

	"SimpleProp"

	Example of a script-based Custom Property plug-in

	To try out this example, use the Plug-in Tree to create an empty plug-in, 

	replace the generated code with the example code, and save the file. Softimage

	will automatically load the plug-in, and you can create an instance of the

	property by right-clicking the property in the Plug-in Tree and choosing

	Create Property.

	(You can also load the plug-in without restarting Softimage - see

	XSIApplication.LoadPlugin)

*/

function XSILoadPlugin( in_reg )

{

	// Called on startup of Softimage to defined

	// what is contained in the script.  (We could potentially

	// implement many PluginItems in the same script)

	in_reg.Author = "Softimage SDK Team" ;

	in_reg.Name = "SDK Example - Simple Custom Property" ;

	in_reg.Major = 1 ;

	in_reg.Minor = 1 ;

	in_reg.RegisterProperty( "SimpleProp" ) ;

	return true ;

}

function SimpleProp_Define( io_Context )

{

	//Called when a new instance of the Custom Property is created

	//Define is not called when the plug-in is updated or reloaded.

	var oCustomProperty = io_Context.Source

	oCustomProperty.AddParameter3( "U", siDouble, 0.3, 0.0, 1.0  ) ;

	oCustomProperty.AddParameter3( "V", siDouble, 0.75, 0.0, 1.0  ) ;	

	oCustomProperty.AddParameter3( "LockUV",siBool,false,null,null,false ) ;		

	oCustomProperty.AddParameter3( "ShowInfo",siBool,false,null,null,false ) ;

	// Some static text that we will dynamically show and hide

	strInfo = "This is an sdk example showing a Custom\r\n" +

			  "Property that is defined inside a script-based\r\n" +

			  "plug-in." ;

	var oParameter = oCustomProperty.AddParameter3( "InfoStatic", siString ) ;		

	oParameter.Show( false ) ;

	oParameter.Value = strInfo ;

}

function SimpleProp_DefineLayout( io_Context )

{

	// Called once per Softimage session, or after

	// a call to XSIUtils.Reload

	var oPPGLayout = io_Context.Source

	//Important first step is to erase any existing contents

	oPPGLayout.Clear() ;

	oPPGLayout.AddGroup( "Data" ) ;

	oPPGLayout.AddRow() ;

	var oItem =	oPPGLayout.AddItem( "U" ) ;

	oItem.SetAttribute( siUIThumbWheel, true ) ;

	oItem.LabelMinPixels = 20 ;

	oItem.LabelPercentage = 1 ;	

	oItem =	oPPGLayout.AddItem( "V" ) ;

	oItem.SetAttribute( siUITreadmill, true ) ;

	oItem.LabelMinPixels = 20 ;

	oItem.LabelPercentage = 1  ;

	oPPGLayout.EndRow() ;

	oPPGLayout.AddItem( "LockUV", "Lock UV" ) ;	

	oPPGLayout.EndGroup() ;

	oPPGLayout.AddGroup() ;	

	// The InfoStatic is always in the layout,

	// but it will not appear if siNotInspected 

	// capability has been set by calling Parameter.Show(false)

	oItem = oPPGLayout.AddItem( "InfoStatic", "", siControlStatic ) ;

	oItem.SetAttribute( siUIValueOnly, true ) ;

	oPPGLayout.AddItem( "ShowInfo", "Show Info" ) ;	

	oPPGLayout.EndGroup() ;

	oPPGLayout.AddButton( "Done" ) ;

}

//

// Logic Code - these callbacks are called when

// events happen in the user interface

//

// The syntax is basically the same as SPDL logic

// but notice how each function uses a prefix based on the

// Custom Property that we registered, i.e. 

// "SimpleProp_"

//

function SimpleProp_OnInit()

{

	//Called when the UI first appears.

	Application.LogMessage( "Someone is inspecting " + 

		PPG.Inspected(0).FullName ) ;

}

function SimpleProp_Done_OnClicked()

{

	// See the documentation for

	// PPG.Close for more info about this

	// technique.

	// Self destruct the property page

	DeleteObj( PPG.Inspected(0) ) ;

	// Close the property page

	PPG.Close() ;

}

function SimpleProp_ShowInfo_OnChanged()

{

	// Toggle the visibility of the static text

	PPG.InfoStatic.Show( PPG.ShowInfo.Value ) ;

	// It isn't strictly necessary to call this for

	// simple cases of hiding and showing controls,

	// but it ensures that the property page is fully

	// redrawn and resized.

	PPG.Refresh() ;

}

// The following three logic routines force both 

// parameters to have the same value

function SimpleProp_U_OnChanged()

{

	if ( PPG.LockUV.Value )

	{	

		// Note: Changing the value from

		// within the logic code will not 

		// result in SimpleProp_V_OnChanged

		// being called.  So there is

		// minimal risk of infinite loops.

		PPG.V.Value = PPG.U.Value ;

	}

}

function SimpleProp_V_OnChanged()

{

	if ( PPG.LockUV.Value )

	{	

		PPG.U.Value = PPG.V.Value ;

	}

}

function SimpleProp_LockUV_OnChanged()

{

	if ( PPG.LockUV.Value )

	{

		// When locking is enabled make sure

		// that the two values snap to the same,

		// value.		

		avg = ( PPG.U.Value + PPG.V.Value	 ) / 2 ;

		PPG.U.Value = avg ;

		PPG.V.Value = avg ;

	}

}

関連項目

Plugin.Items SceneItem.AddProperty CustomProperty PPGLayout PPG Definition Callbacks for Properties