Feature Settings
FeatureSetting object, is a setting object, which is bound to a Feature. These objects can be casted to other higher-level setting.
Creating a Setting
To create a FeatureSetting, simply call addSetting
on the Feature object. Let's start with CheckboxSetting (checkbox
):
This method will return a higher-level FeatureSetting object, which has the properties of the corresponding type, meaning you don't have to call .as('CheckboxSetting')
, for example.
Creating a ComboSetting (combo
) isn't difficult either:
Here, instead of false, we supply an object instead, because a setting value is unique to each setting type. Let's break down the parameters:
String Array of Combobox elements
Index of the default element in the abovementioned array. Array indexes start with 0
To create a SliderSetting (slider
), you need to do the following:
Default value for the Slider setting
Minimum allowed value
Maximum allowed value
1, 2, 3 can either be decimal or integer; you can't mix number types!
To create a MultiComboSetting (multi_combo
), use the following snippet:
As you can see, we use an object here instead of a simple argument. The keys (1) in this object are the Elements' names, and values (2) - are the Elements' default states.
Creating a ColorSetting (color
) is trivial:
Hex color code (can be obtained by using
rgb(0, 255, 0)
orrgba(0, 255, 0, 255)
, for example.
Once you create a Setting, you can assign the function call to a variable and use it afterwards in your Script. Take a look at your Setting's Properties in order to find out what you can do with it.
Overrides
You're able to override shouldShow
/interactCallback
, by passing a 4th argument - object, to the addSetting method, which may contain these function definitions:
Properties
Type | Name | Description | Signature |
---|---|---|---|
field | featureSettingType | Type of the FeatureSetting ( | string |
function | getReference | Returns the Feature, that this setting is assigned to. | Feature() |
function | shouldShow | Whether the setting should be currently displayed. | boolean() |
function | interactCallback | Runs the setting's interact callback. | void() |
Inherits (higher-level objects)
CheckboxSetting
Type | Name | Description | Signature |
---|---|---|---|
function | toggle | Toggles the setting's state | void() |
function | isEnabled | Whether the setting is enabled | boolean() |
function | setEnabled | Sets the setting's state | void(boolean) |
function | isDefaultState | Returns the setting's state on the default config | boolean() |
ComboSetting
Type | Name | Description | Signature |
---|---|---|---|
function | getElements | Returns the combobox's elements | string[]() |
function | getCurrentElement | Returns the current active element's index | int() |
function | getCurrentElementAsString | Returns the current active element's name | string() |
function | getDefaultState | Returns the default active element index | int() |
function | setCurrentElement | Sets the current element by index | void(int) |
function | setCurrentElementByName | Sets the current element by name | void(string) |
function | isExtended | Whether the combobox is extended in the UI | boolean() |
function | setExtended | Sets the extended UI state | void(boolean) |
SliderSetting
Type | Name | Description | Signature |
---|---|---|---|
function | getMinValue | Returns the slider's minimum value | decimal() |
function | getMaxValue | Returns the slider's maximum value | decimal() |
function | getCurrentValue | Returns the slider's current value | decimal() |
function | getDefaultState | Returns the slider's default value | decimal() |
function | setCurrentValue | Sets the slider's value | void(decimal) |
function | setCurrentValueIgnoreNormalize | Sets the slider's value without rounding | void(decimal) |
field | type | Slider's type ( | string |
MultiComboSetting
Type | Name | Description | Signature |
---|---|---|---|
function | add | Adds an Element to the setting | void(string, boolean) |
function | isSelected | Whether the Element by this index is selected | boolean(int) |
function | byName | Returns an Element by its name | Element(string) |
function | getElements | Returns the setting's Elements | List<Element>() |
Object Element is a MultiComboSetting's entry, its state can be set to true/false.
Type | Name | Description | Signature |
---|---|---|---|
function | isSelected | Whether the Element is selected | boolean() |
function | setSelected | Sets the Element's state | void(boolean) |
function | getName | Returns the Element's name | string() |
function | isDefaultState | Returns the Element's default state | boolean() |
function | toggleSelection | Toggle the Element's state | void() |
ColorSetting
Type | Name | Description | Signature |
---|---|---|---|
function | getColor | Returns the current HEX color | int() |
function | setColor | Sets the current HEX color | void(int) |
Last updated