您当前的位置: 首页 > 

开发游戏的老王

暂无认证

  • 2浏览

    0关注

    803博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Rigify图解教程:添加Rigify Layers按钮的hack办法

开发游戏的老王 发布时间:2020-09-18 19:39:18 ,浏览量:2

情景描述

使用Rigify模块自定义骨架的时候,生成的最终Rig一般会如下图所示:按钮有了,但是没有名称 在这里插入图片描述 以前的文章介绍过标准流程,就是在MetaRig上编辑层和UI的对应关系。不过如果绑定的时候忘了,已经生成最终Rig以后,也是完全可以补救的,而且更加简单。

步骤

将任意窗口切换成文本编辑器,然后在下图红框所示的下拉菜单找到rig_ui.py这个python脚本(由Rigify生成的脚本)。

在这里插入图片描述 找到draw这个函数的定义:

这个函数,本例中该函数如下所示

 def draw(self, context):
        layout = self.layout
        col = layout.column()

        row = col.row()
        row.prop(context.active_object.data, 'layers', index=1, toggle=True, text=' ')
        row.prop(context.active_object.data, 'layers', index=4, toggle=True, text=' ')
        row.prop(context.active_object.data, 'layers', index=8, toggle=True, text=' ')
        row.prop(context.active_object.data, 'layers', index=9, toggle=True, text=' ')

        row = col.row()
        row.prop(context.active_object.data, 'layers', index=13, toggle=True, text=' ')
        row.prop(context.active_object.data, 'layers', index=14, toggle=True, text=' ')
        row.prop(context.active_object.data, 'layers', index=15, toggle=True, text=' ')

        row = col.row()
        row.separator()
        row = col.row()
        row.separator()

        row = col.row()
        row.prop(context.active_object.data, 'layers', index=28, toggle=True, text='Root')

这个函数的原理很简单:

# 换行
 row = col.row()
#设置按钮和层的对应关系,并为该按钮命名
row.prop(context.active_object.data, 'layers', index=15, toggle=True, text=' ')
 def draw(self, context):
        layout = self.layout
        col = layout.column()

        row = col.row()
        row.prop(context.active_object.data, 'layers', index=1, toggle=True, text=' ')
        row.prop(context.active_object.data, 'layers', index=4, toggle=True, text=' ')
        row.prop(context.active_object.data, 'layers', index=8, toggle=True, text=' ')
        row.prop(context.active_object.data, 'layers', index=9, toggle=True, text=' ')

        row = col.row()
        row.prop(context.active_object.data, 'layers', index=13, toggle=True, text=' ')
        row.prop(context.active_object.data, 'layers', index=14, toggle=True, text=' ')
        row.prop(context.active_object.data, 'layers', index=15, toggle=True, text=' ')

        row = col.row()
        row.separator()
        row = col.row()
        row.separator()

        row = col.row()
        row.prop(context.active_object.data, 'layers', index=28, toggle=True, text='Root')

修改后的draw函数


    def draw(self, context):
        layout = self.layout
        col = layout.column()

        row = col.row()
        row.prop(context.active_object.data, 'layers', index=1, toggle=True, text='Arms')
        row.prop(context.active_object.data, 'layers', index=4, toggle=True, text=' Legs')
        row.prop(context.active_object.data, 'layers', index=8, toggle=True, text=' Torso')
        row.prop(context.active_object.data, 'layers', index=9, toggle=True, text=' Torso(Tweak)')

        row = col.row()
        row.prop(context.active_object.data, 'layers', index=13, toggle=True, text='Arms(Tweak) ')
        row.prop(context.active_object.data, 'layers', index=14, toggle=True, text='Legs(Tweak) ')
        row.prop(context.active_object.data, 'layers', index=15, toggle=True, text=' Tail')

        row = col.row()
        row.separator()
        row = col.row()
        row.separator()

        row = col.row()
        row.prop(context.active_object.data, 'layers', index=28, toggle=True, text='Root')

别忘了运行一下

在这里插入图片描述 于是乎,按钮就有名字了

在这里插入图片描述

你甚至还可以照猫画虎地给任意层添加按钮

在这里插入图片描述 在这里插入图片描述

关注
打赏
1656935939
查看更多评论
立即登录/注册

微信扫码登录

0.0401s