You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: UnityProjects/MRTKDevTemplate/Assets/UX Theming Example/Themes/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,10 @@
2
2
3
3
All UXComponents controls can easily be themed. New UX elements that are application specific can also be themed quite easily by creating either a new binding profile, or extending the existing UXComponents binding profile. A single script, DataBindingConfigurator, added to the root of a prefab, will do all the necessary binding.
4
4
5
-
Any data source of any kind such as DataSourceReflection, DataSourceDictionary, or DataSourceJSON can be used to provide theming data.
5
+
Any data source of any kind such as DataSourceReflection, DataSourceDictionary, or DataSourceJSON can be used to provide theming data.
6
6
7
-
The default UXComponents controls uses a ScriptableObject, MRTK_UXComponents_ThemeProfile, as a data source, which is then attached to a DataSourceReflection data source instance to retrieve data from it.
7
+
The default UXComponents controls uses a ScriptableObject, MRTK_UXComponents_ThemeProfile, as a data source, which is then attached to a DataSourceReflection data source instance to retrieve data from it.
8
8
9
9
As long as the data source uses the same naming conventions as the UXComponents controls, as seen in the MRTK_UXComponents_ThemeProfile instance of the UXCoreThemeProfile ScriptableObject, it will work properly with the standard UXComponents controls.
10
10
11
-
Although not a requirement, a helper script called ThemeProvider, can be used to make it easy to set up and provide the right profile. If this is higher in the Scene's GameObject heirarchy than the controls that depend on it, it will automatically be discovered and used because it implements IDataSourceProvider
11
+
Although not a requirement, a helper script called ThemeProvider, can be used to make it easy to set up and provide the right profile. If this is higher in the Scene's GameObject hierarchy than the controls that depend on it, it will automatically be discovered and used because it implements IDataSourceProvider.
Copy file name to clipboardExpand all lines: contributions/merging-pull-requests.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ If any of these criteria are not met, the pull request can not be merged.
22
22
23
23
## Additional considerations
24
24
25
-
Pull requests should be kept as small as possible. If a change requires a large amount of code, it should be split into smaller requests that are easier to review. When in doubt, please contact the [maintainers group](../MAINTAINERS.md)*before* opening a large pull request. They can often assist in refactoring the change into smaller pieces that facilite effective code reviews.
25
+
Pull requests should be kept as small as possible. If a change requires a large amount of code, it should be split into smaller requests that are easier to review. When in doubt, please contact the [maintainers group](../MAINTAINERS.md)*before* opening a large pull request. They can often assist in refactoring the change into smaller pieces that facilitate effective code reviews.
26
26
27
27
The pull request author should also consider adding the following before a PR is merged:
28
28
@@ -36,7 +36,7 @@ If a merged pull request breaks subsequent builds or automated tests, the author
36
36
37
37
## Blocking pull requests
38
38
39
-
There may be times when a pull request contains changes that need further consideration before approval. Such occurrences include, but not limited to, design and breaking changes. In such cases, you should block the pull request by adding the "Merge: Blocked" label, and kindly explain your reasoning for blocking. Then notify the Project's Maintainers.
39
+
There may be times when a pull request contains changes that need further consideration before approval. Such occurrences include, but not limited to, design and breaking changes. In such cases, you should block the pull request by adding the "Merge: Blocked" label, and kindly explain your reasoning for blocking. Then notify the Project's Maintainers.
Copy file name to clipboardExpand all lines: org.mixedrealitytoolkit.data/Documentation~/DataBinding.md
+25-24Lines changed: 25 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
-
# Data Binding Framework
1
+
# Data binding framework
2
2
3
-
**NOTE: This framework is still under development and APIs may change. Also see Known Limitations section below for more information.**
3
+
> [!WARNING]
4
+
> This framework is experimental, and APIs may change. Also see the [Known Limitations](#known-limitations-and-missing-features) section below for more information.
4
5
5
6
Welcome to the data binding framework of MRTK. This framework is designed to make it easy to create
6
7
visual elements that can be populated dynamically at runtime with data being provided from an external
@@ -80,7 +81,7 @@ that have registered to receive change notifications.
80
81
81
82
### Data Source Provider
82
83
83
-
A simple interface that has a single method to retrieve a data source. This is designed to allow a MonoBehavior scripting component to be auto-discovered in the game object hierarchy by data consumer components, but without the need to implement a data source directly on the game object itself. This is useful when an existing MonoBehaviour must derive from another class and multiple inheritance prevents deriving from DataSourceGOBase. It also allows more code to have no Unity dependencies.
84
+
A simple interface that has a single method to retrieve a data source. This is designed to allow a MonoBehavior scripting component to be auto-discovered in the game object hierarchy by data consumer components, but without the need to implement a data source directly on the game object itself. This is useful when an existing MonoBehaviour must derive from another class and multiple inheritance prevents deriving from DataSourceGOBase. It also allows more code to have no Unity dependencies.
84
85
85
86
### Key Path (string)
86
87
@@ -97,12 +98,12 @@ which are the two most prevalent means of transferring information from back*end
Given that a key path is an arbitrary string with no required taxonomy, the actual
108
109
data specifiers could be any method of describing what data to retrieve. XML's XPath is an
@@ -123,7 +124,7 @@ not matter where in a larger data set hierarchy it actually exists. The most cri
123
124
use of this ability is to describe the data of a single entry in a list without worrying about which
124
125
entry in that list the current instance is referencing.
125
126
126
-
Since a "fully resolved" Key path is always generated and consumed by a DataSource and should never (or at least rarely) be modified by a DataConsumer or other external component, it can have any structure that makes sense to the DataSource. For example, if a prefab to show a list entry for a photo and it's title, date taken and other attributes, the local key path in the prefab might look like this:
127
+
Since a "fully resolved" Key path is always generated and consumed by a DataSource and should never (or at least rarely) be modified by a DataConsumer or other external component, it can have any structure that makes sense to the DataSource. For example, if a prefab to show a list entry for a photo and it's title, date taken and other attributes, the local key path in the prefab might look like this:
127
128
128
129
* "photo_url"
129
130
* "title"
@@ -175,23 +176,23 @@ list of products, photos, or contacts.
175
176
This is accomplished by assigning an item placer to the collection data consumer. This item placer is the logic tha knows how to request list items, accept prefabs
176
177
that have been populated with variable data, and then present them to the user, typically by inserting them into a list managed by a ux layout component for lists.
177
178
178
-
# Theming
179
+
##Theming
179
180
180
-
Theming uses all of the plumbing of data sources and data consumers. It is possible to theme any hierarchy of GameObjects whether they are static or are dynamically data bound to other data sources. This allows for both data binding and theming to be applied in combination. It is even possible to theme the data coming from another data source.
181
+
Theming uses all of the plumbing of data sources and data consumers. It is possible to theme any hierarchy of GameObjects whether they are static or are dynamically data bound to other data sources. This allows for both data binding and theming to be applied in combination. It is even possible to theme the data coming from another data source.
181
182
182
183
## Theming UXComponents
183
184
184
-
The standard UXComponents controls provided in the UXComponents package are all configured to support theming. It is turned OFF by default, but is easy to enable.
185
+
The standard UXComponents controls provided in the UXComponents package are all configured to support theming. It is turned OFF by default, but is easy to enable.
185
186
186
187
Each control, typically on the topmost GameObject of the root prefab, has a script called UXBindingConfigurator. This script, if enabled, will pull in the needed data binding scripts to turn on theming. Make sure to import the Data Binding and Theming package as well.
187
188
188
-
**Note on TextMeshPro StyleSheets**: It is not currently possible to use StyleSheets to style the TextMeshPro *Normal* style. Any other style that is included in TextMeshPro's *Default Style Sheet* can be used. The examples use *Body* to work around this limitation.
189
+
**Note on TextMeshPro StyleSheets**: It is not currently possible to use StyleSheets to style the TextMeshPro *Normal* style. Any other style that is included in TextMeshPro's *Default Style Sheet* can be used. The examples use *Body* to work around this limitation.
189
190
190
191
## Data Consumer Theming
191
192
192
193
Theming is accomplished by Data Consumers, particularly ones that inherit from DataConsumerThemeBase\<T\>, DataConsumerTextStyle and custom DataConsumer classes that any developer can implement to enhance the theming support.
193
194
194
-
The DataConsumerThemeBase\<T\> base class provides logic to use an integer or key datum from a primary data source to then look up the desired final value from a secondary theme database. This is accomplished by mapping the input data to a theme keypath, and then using that theme keypath to retrieve the final value. This allows for any element to be both data bound and themed at the same time. As an example, imagine a status field in a database with statuses of New, Started, and Done represented by values 0, 1 and 2. Each of these can be represented by a Sprite icon. For data binding, a value from 0 to 2 is used to lookup the desired sprite. With theming and data binding, the theme profile points to the correct list of 3 sprites in the theme profile and then the value from 0 to 2 is used to select the correct sprite from that list. This allows the styling of these icons to differ per theme.
195
+
The DataConsumerThemeBase\<T\> base class provides logic to use an integer or key datum from a primary data source to then look up the desired final value from a secondary theme database. This is accomplished by mapping the input data to a theme keypath, and then using that theme keypath to retrieve the final value. This allows for any element to be both data bound and themed at the same time. As an example, imagine a status field in a database with statuses of New, Started, and Done represented by values 0, 1 and 2. Each of these can be represented by a Sprite icon. For data binding, a value from 0 to 2 is used to lookup the desired sprite. With theming and data binding, the theme profile points to the correct list of 3 sprites in the theme profile and then the value from 0 to 2 is used to select the correct sprite from that list. This allows the styling of these icons to differ per theme.
195
196
196
197
When both runtime theming and dynamic data binding are used together, a DataConsumerThemeHelper class can be specified in any DataConsumerThemeBase derived class to notify when a theme has changed.
197
198
@@ -249,15 +250,15 @@ An example for retrieving a themed status icon from a database containing a nume
249
250
250
251
### TextMeshPro StyleSheets
251
252
252
-
Theming is able to activate TMPro stylesheets. "TMP Settings" ScriptableObject dictates where stylesheets are expected to be in the Resources. It's the "Default Font Asset => Path" property.
253
+
Theming is able to activate TMPro stylesheets. "TMP Settings" ScriptableObject dictates where stylesheets are expected to be in the Resources. It's the "Default Font Asset => Path" property.
253
254
254
255
Make sure to place any app specific StyleSheets in the same sub-path off of Resources. If you wish to organize them differently, make sure to update "TMP Settings" to match.
255
256
256
257
### Making New UX Controls Themable
257
258
258
259
If you are developing new UX controls, it is relatively easy to make them themable. To the extent that the control uses Materials, Sprites, and other assets already in use by other UX controls, it is generally a matter of naming the various game objects in a discoverable way.
259
260
260
-
It's possible to inherit from the MRTK_UXCore_ThemeProfile and add more themable fields, or point your controls to your own ScriptableObject. There is nothing magical about the ones provided other than the organization of the ScriptableObject will determine the keypaths need to access individual data items, via C# Reflection.
261
+
It's possible to inherit from the MRTK_UXCore_ThemeProfile and add more themable fields, or point your controls to your own ScriptableObject. There is nothing magical about the ones provided other than the organization of the ScriptableObject will determine the keypaths need to access individual data items, via C# Reflection.
261
262
262
263
By adding a BindingConfigurator.cs script to the top level of the new control, you can then specify your own serialized BindingProfile ScriptableObject to provide the necessary GameObject name to KeyPath mappings needed to associate your themable elements with the data provided in the theme profile. This script will automatically add any needed DataConsumerXXX components at runtime to support the theming you wish to use.
263
264
@@ -270,7 +271,7 @@ By adding a BindingConfigurator.cs script to the top level of the new control, y
270
271
271
272
### Sample Scene
272
273
273
-
For a first step, take a close look at the "Data Binding Test" scene that demonstrates a variety of variable data scenarios. Simply load the scene and play. A few things to notice:
274
+
For a first step, take a close look at the "Data Binding Test" scene that demonstrates a variety of variable data scenarios. Simply load the scene and play. A few things to notice:
274
275
275
276
* The Text Input field of TextMeshPro components contain variables that look like this: {{ firstName }}
276
277
* Game objects for sprites and text have some form of Data Consumer component that manages receiving data and updating views.
@@ -289,21 +290,21 @@ Create an empty game object and rename it to "Data Binding". Add a DataSourceJso
289
290
290
291
In the inspector, change the Url to: <https://www.boredapi.com/api/activity>
291
292
292
-
Add a UI -> Text - TextMeshPro object to the Data Binding game object. It will add a canvas and then a "Text (TMP)" object.
293
+
Add a UI -> Text - TextMeshPro object to the Data Binding game object. It will add a canvas and then a "Text (TMP)" object.
293
294
294
295
Select the Text (TMP) object, and in the inspector change the Text Input to:
295
296
296
297
`{{ activity }}. It's {{ type }}.`
297
298
298
299
Select the canvas object and add a Data Consumer Text component to it.
299
300
300
-
Run the project. Every 15 seconds, a different activity will be shown.
301
+
Run the project. Every 15 seconds, a different activity will be shown.
301
302
302
303
Congratulations. You've created your first Data Binding project with MRTK!
303
304
304
305
### Writing a new Data Source
305
306
306
-
A data source provides data to one or more data consumers. It's data can be anything: algorithmically generated, in RAM, on disk, or fetched from a central database.
307
+
A data source provides data to one or more data consumers. It's data can be anything: algorithmically generated, in RAM, on disk, or fetched from a central database.
307
308
308
309
All Data sources must provide the IDataSource interface. Some of the basic functionality is offered in a base class called DataSourceBase. You most likely want to derive from this class to add the specific data management functionality specific to your need.
309
310
@@ -317,15 +318,15 @@ A data consumer gets notifications when data has changed and then updates some a
317
318
318
319
All data consumers must provide the IDataConsumer interface. Some of the basic functionality is offered in a base class called DataConsumerGOBase, where GO stands for GameObject.
319
320
320
-
The majority of the work of a data consumer is to accept new data and then prepare it for presentation. This may be as simple as selecting the right prefab, or it could mean fetching more data from a cloud service such as a content management system.
321
+
The majority of the work of a data consumer is to accept new data and then prepare it for presentation. This may be as simple as selecting the right prefab, or it could mean fetching more data from a cloud service such as a content management system.
321
322
322
323
### Writing a data collection item placer
323
324
324
325
A data collection item placer is responsible for managing which parts of a collection are currently visible and how to present that visible collection, whether the collection is a small static list, or a giant million record database.
325
326
326
-
All item placers must provide the IDataCollectionItemPlacer interface. Some of the basic functionality is offered in a base class called DataCollectionItemPlacerGOBase. All item placers should derive from this class.
327
+
All item placers must provide the IDataCollectionItemPlacer interface. Some of the basic functionality is offered in a base class called DataCollectionItemPlacerGOBase. All item placers should derive from this class.
327
328
328
-
# Known Limitations and Missing Features
329
+
##Known Limitations and Missing Features
329
330
330
331
* Need to verify proper cleanup of resources in all use cases, particularly lists.
331
332
* Dynamic changes to list data completely refreshes entire list instead of incrementally updating.
0 commit comments