-
Notifications
You must be signed in to change notification settings - Fork 7
Attributes
A collection of attributes to create custom UIs for your own behaviours
The following attributes are only available to use with classes. Make sure to always inherit from UTController base class or they will not do anything.
[CustomName(string name)]
Sets a custom name shown in the controller's header bar.
Shows <NameOfControllerClass> with Controller part stripped by default, e.g. MyBehaviourController would be shown as MyBehaviour by default
[CustomName("My Fancy Controller")]
public class MyBehaviourController : UTController {}[HelpMessage(string message)]
Displays a box with some text below the controller's header bar and above the rest of the UI.
Usually used to describe the purpose of the behaviour if it is not obvious, or to warn user about anything in particular.
[HelpMessage("This behaviour should be enabled at all times")]
public class MyBehaviourController : UTController {}[ControlledBehaviour(Type udonSharpBehaviour)]
Automatically adds an UdonBehaviour of the specified type to the game object if no Udon Behaviour component is provided. Makes the setup easier for the end user, allowing them to just add the Controller which will take care of everything else.
[ControlledBehaviour(typeof(MyBehaviour))]
public class MyBehaviourController : UTController {}Note: this works by searching through UdonSharpProgramAssets to find the corresponding class. Make sure to create the program asset and the class before adding this attribute.
These attributes are meant to go on public fields of your Controller. They serve as UI buiding blocks and provide an ability to react to value changes, for example if you would like to do something specific in the scene when user checks a checkbox.
Note: these attributes use a property modifier approach, as unity doesn't allow to stack multiple property drawers otherwise. Make sure to use them in combination with a [UTEditor] or an [UdonPublic] attribute or they will not do anything. Both of those should go last in the chain, right before the public keyword.
Some attributes share parameter names. One of such parameters is methodName. In most cases you will be able to pass either a method or a variable name to it (where it makes sense, there are exceptions and they are mentioned separately).
// Will execute `ShouldShowBox` to determine whether the box should be visible
[HelpBox("", "ShouldShowBox")] [UdonPublic];
public bool active;
// Must return `bool`
public bool ShouldShowBox() {
return active;
}To use a variable instead of a method - prefix the variable name with @, you can also invert the variable value by adding ! after that.
// Will show if active is `true`
[HelpBox("", "@active")] [UdonPublic];
public bool active;
// Will show if active is `false`
[HelpBox("", "@!active")] [UdonPublic];
public bool active;This can be any public variable of a class, doesn't have to be specifically the same variable. You can use something like [HideInInspector] for storing the state of the box without displaying it in the editor.
[SectionHeader(string title)]
Displays a visual separator box with some text
[SectionHeader("General")][UdonPublic]
public Transform sourceTransform;[HelpBox(string message, [string methodName])]
Displays a box with a help message. You can provide a boolean method or a variable name to it that would be used to determine whether the message should be shown.
// Always visible
[HelpBox("This option disables rotation transfer")]
[UdonPublic]
public bool ignoreRotation;
// Only visible if provided variable is set to `true`
[HelpBox("This option disables rotation transfer", "@ignoreRotation")]
[UdonPublic]
public bool ignoreRotation;
// Only visible if provided variable is set to `false`
[HelpBox("This option disables rotation transfer", "@!ignoreRotation")]
[UdonPublic]
public bool ignoreRotation;
// Only visible if the provided method returns `true`
[HelpBox("This option disables rotation transfer", "ShowIgnoreHelp")]
[UdonPublic]
public bool ignoreRotation;
public bool ShowIgnoreHelp() {
return ignoreRotation;
}🚨 Found an issue? File an issue
💬 Join the Discord server
🕶 Support the project if you found it useful



