覆盖事件处理程序

可以覆盖生成的事件处理程序,并通过在“自定义 UI”属性中定义此处理程序,从而创建 MCG 工具的其他处理程序。

例如,在 3ds Max 中应用基于 MCG 的控制器、修改器或几何体操作符时,将触发 create 事件。稍后,该事件将调用工具的 initialize() 函数。如果计算图形并打开生成的 .ms 文件,则可看到以下代码:

	on create do 
	(
	    initialize()
	)

如果要扩展此代码以添加自己的创建逻辑,则可在“自定义 UI”属性中输入以下内容:

-- Restore the default rollout
rollout params "Parameters"
(
<<ParamUIDefs>>
<<RolloutParamsHanders>>
)

-- Define your custom functions before they are called
fn myCustomSetup
(
    -- Add your code here
)

-- Override the create handler
on create do
(
    -- Initialise the plug-in
    initialize()

    -- Call your custom MAXScript
    myCustomSetup()
)

-- Define additional handlers
on postCreate do 
(
    -- Add your code here
)