- set script files
- set the background image
- set up a multiple interfaces
- edit buttons
- edit namespace and tool controls
- undo and redo
This script builds an interface that can select controls of your rig. This means you can hide all your control curves in the viewport and animate almost directly with the geometry.
The uiBuilder will only work with Maya 2014 or higher.
set script files
You need two .MEL files to build your interface. The ui.mel will contain your interface, once you’re finished. The uiBuilder.mel is the script that lets you build the interface for your character.
Place both scripts in an appropriate Maya directory such as “Documents/Maya/Maya2014x64/prefs/scripts” on a PC or Library/Preferences/Autodesk/Maya/2014-x64/prefs/scripts on a MAC.
Open the file uiBuilder.mel in Maya, a window opens. At the top there are two fields with filebrowser icons. The first is for the ui.mel file, the second is for the background image. Click the upper browser icon and navigate to the ui.mel file. Click “OK” on the right side to open the UI file. You can now start to build your Interface.
set the background image
Next, you should set you background image. This will typically be a render of screenshot of your character in a symmetric pose. I recommend to keep the image size small so it will not take to much screen space while animating. For example: Do not use a T – Pose as it will take much space in width you don’t need.
Click the lower browser icon and navigate to your image. If your image File is in one of Mayas default folders such as “Documents/Maya/Maya2014x64/prefs/icons” you can remove the absolute path and just use the file name and suffix. By clicking “OK” the image will appear in your UI as well as in the uiBuilder. Your windows size will update automatically to fit your image.
If you close the uiBuilder for some reason and open it again it will display the default image. Set the ui.mel file and image file again and press the “OK” buttons. If the Image path is the same as before, it will not add an extra line in your interface file but will only add the image to the uiBuilder.
set up multiple interfaces
If you duplicate the ui.mel and try to use both files at the same time each Window will close the other. To use multiple windows you need to change the prefix right under the file browsers. Activate the checkbox “change Prefix” and a small window will open. If this isn’t the first time you work with a new window just click “OK” and go ahead. If it is the first time you work on an extra Interface click “setup file for new prefix” in this window. This will again open a little window. Here you can search and replace the whole source text of your UI file. Just replace the old prefix (default is “XXX_”) with a prefix of your choice. If you close and reopen the uiBuilder before you finished your interface, remember to change the prefix again, because every object you create or edit in the UI will use the prefix from the prefix field. You do not need to search and replace again, just type your prefix in the prefix textfield.
Place the button with the sliders at the top and right in the uiBuilder. The button in the top right corner mirrors the position.
Click the button in the uiBuilder to preview the result in your UI.
There are 5 options for the buttons: Tool, Size, Color, Label and Name.
Tool will change the the tool whenever the button is clicked to either “Move”, “Rotate” or “Scale”. If you choose “none” the tool will not change when the button is clicked. You can also disable the tool changing in the interface by deactivating the “change tool” checkbox in your interface.
Size will resize your button. There are 3 preset sizes but you can also choose a custom size with the width and height fields next to the preset buttons.
Use the colorslider to change the color of your button or pick one of the three presets. By rightclicking the preset buttons you can save the current slider-color as a preset.
To display a label on the button simply type it into the label textfield.
Choose a describing name and type it into the name textfield. Every button in the UI needs to have a unique name. The button name is important when editing existing buttons. Mouseover a button in the Interface to see its name.
Select one or more objects in your scene that should be selectable with the button. Click the big “create” button in the lower left corner to finish the button creation. Your UI will update and show the new button. It should already be working now. The UI-preview-button is hidden, to display it click the preview button in the uiBuilder again.
undo and redo
If the UI file errors after some action or you made a mistake you can use “edit → undo” from the menu at the top. This will not change anything in the uiBuilder but reset your UI file to the last version. There are only three undo steps so I recommend you duplicate your UI file from time to time if you’re working on a complicated Interface. Also the undo steps are only available as long as the uiBuilder is opened. If you close and re-open it all undo data will be lost.
Redo, of course, is the same thing just the other way around.
To change any attribute of an existing button in your interface type the button name into the textfield right over the edit button. If you don’t know a buttons name mouseover it in the Interface and its name will appear. It doesn’t matter whether you type the name with or without prefix – just be sure your prefix in the prefix field is still correct.
Set the attributes of the preview button so they match what you want to edit. By clicking the edit button a window with a few checkboxes opens. Select which settings should be edited. Attributes that are not checked will not be influenced. For example of you want to make a blue button green it doesn’t matter where the preview button is in the uiBuilder, how big it is, what the label is or what your selection and tool is. Only the color will be affected.
Click “OK” to change the button. The UI will open again with your updated button.
Each edit of a button will add an extra line of code into the UI file. A lot of edits may increase the file size a little but more important: it will be confusing when someone tries to edit the script in the script editor.
edit namespace and tool controls
The “namespace” field and “change tool” checkbox are already in the UI file. They are on the top of the Interface by default. To place them somewhere else put the preview button in the desired place. The top left corner of the button is crucial for the placement. Choose “Modify → place both” from the menu at the top. Your UI will open again with both objects in the right position. You can of course place each of the both objects alone by choosing “Place Namespace Field” or “Place Tool Checkbox” in the “Modify” menu.
To change the default namespace or toolbox setting, first set the field or box to the desired value. Next, choose “Modify → Set Namespace Default” or “Modify → Set Tool Box Default” from the menu at the top. Your Interface will re-open with your settings.
As with the button edits, every edit will add an extra line of code to the UI file.
If you are familiar with MEL you may want to edit the Interface further after you finished your work with the uiBuilder. In that case it’s a good idea to add some comments into the code for clarity.
To add a comment activate it with the checkbox next to “comments”. The textfield is now editable. Type a comment for the button you create in that field. No special characters (such as //) are required. The comment will be added into the script when you create the button.
If you edit a button the comment will be added at the line where the button is edited.
Deactivate the checkbox and no comment will be added. There’s no need to empty the textfield.
By checking “empty line” an empty line will be added into the code before the comment and button are written.
When you’re done adding buttons, close the uiBuilder for you don’t need it anymore. Hide your control curves in the viewport and use the buttons in the Interface to select them. You can shift-click a button to toggle selections, ctrl-click to subtract selections and shift-ctrl-click to add selections just as you would in the viewport.
By right-clicking a button a small menu opens. You can set Keyframes for translate, rotate and sale, or for all keyable attributes of the objects connected to the button. This will only set Keys for this buttons objects, not any shift-selected objects. To Key all selected objects just use the normal shortcuts as always :)
When working with references the buttons won’t work on their own. In that case type the namespace into the namespace field and everything will work again.
To use the Interface on another computer just make sure that the background image is in the right folder.