定义UI

红色框,是我们要定义的窗口内容

QQ截图20210531195317.png

QQ截图20210529003433.png

添加元素

创建一个UI元素必须由3个部分组成
QQ截图20210531202603.png
删除一个元素,只要调用deleteUI关键字即可
QQ截图20210531202724.png


L- 创建菜单【Menus】

https://help.autodesk.com/cloudhelp/2022/CHS/Maya-Tech-Docs/Commands/cat_Windows.html#Menus 菜单必须在最开始创建 QQ截图20210531205314.png **QQ截图20210531205047.png

  1. if(`window -ex name`)
  2. {deleteUI name;}
  3. window
  4. -menuBar true
  5. -title "newName"
  6. -width 300
  7. -height 300
  8. name;
  9. menu
  10. -label "Fist"
  11. -tearOff true
  12. nameA; //菜单名
  13. menuItem
  14. -label "1";
  15. menuItem
  16. -divider true;
  17. menuItem
  18. -label "2"
  19. -subMenu true
  20. -tearOff true
  21. newSubM;
  22. menuItem
  23. -label "2.1";
  24. setParent -menu ..;
  25. menuItem
  26. -label "3";
  27. window
  28. -edit
  29. -width 300
  30. -height 300
  31. name;
  32. 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 控件必须在布局声明之后创建

QQ截图20210531205607.png

  1. if(`window -ex name`)
  2. {deleteUI name;}
  3. window
  4. -menuBar true
  5. -title "newName"
  6. -width 300
  7. -height 300
  8. name;
  9. menu -label "Fist" -tearOff true;
  10. menuItem
  11. -label "1";
  12. columnLayout
  13. -adjustableColumn true;
  14. text
  15. -label "===By HibariCN===";
  16. floatSliderGrp
  17. -label "半径"
  18. -min 1
  19. -max 10
  20. -field true
  21. readSlider;
  22. button
  23. -label "创建小球"
  24. -command "func";
  25. window
  26. -edit
  27. -width 300
  28. -height 300
  29. name;
  30. showWindow;
  31. //============================================
  32. //外部函数,用来给button使用
  33. global proc float func()
  34. {
  35. float $readit = `floatSliderGrp -q -value readSlider`;
  36. string $str = "成功创建半径为【" + $readit + "】小球";
  37. if(`text -ex PolyN`)
  38. {
  39. deleteUI PolyN;
  40. }
  41. text
  42. -label $str
  43. PolyN;
  44. return $readit;
  45. }

QQ截图20210531205800.png

QQ截图20210529003433.png

主菜单

L- 创建主菜单

QQ截图20210531214117.png QQ截图20210531214016.png

  1. if(`menu -ex myNewMainMenu`)
  2. {
  3. deleteUI myNewMainMenu;
  4. }
  5. //global string $gMainWindow;
  6. setParent $gMainWindow;
  7. menu -label "Hibari" myNewMainMenu;
  8. //setParent -menu myNewMainMenu;
  9. menuItem
  10. -label "1"