摘要:本文将带你了解Maya教程之Maya Mel GUI入门,希望本文对大家学Maya有所帮助
本文将带你了解Maya教程之Maya Mel GUI入门,希望本文对大家学Maya有所帮助
在写mel程序时,友好的用户界面是很重要的,因此需要掌握一些基本控件的使用方法,在学习的过程中,也留给自己作为笔记,同时也希望能对有需要的人有些帮助。
1.创建一个window,里面可以包含很多的控件,比如基本的button,checkbox,textfield等等
window;columnLayout; text -label "My text"; button -label "I'm a button"; checkBox -label "Check Box"; radioCollection; radioButton -label "start"; radioButton -label "stop"; floatField -value 3.41; textField -text "Hello";showWindow;
2.控件触发执行相应命令
global proc Create_sphere(){ sphere -name "MySphere";} window; columnLayout; button -label "My Sphere" -command "Create_sphere()";showWindow;
3.界面布局,有ColumnLayout,RowLayout,FrameLayout等等
window; columnLayout -columnWidth 150; button; button;showWindow;
4.确认对话框
$my_confirm = `confirmDialog -title "Confirm" -message "Yes or No" -button "YES" -button "NO" -defaultButton "YES" -cancelButton "NO" -dismissString "NO"`;if ($my_confirm == "YES"){ print "User has picked YES\n";}else if ($my_confirm == "NO"){ print "User has picked NO\n";}
4.提示框
string $text;string $my_prompt = `promptDialog -title "Rename An Entity" -message "Enter Name:" -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "Cancel"`; //get new name of entityif ($my_prompt == "OK") { $text = `promptDialog -query -text`; print ("New name for Entity: " + $text + "\n");}else if ($my_prompt == "Cancel") { print ("OK, fine don't rename....\n");}
5.获取输入框中的数字
window intFieldTestWin;columnLayout;intField intergerField;showWindow intFieldTestWin; //then declare an interger variable to store your value int $intStorage; //now, type an interger in the window.//Then, use the infField query mode to query the value of the window into//the variable. You use the single quote (``) signs for this. $intStorage = `intField -q -v intergerField`;print $intStorage;// To do it the other way around, meaning to put the value of a variable into the field // itself, you can try this.// Declare a variable with a value. int $intStorage = 20; // Then use the intField edit mode to input the variable as the arguement// for the window. intField -e -v $intStorage intergerField;// Basically, most UI controls share the same creation/edit/query syntax.6.取得输入框的值并进行相应的动作
window -t "test"; gridLayout -numberOfColumns 3 -cellWidthHeight 100 30 -w 300 -h 50; text -label "个数:"; intField -min 1 -max 10 number; button -label "生成" -c "test";showWindow; proc test(){ global string $intFieldName = ""; int $value; $value = `intField -query -value number`; print($value); int $i = 0; for($i=1;$i<=$value;++$i) { polyCylinder -r 1 -h 2 -sx 20 -sy 1 -sz 1 -ax 0 1 0 -rcp 0 -cuv 3 -ch 1; polyCylinder -r 1 -h 2 -sx 20 -sy 1 -sz 1 -ax 0 1 0 -rcp 0 -cuv 3 -ch 1; move -r 0 1.40901 0 ; //scale -r 0.487535 0.487535 0.487535 ; $randx = rand(0.2,2); $randy = rand(0.2,2); $randz = rand(0.2,2); scale -r $randx $randy $randz; select -r ("pCylinder"+ ($i*2-1)) ("pCylinder"+$i*2) ; move -r ($i*3) 0 0 ; }}
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之Maya频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号