- Modules
- Master Controllers
- Creating Master Controller Widgets
Creating Master Controller Widgets
T-HSCP-002-004
The UI script linked to a Master Controller node is called when the Master Controller node is selected and the user uses the Show Control command to display its controls in the camera view, which calls the onShowControl method of the Controller object of the node. Hence, to make the Master Controller node display a widget, you must define its widget in a function that overrides this method.
The following example overrides a Master Controller's onShowControl method with a function that creates a basic slider widget. Simply copy and paste it to your UI script to test its effect.
// When Show Controls is called from the Harmony UI, create a script widget
// and register it to the main Controller.
Controller.onShowControl = function()
{
// Initialize the array of widgets
Controller.controls = [];
// Add a slider widget.
Controller.controls.push(new SliderWidget());
}
Similarly, you can handle the case where the control is hidden using the onHideControl method.
// Called when the user hides the Master Controller node controls
Controller.onHideControl = function()
{
MessageLog.trace("Slider hidden.");
}
It is possible to create a Master Controller with several widgets. For example, you can combine a TranslationXWidget and TranslationYWidget to make a 2D Translation widget by creating them as elements of the same Controller.controls array.
// Create a TranslationX and TranslationY widget in the same Master Controller.
Controller.onShowControl = function()
{
// Initialize the array of widgets
Controller.controls = [];
// Add the TranslationX and TranslationY widgets
Controller.controls.push(new TranslationXWidget());
Controller.controls.push(new TranslationYWidget());
}
Save your script, then refer to the following topic to display and use the Master Controller's widget.
Time Estimated 25 mins
Difficulty Level Advanced
Topics List
- Introduction to Master Controllers
- Creating a Master Controller
- Creating Master Controller Widgets
- Setting the Properties of a Master Controller Widget
- Updating an Element's Attribute when Manipulating a Master Controller Widget
- Linking Attributes Between Master Controller Widgets
- Updating the Attributes of a Master Controller Widget
- Connecting Master Controller Widgets to Nodes
- Applying the Coordinates of a Master Controller Widget to Nodes
- Applying the Coordinates of a Master Controller Widget to Deformers
- Controlling Nodes Connected to a Master Controller
- Referring to the Master Controller Node
- Master Controllers Examples
Support
Help and FAQ
Toon Boom Forum
Contact us