Maxscript 窗体与结构体this的传递

try(mainWindowDef.close())catch()
struct mainWindowDef 
(
    title = "Main Window",
    
    roll = rollout roll "" 
    (
        local _this
        fn created =
        (
            roll.title = _this.title
        )
    ),

    fn close = 
    (
        try(
            destroyDialog this.roll
        )
        catch()
    ),

    fn show = 
    (
        --关闭,_this被销毁
        this.close()
        --创建,_this初始为undefined
        createDialog this.roll 500 300
        --赋值,_this指向当前结构体实例
        this.roll._this = this
        --使用函数代替on open do
        this.roll.created()
    )
)

global mainWindowDef = mainWindowDef()
mainWindowDef.show()


posted @ 2021-03-08 10:04  trykle  阅读(221)  评论(0编辑  收藏  举报