定义UI
红色框,是我们要定义的窗口内容
添加元素
创建一个UI元素必须由3个部分组成
删除一个元素,只要调用deleteUI关键字即可
L- 创建菜单【Menus】
https://help.autodesk.com/cloudhelp/2022/CHS/Maya-Tech-Docs/Commands/cat_Windows.html#Menus 菜单必须在最开始创建 **
if(`window -ex name`)
{deleteUI name;}
window
-menuBar true
-title "newName"
-width 300
-height 300
name;
menu
-label "Fist"
-tearOff true
nameA; //菜单名
menuItem
-label "1";
menuItem
-divider true;
menuItem
-label "2"
-subMenu true
-tearOff true
newSubM;
menuItem
-label "2.1";
setParent -menu ..;
menuItem
-label "3";
window
-edit
-width 300
-height 300
name;
showWindow;
L- 布局声明【Layout】
https://help.autodesk.com/cloudhelp/2022/CHS/Maya-Tech-Docs/Commands/cat_Windows.html#Layouts
L- 基础控件【Controls】
https://help.autodesk.com/cloudhelp/2022/CHS/Maya-Tech-Docs/Commands/cat_Windows.html#Controls 控件必须在布局声明之后创建
if(`window -ex name`)
{deleteUI name;}
window
-menuBar true
-title "newName"
-width 300
-height 300
name;
menu -label "Fist" -tearOff true;
menuItem
-label "1";
columnLayout
-adjustableColumn true;
text
-label "===By HibariCN===";
floatSliderGrp
-label "半径"
-min 1
-max 10
-field true
readSlider;
button
-label "创建小球"
-command "func";
window
-edit
-width 300
-height 300
name;
showWindow;
//============================================
//外部函数,用来给button使用
global proc float func()
{
float $readit = `floatSliderGrp -q -value readSlider`;
string $str = "成功创建半径为【" + $readit + "】小球";
if(`text -ex PolyN`)
{
deleteUI PolyN;
}
text
-label $str
PolyN;
return $readit;
}
主菜单
L- 创建主菜单
if(`menu -ex myNewMainMenu`)
{
deleteUI myNewMainMenu;
}
//global string $gMainWindow;
setParent $gMainWindow;
menu -label "Hibari" myNewMainMenu;
//setParent -menu myNewMainMenu;
menuItem
-label "1"