Phriction Documentation Mutable Mutable for Unreal Engine Create States and data driven user interfaces History Version 14 vs 22
Version 14 vs 22
Version 14 vs 22
Content Changes
Content Changes
== Overview
This article explains the steps to go from an existing customizable object to a playing character that can be modified with an interface automatically generated from the object data.
It covers the following chapters:
* **[[#create-states|Create States]]**: Allows to organize the UI, and makes the relevant modification updates as fast as possible and to have the minimum impact.
* **[[#create-data|Set UI data]]**: Allows users to see in the UI icons and text defined in the current Customizable Object. Avoids having to manually modifying the UI for each new object artists add.
* **[[#access-data|Access the UI data]]**: Allows the widget to be created with the relevant content at runtime.
---
= Create States{anchor #create-states}
This chapter covers the creation of Customizable Object States. As an example, we will create one "in-game" state to use while playing and one "clothing" state for character edition.
(IMPORTANT) Each State can contain any number of [[mutable/unreal-engine-4/user-documentation/nodes/object-group/|Group Object Nodes]] and any amount of the parameters in the Customizable Object hierarchy. A parameter can be one of the following types: [[mutable/unreal-engine-4/user-documentation/nodes/float-parameter/|Float Parameter Node]], [[mutable/unreal-engine-4/user-documentation/nodes/enum/|Enum Parameter Node]], [[mutable/unreal-engine-4/user-documentation/nodes/color-parameter/|Color Parameter Node]], [[mutable/unreal-engine-4/user-documentation/nodes/texture-parameter/| Texture Parameter Node]], [[mutable/unreal-engine-4/user-documentation/nodes/projector-parameter/|Projector Parameter Node]] and [[mutable/unreal-engine-4/user-documentation/nodes/group-projector-parameter/|Group Projector Parameter Node]].
(IMPORTANT) A child object can contain its own States. A State defined at a Child Object functions identically to a states defined at the Base Object.
(WARNING) It's advised to split character edition states into multiple coherent states as more parameters are added to the model. Parameters usually modified together, such as facial features, would go well in their own state, separate from clothing. It's uncommon to be modifying the face and the clothes at the same time. This division into states with less parameters frees resources and will allow the updates to be faster.
(NOTE) The resulting Customizable Object of this example can be found in the [[mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI// named "DataDrivenUICharacter".
== Assets required
* A Customizable Object with at least one **Group Object Node** in the hierarchy
(NOTE) The asset used in this step can be found in the [[ mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/RemoveUnseen// named "RemoveUnseen" together with the assets that create it.
== Steps
1) The first step is to create the states at the Customizable Object where they are most relevant. Add two states for the Base Object, at the **node properties States** array.
{F106506}
>In this example, the **Customizable Object** has been renamed "Data Driven UI Character"
---
2) The second step is to create an in-game state to use in situations where there's no plan on changing properties fast. Name the first state created, and make sure the options "Don't compress Runtime Textures" and "Build Only First LOD" are **off**.
{F106756}
>In this example, the **State** has been named "inGame"
---
3) The third step is to create a state to use in a character edition lobby, where many parameter changes are expected. Name the second state created, and make sure the options "Don't compress Runtime Textures" and "Build Only First LOD" are **on**.
{F106758}
>In this example, the **State** has been named "Clothing"
---
4) To finish the edition state, add the parameters are important when the state is chosen. To do so, add as many properties as needed at the **Runtime Parameters** array, and name each one of them exactly as the property that must be included in the state. For this guide it's three parameters, as the **Group Object Node** of group type **Toggle** defines one toggle parameter for each of its objects.
{F106778}
>In this example, we need three parameters, named "Boots", "Trousers" and "Shirt", the **Object Name** property of each object included in the group. We need the names of all the objects in the group only because this group is of type **Toggle**, and this type of group defines an independent parameter for each of its objects, but in the example we want to use all of them under the same state. {F106776}{F106766}
(WARNING) When the parameter comes from a group object node of types **At leat one Option** or **One or None**, the name of the parameter that the group defines is the **Group Name** {F106780}
(WARNING) When the parameter is from a parameter node, the parameter name comes from the property **Parameter Name** {F106764}
---
== Result
This is now a Customizable Object with correctly set states, ready to use under two different conditions by enabling one of its states. It is ready for a game, but contains no interface information to automatically generate one.
---
= Set UI data{anchor #create-data}
This chapter covers the addition of metadata to customizable objects to automatically create an UI.
(NOTE) The resulting Customizable Object of this example can be found in the [[mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI// named "DataDrivenUICharacter".
== Assets required
* One icon image asset for every toggle parameter.
(NOTE) The assets used in this step can be found in the [[ mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI//.
---
== Steps
1) Choose a thumbnail image for each toggle parameter. In each **Child Object Node** of the group, inside the **Parameter UI Metadata** node property, set each chosen image asset as the **UIThumbnail** property.
{F106786}
> In this example, the "Shirt" child object is given the "DDUI_Shirt" image.
{F106794}
> In this example, the "Trousers" child object is given the "DDUI_Trousers" image.
{F106798}
> In this example, the "Boots" child object is given the "DDUI_Boots" image.
---
== Result
This is now a Customizable Object with UI metadata set, ready to be used by the game in any way it sees fit when generating the UI.
---
= Access UI data{anchor #access-data}
This chapter covers how to read the UI metadata of a customizable object to adapt widgets to the character parameters. It includes the usage of the customizable object UI metadata to automatically generate an interface that allows the modification of the character and reads the character state to determine what are the parameter values when it's created.
(WARNING) This tutorial does not cover how to create a playable character, a level or how to setup a basic widget. Those are, however, provided, as mentioned at the Assets Required section. How to create a character from a [[mutable/unreal-engine-4/user-documentation/basic-concepts/#customizable-object-instance|customizable object instance]] of the customizable object that has been made in the previous steps can be done following [[mutable/unreal-engine-4/technical/#create-character| these steps]].
(NOTE) The resulting widgets of this example can be found in the [[mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI//. The widgets final configurations are "DDUI_Container_Final" and "DDUI_Toggle_Final", and the level final configuration is "DataDrivenUI_Level".
== Assets required
* A level to play in
* A customizable object instance as playing character
* A user interface container widget
* A user interface toggle button widget
(NOTE) The assets used in this step can be found in the [[ mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI//. The widgets initial configurations are "DDUI_Container_Initial" and "DDUI_Toggle_Initial", and are referred to as **container widget** and **button widget** respectively in the following steps. The level initial configuration is "DataDrivenUI_Level_Initial", and is referred to as **level**.
---
== Steps
1) The first step is to prepare the container widget to know what instance is it working with. To do so, go to the container widget graph and add a variable of the type **Customizable Object Instance reference**.
{F106828}
>In this example, the variable name is "CustomizableObjectInstance"
2) Then, expose that variable on spawn, as it is going to be used when constructing the widget. To do so, make sure the toggle buttons **Instance Editable** and **Expose on Spawn** of the instance variable are set to **on**.
{F106832}
3) Now, when the container widget is constructed, get all the parameters for the current state. To do so, access the current state and get its parameter count.
{F106844}
4) For each parameter, get its name, and from the name, the parameter data.
{F106845}
5) From the parameter data, get access to the name, type and the UI metadata.
{F106847}
6) From the type of parameter, decide what to do. In this case boolean parameters are going to create button widgets
{F106849}
7) To give the button some content, it needs to know what it represents. To do so, the first step is to store that information, so go to the button widget graph and add one variable of type **string** for the parameter name and another of type **Customizable Object Instance reference**.
{F106851}
> In this example, the parameter name is stored in a string variable named "Parmeter", and the instance in a variable named "CustomizableObjectInstance".
8) Then, expose both variables on spawn, as they are going to be used when constructing the widget. To do so, make sure the toggle buttons **Instance Editable** and **Expose on Spawn** of the instance variables are set to **on**.
{F106853}
9) To create the widget in a configuration consistent with the current value of the parameter, we have to read its current value. As it's a boolean parameter, use the bool value to set the button state.
{F106855}
10) To make the widget use the icon provided, read its value from the UI metadata, then load the resource and set the button icon to that texture.
{F106857}
11) And to complete the button widget, give it functionality. First, go to the button widget designer and enable the "On Check State Changed" event.
{F106861}
12) Then, back to the button widget graph, set the parameter to the value of the button, and update the instance to reflect the changes.
{F106863}
13) The button has to know what is modifying to actually work, so go back to the container widget blueprint, refresh the button widget spawn node, and connect the new input pins to the relevant data.
{F106859}
14) Now, to be able to give the actual instance reference to the container widget, go to the level blueprint and refresh the node "Create DDUI Container Initial Widget".
{F106834}
15) With the constructor input pin exposed, it's time to connect to it the Customizable Object Instance reference that the menu is going to modify.
{F106836}
>In this simple example, we are interested in modifying the player character, so we first get the Customizable Skeletal Component of the player and then retrieve the Customizable Object Instance reference from it.
(WARNING) You can have the customizable object instance reference stored in a more direct or more sophisticated way in your game, it's not necessary to extract it every time from a customizable skeletal component. For example, it can exist before a skeletal component and be used to construct both the customizable skeletal component and the menu that modifies it.
16) When the container widget, we also want to set the instance to a state in which it will update the relevant parameters faster. In this example, do so by setting its state from the level.
{F106840}
>In this example, the "Clothing" state is the most appropriate, as it's what the widget spawned after it will modify. The state name is verbatim the defined in the states property of the base object node of the modified customizable instance. We have changed the state before the widget is created so the widget can use the node "get current state" to know what it's modifying, but you could organize it however fits your project.
17) And when the container widget is destroyed, re-set the state to the playing mode.
{F106842}
>In this example, the playing state name is "InGame".
---
== Result
This is now a playable customizable object character in a level with an automatically generated UI that allows to change its parameters at runtime.
---
= Permission to use the DemoUI in your game
(NOTE) The fully fledged UI widgets and blueprints provided as example with the demos is free for you to copy and use for any purpose, including commercial purposes and/or further customize it to fit your needs. This applies to all the widgets and assets found inside the mutable plugin content path: //Content/UI/DynamicallyGeneratedGUI_DGGUI//.
== Overview
This article explains the steps to go from an existing Customizable Object to a playing character that can be modified with an interface automatically generated from the object data. The article covers the following chapters:
* **[[#create-states|Create States:]]:** Create an configure the multiple States.
* **[[#create-data|Set UI data:]]** Add metadata to Customizable Objects to automatically create an UI.
* **[[#access-data|Access the UI data:]]** Read the UI metadata of a Customizable Object to adapt widgets to the character parameters.
(WARNING) We recommend visiting the [[mutable/unreal-engine-4/user-documentation/basic-concepts/ | Basic Concepts ]] and [[mutable/unreal-engine-4/user-documentation/states/ | States]] pages before start creating any State.
= Create States{anchor #create-states}
This chapter covers the creation and configuration of two States: one in-game State and one edition State.
(NOTE) The resulting Customizable Object of this example can be found in the [[mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI// named "DataDrivenUICharacter".
== Assets required
* A Customizable Object with at least one **Group Object Node** in the hierarchy
(NOTE) The asset used in this step can be found in the [[ mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/RemoveUnseen// named "RemoveUnseen" together with the assets that create it.
== Steps
1) The first step is to create the States at the Customizable Object where they are most relevant. Add two States for the Base Object, at the **node properties States** array.
{F351683}
>In this example, the **Customizable Object** has been renamed "Data Driven UI Character"
---
2) The second step is to create an in-game state to use in situations where there's no plan on changing properties fast. Name the first state created, and make sure the options "Don not compress Runtime Textures" and "Build Only First LOD" are **off**.
{F351685}
>In this example, the **State** has been named "InGame"
---
3) The third step is to create a state to use in a character edition lobby, where many parameter changes are expected. Name the second state created, and make sure the options "Don't compress Runtime Textures" and "Build Only First LOD" are **on**.
{F351689}
>In this example, the **State** has been named "Clothing"
---
4) To finish the edition State, add the parameters which are important to this State. To do so, add as many properties as needed in the **Runtime Parameters** array. For this guide we are going to add all the clothing parameters.
{F351691}
>In this example, we need three parameters, named "Boots", "Trousers" and "Shirt". Because the Group Type is of type **Toggle**, it defines an independent parameter for each of its child objects. In the example, as we want to use all of the objects, we add all three parameters (one from each child). {F106776}{F106766}
(WARNING) When the parameter comes from a Group Object with the Group Type of types **Toggle**, the parameter name is the Object Name of each Child Object. {F351831}
(WARNING) When the parameter comes from a Group Object with the Group Type of types **At least one Option** or **One or None**, the name of this parameter is the **Group Name** of that Group Object. {F351833}
(WARNING) When the parameter comes from a Parameter Node, the parameter name is the **Parameter Name** from that Parameter Node. {F106764}
---
== Result
This is now a Customizable Object with correctly set States, ready to use under two different conditions by enabling one of its States. It is ready for a game, but contains no interface information to automatically generate one.
= Set UI data{anchor #create-data}
This chapter covers the addition of metadata to Customizable Objects to automatically create an UI.
(NOTE) The resulting Customizable Object of this example can be found in the [[mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI// named "DataDrivenUICharacter".
== Assets required
* One icon image asset for every toggle parameter.
(NOTE) The assets used in this step can be found in the [[ mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI//.
---
== Steps
1) Choose a thumbnail image for each toggle parameter. In each **Child Object Node** of the group, inside the **Parameter UI Metadata** node property, set each chosen image asset as the **UIThumbnail** property.
{F106786}
> In this example, the "Shirt" child object is given the "DDUI_Shirt" image.
{F106794}
> In this example, the "Trousers" child object is given the "DDUI_Trousers" image.
{F106798}
> In this example, the "Boots" child object is given the "DDUI_Boots" image.
---
== Result
This is now a Customizable Object with UI metadata set, ready to be used by the game in any way it sees fit when generating the UI.
= Access UI data{anchor #access-data}
This chapter covers how to read the UI metadata of a Customizable Object to adapt widgets to the character parameters. It includes the usage of the Customizable Object UI metadata to automatically generate an interface that allows the modification of the character and reads the character State to determine what are the parameter values when it's created.
(WARNING) This tutorial does not cover how to create a playable character, a level or how to setup a basic widget. Those are, however, provided, as mentioned at the Assets Required section. How to create a character from a [[mutable/unreal-engine-4/user-documentation/basic-concepts/#customizable-object-instance|Customizable Object Instance]] of the Customizable Object that has been made in the previous steps can be done following [[mutable/unreal-engine-4/technical/#create-character| these steps]].
(NOTE) The resulting widgets of this example can be found in the [[mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI//. The widgets final configurations are "DDUI_Container_Final" and "DDUI_Toggle_Final", and the level final configuration is "DataDrivenUI_Level".
== Assets required
* A level to play in
* A Customizable Object Instance as playing character
* A user interface container widget
* A user interface toggle button widget
(NOTE) The assets used in this step can be found in the [[ mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI//. The widgets initial configurations are "DDUI_Container_Initial" and "DDUI_Toggle_Initial", and are referred to as **container widget** and **button widget** respectively in the following steps. The level initial configuration is "DataDrivenUI_Level_Initial", and is referred to as **level**.
---
== Steps
1) The first step is to prepare the container widget to know what instance is it working with. To do so, go to the container widget graph and add a variable of the type **Customizable Object Instance reference**.
{F106828}
>In this example, the variable name is "CustomizableObjectInstance"
2) Then, expose that variable on spawn, as it is going to be used when constructing the widget. To do so, make sure the toggle buttons **Instance Editable** and **Expose on Spawn** of the instance variable are set to **on**.
{F106832}
3) Now, when the container widget is constructed, get all the parameters for the current State. To do so, access the current State and get its parameter count.
{F106844}
4) For each parameter, get its name, and from the name, the parameter data.
{F106845}
5) From the parameter data, get access to the name, type and the UI metadata.
{F106847}
6) From the type of parameter, decide what to do. In this case boolean parameters are going to create button widgets
{F106849}
7) To give the button some content, it needs to know what it represents. To do so, the first step is to store that information, so go to the button widget graph and add one variable of type **string** for the parameter name and another of type **Customizable Object Instance reference**.
{F106851}
> In this example, the parameter name is stored in a string variable named "Parmeter", and the instance in a variable named "CustomizableObjectInstance".
8) Then, expose both variables on spawn, as they are going to be used when constructing the widget. To do so, make sure the toggle buttons **Instance Editable** and **Expose on Spawn** of the instance variables are set to **on**.
{F106853}
9) To create the widget in a configuration consistent with the current value of the parameter, we have to read its current value. As it's a boolean parameter, use the bool value to set the button State.
{F106855}
10) To make the widget use the icon provided, read its value from the UI metadata, then load the resource and set the button icon to that texture.
{F106857}
11) And to complete the button widget, give it functionality. First, go to the button widget designer and enable the "On Check State Changed" event.
{F106861}
12) Then, back to the button widget graph, set the parameter to the value of the button, and update the instance to reflect the changes.
{F106863}
13) The button has to know what is modifying to actually work, so go back to the container widget blueprint, refresh the button widget spawn node, and connect the new input pins to the relevant data.
{F106859}
14) Now, to be able to give the actual instance reference to the container widget, go to the level blueprint and refresh the node "Create DDUI Container Initial Widget".
{F106834}
15) With the constructor input pin exposed, it's time to connect to it the Customizable Object Instance reference that the menu is going to modify.
{F106836}
>In this simple example, we are interested in modifying the player character, so we first get the Customizable Skeletal Component of the player and then retrieve the Customizable Object Instance reference from it.
(WARNING) You can have the Customizable Object instance reference stored in a more direct or more sophisticated way in your game, it's not necessary to extract it every time from a customizable skeletal component. For example, it can exist before a skeletal component and be used to construct both the customizable skeletal component and the menu that modifies it.
16) When the container widget, we also want to set the instance to a State in which it will update the relevant parameters faster. In this example, do so by setting its State from the level.
{F106840}
>In this example, the "Clothing" State is the most appropriate, as it's what the widget spawned after it will modify. The State name is verbatim the defined in the States property of the base object node of the modified customizable instance. We have changed the State before the widget is created so the widget can use the node "Get Current State" to know what it's modifying, but you could organize it however fits your project.
17) And when the container widget is destroyed, re-set the State to the playing mode.
{F106842}
>In this example, the playing State name is "InGame".
---
== Result
This is now a playable Customizable Object character in a level with an automatically generated UI that allows to change its parameters at runtime.
---
= Permission to use the DemoUI in your game
(NOTE) The fully fledged UI widgets and blueprints provided as example with the demos is free for you to copy and use for any purpose, including commercial purposes and/or further customize it to fit your needs. This applies to all the widgets and assets found inside the mutable plugin content path: //Content/UI/DynamicallyGeneratedGUI_DGGUI//.
== Overview
This article explains the steps to go from an existing cCustomizable oObject to a playing character that can be modified with an interface automatically generated from the object data.
It The article covers the following chapters:
* **[[#create-states|Create States]]**: Allows to organize the UI, and makes the relevant modification updates as fast as possible and to have the minimum impact.
* **[[#create-data|Set UI data]]**: Allows users to see in the UI icons and text defined in the current Customizable Object. Avoids having to manually modifying the UI for each new object artists add:]]:** Create an configure the multiple States.
* **[[#accesscreate-data|Access theSet UI data:]]**: Allows the widget Add metadata to be created with the relevant content at runtime.
---Customizable Objects to automatically create an UI.
= Create States{anchor #create-states}
This chapter covers the creation of Customizable Object States. As an example, we will create one "in-game" state to use while playing and one "clothing" state for character edition* **[[#access-data|Access the UI data:]]** Read the UI metadata of a Customizable Object to adapt widgets to the character parameters.
(IMPORTANT) Each State can contain any number of [[mutable/unreal-engine-4/user-documentation/nodes/object-group/|Group Object Nodes]] and any amount of the parameters in the Customizable Object hierarchy. A parameter can be one of the following types: [[mutable/unreal-engine-4/user-documentation/nodes/float-parameter/|Float Parameter Node]], [[mutable/unreal-engine-4/user-documentation/nodes/enum/|Enum Parameter Node]], [[mutable/unreal-engine-4/user-documentation/nodes/color-parameter/|Color Parameter Node]], [[mutable/unreal-engine-4/user-documentation/nodes/texture-parameter/| Texture Parameter Node]], [[mutable/unreal-engine-4/user-documentation/nodes/projector-parameter/|Projector Parameter Node]] and [[mutable/unreal-engine-4/user-documentation/nodes/group-projector-parameter/|Group Projector Parameter Node]]WARNING) We recommend visiting the [[mutable/unreal-engine-4/user-documentation/basic-concepts/ | Basic Concepts ]] and [[mutable/unreal-engine-4/user-documentation/states/ | States]] pages before start creating any State.
(IMPORTANT) A child object can contain its own States. A State defined at a Child Object functions identically to a states defined at the Base Object.
(WARNING) It's advised to split character edition states into multiple coherent states as more parameters are added to the model. Parameters usually modified together, such as facial features, would go well in their own state, separate from clothing. It's uncommon to be modifying the face and the clothes at the same time. This division into states with less parameters frees resources and will allow the updates to be faster= Create States{anchor #create-states}
This chapter covers the creation and configuration of two States: one in-game State and one edition State.
(NOTE) The resulting Customizable Object of this example can be found in the [[mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI// named "DataDrivenUICharacter".
== Assets required
* A Customizable Object with at least one **Group Object Node** in the hierarchy
(NOTE) The asset used in this step can be found in the [[ mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/RemoveUnseen// named "RemoveUnseen" together with the assets that create it.
== Steps
1) The first step is to create the sStates at the Customizable Object where they are most relevant. Add two sStates for the Base Object, at the **node properties States** array.
{F106506}{F351683}
>In this example, the **Customizable Object** has been renamed "Data Driven UI Character"
---
2) The second step is to create an in-game state to use in situations where there's no plan on changing properties fast. Name the first state created, and make sure the options "Don't not compress Runtime Textures" and "Build Only First LOD" are **off**.
{F106756}{F351685}
>In this example, the **State** has been named "i"InGame"
---
3) The third step is to create a state to use in a character edition lobby, where many parameter changes are expected. Name the second state created, and make sure the options "Don't compress Runtime Textures" and "Build Only First LOD" are **on**.
{F106758}{F351689}
>In this example, the **State** has been named "Clothing"
---
4) To finish the edition sState, add the parameters which are important when the state is chosento this State. To do so, add as many properties as needed at the **Runtime Parameters** array, and name each one of them exactly as the property that must be included in the state. For this guide it's three padd as many properties as needed in the **Runtime Parameters,** array. as the **Group Object Node** of group type **Toggle** defines one toggleFor this guide we are going to add all the clothing parameter for each of its objects.
{F106778}rs.
>In this example, we need three parameters, named "Boots", "Trousers" and "Shirt", the **Object Name** property of each object included in the group. We need the names of all the objects in the group only because this group is of type **Toggle**, and this type of group defines an independent parameter for each of its objects, but in the example we want to use all of them under the same state. {F106776}{F106766{F351691}
>In this example, we need three parameters, named "Boots", "Trousers" and "Shirt". Because the Group Type is of type **Toggle**, it defines an independent parameter for each of its child objects. In the example, as we want to use all of the objects, we add all three parameters (one from each child). {F106776}{F106766}
(WARNING) When the parameter comes from a Group Object with the Group Type of types **Toggle**, the parameter name is the Object Name of each Child Object. {F351831}
(WARNING) When the parameter comes from a gGroup oObject nodt with the Group Type of types **At leatst one Option** or **One or None**, the name of this parameter is the **Group Name** of that Group Object. the name of the parameter that the group defines is the **Group Name** {F106780}{F351833}
(WARNING) When the parameter icomes from aa Parameter Node, the parameter node,ame is the **Parameter Name** from that Parameter Node. the parameter name comes from the property **Parameter Name** {F106764}
---
== Result
This is now a Customizable Object with correctly set sStates, ready to use under two different conditions by enabling one of its sStates. It is ready for a game, but contains no interface information to automatically generate one.
---
= Set UI data{anchor #create-data}
This chapter covers the addition of metadata to cCustomizable oObjects to automatically create an UI.
(NOTE) The resulting Customizable Object of this example can be found in the [[mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI// named "DataDrivenUICharacter".
== Assets required
* One icon image asset for every toggle parameter.
(NOTE) The assets used in this step can be found in the [[ mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI//.
---
== Steps
1) Choose a thumbnail image for each toggle parameter. In each **Child Object Node** of the group, inside the **Parameter UI Metadata** node property, set each chosen image asset as the **UIThumbnail** property.
{F106786}
> In this example, the "Shirt" child object is given the "DDUI_Shirt" image.
{F106794}
> In this example, the "Trousers" child object is given the "DDUI_Trousers" image.
{F106798}
> In this example, the "Boots" child object is given the "DDUI_Boots" image.
---
== Result
This is now a Customizable Object with UI metadata set, ready to be used by the game in any way it sees fit when generating the UI.
---
= Access UI data{anchor #access-data}
This chapter covers how to read the UI metadata of a cCustomizable oObject to adapt widgets to the character parameters. It includes the usage of the cCustomizable oObject UI metadata to automatically generate an interface that allows the modification of the character and reads the character sState to determine what are the parameter values when it's created.
(WARNING) This tutorial does not cover how to create a playable character, a level or how to setup a basic widget. Those are, however, provided, as mentioned at the Assets Required section. How to create a character from a [[mutable/unreal-engine-4/user-documentation/basic-concepts/#customizable-object-instance|cCustomizable oObject iInstance]] of the cCustomizable oObject that has been made in the previous steps can be done following [[mutable/unreal-engine-4/technical/#create-character| these steps]].
(NOTE) The resulting widgets of this example can be found in the [[mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI//. The widgets final configurations are "DDUI_Container_Final" and "DDUI_Toggle_Final", and the level final configuration is "DataDrivenUI_Level".
== Assets required
* A level to play in
* A cCustomizable oObject iInstance as playing character
* A user interface container widget
* A user interface toggle button widget
(NOTE) The assets used in this step can be found in the [[ mutable/unreal-engine-4/examples/#village-demo | Village Demo ]] in //Content/HowTo/DataDrivenUI//. The widgets initial configurations are "DDUI_Container_Initial" and "DDUI_Toggle_Initial", and are referred to as **container widget** and **button widget** respectively in the following steps. The level initial configuration is "DataDrivenUI_Level_Initial", and is referred to as **level**.
---
== Steps
1) The first step is to prepare the container widget to know what instance is it working with. To do so, go to the container widget graph and add a variable of the type **Customizable Object Instance reference**.
{F106828}
>In this example, the variable name is "CustomizableObjectInstance"
2) Then, expose that variable on spawn, as it is going to be used when constructing the widget. To do so, make sure the toggle buttons **Instance Editable** and **Expose on Spawn** of the instance variable are set to **on**.
{F106832}
3) Now, when the container widget is constructed, get all the parameters for the current sState. To do so, access the current sState and get its parameter count.
{F106844}
4) For each parameter, get its name, and from the name, the parameter data.
{F106845}
5) From the parameter data, get access to the name, type and the UI metadata.
{F106847}
6) From the type of parameter, decide what to do. In this case boolean parameters are going to create button widgets
{F106849}
7) To give the button some content, it needs to know what it represents. To do so, the first step is to store that information, so go to the button widget graph and add one variable of type **string** for the parameter name and another of type **Customizable Object Instance reference**.
{F106851}
> In this example, the parameter name is stored in a string variable named "Parmeter", and the instance in a variable named "CustomizableObjectInstance".
8) Then, expose both variables on spawn, as they are going to be used when constructing the widget. To do so, make sure the toggle buttons **Instance Editable** and **Expose on Spawn** of the instance variables are set to **on**.
{F106853}
9) To create the widget in a configuration consistent with the current value of the parameter, we have to read its current value. As it's a boolean parameter, use the bool value to set the button sState.
{F106855}
10) To make the widget use the icon provided, read its value from the UI metadata, then load the resource and set the button icon to that texture.
{F106857}
11) And to complete the button widget, give it functionality. First, go to the button widget designer and enable the "On Check State Changed" event.
{F106861}
12) Then, back to the button widget graph, set the parameter to the value of the button, and update the instance to reflect the changes.
{F106863}
13) The button has to know what is modifying to actually work, so go back to the container widget blueprint, refresh the button widget spawn node, and connect the new input pins to the relevant data.
{F106859}
14) Now, to be able to give the actual instance reference to the container widget, go to the level blueprint and refresh the node "Create DDUI Container Initial Widget".
{F106834}
15) With the constructor input pin exposed, it's time to connect to it the Customizable Object Instance reference that the menu is going to modify.
{F106836}
>In this simple example, we are interested in modifying the player character, so we first get the Customizable Skeletal Component of the player and then retrieve the Customizable Object Instance reference from it.
(WARNING) You can have the cCustomizable oObject instance reference stored in a more direct or more sophisticated way in your game, it's not necessary to extract it every time from a customizable skeletal component. For example, it can exist before a skeletal component and be used to construct both the customizable skeletal component and the menu that modifies it.
16) When the container widget, we also want to set the instance to a sState in which it will update the relevant parameters faster. In this example, do so by setting its sState from the level.
{F106840}
>In this example, the "Clothing" sState is the most appropriate, as it's what the widget spawned after it will modify. The sState name is verbatim the defined in the sStates property of the base object node of the modified customizable instance. We have changed the sState before the widget is created so the widget can use the node "get c"Get Current sState" to know what it's modifying, but you could organize it however fits your project.
17) And when the container widget is destroyed, re-set the sState to the playing mode.
{F106842}
>In this example, the playing sState name is "InGame".
---
== Result
This is now a playable cCustomizable oObject character in a level with an automatically generated UI that allows to change its parameters at runtime.
---
= Permission to use the DemoUI in your game
(NOTE) The fully fledged UI widgets and blueprints provided as example with the demos is free for you to copy and use for any purpose, including commercial purposes and/or further customize it to fit your needs. This applies to all the widgets and assets found inside the mutable plugin content path: //Content/UI/DynamicallyGeneratedGUI_DGGUI//.