Hi all. I've been using Maya for a year or so, but I'm just starting to learn Mel scripting.
My first script that I've included the code for is supposed to list all the cameras in a scene and allow you to look through the camera when it's button is pressed.
For some reason the buttons are all created with their proper labels, but all of the created buttons toggle the last camera in the list (which is in alphabetical order due to listCameras
).
Any help fixing this script is greatly appreciated.
The script ->
//variables
string $cameraList[] = listCameras
;
string $currentCamera;
int $i;
//delete old window
if (window -exists cameraLister
) deleteUI cameraLister;
//create new window
window -title "Camera Lister v.1.0" -wh 100 200 cameraLister;
rowColumnLayout;
//create buttons with lookThru actions assigned
for ($i=0;$i < size($cameraList);$i++)
{
$currentCamera = $cameraList[$i];
button -label $currentCamera -align "center" -command "lookThru $currentCamera";
};
button -label "Close Camera Lister" -align "center" -command "deleteUI cameraLister";
//show new window
showWindow;