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: README.md
+96-20Lines changed: 96 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,8 @@ This package is part of [UnityMvvmToolkit](https://github.com/LibraStack/UnityMv
8
8
-[Folder Structure](#cactus-folder-structure)
9
9
-[Installation](#gear-installation)
10
10
-[How To Use](#joystick-how-to-use)
11
+
-[UxmlElement](#uxmlelement)
12
+
-[UxmlAttribute](#uxmlattribute)
11
13
-[Contributing](#bookmark_tabs-contributing)
12
14
-[Discussions](#discussions)
13
15
-[Report a bug](#report-a-bug)
@@ -57,13 +59,15 @@ You can install **UnityUxmlGenerator** in one of the following ways:
57
59
58
60
You can add `https://github.com/LibraStack/UnityUxmlGenerator.git?path=src/UnityUxmlGenerator.UnityPackage/Assets/Plugins/UnityUxmlGenerator` to the Package Manager.
59
61
60
-
If you want to set a target version, UnityUxmlGenerator uses the `v*.*.*` release tag, so you can specify a version like `#v0.0.1`. For example `https://github.com/LibraStack/UnityUxmlGenerator.git?path=src/UnityUxmlGenerator.UnityPackage/Assets/Plugins/UnityUxmlGenerator#v0.0.1-preview1`.
62
+
If you want to set a target version, UnityUxmlGenerator uses the `v*.*.*` release tag, so you can specify a version like `#v0.0.1`. For example `https://github.com/LibraStack/UnityUxmlGenerator.git?path=src/UnityUxmlGenerator.UnityPackage/Assets/Plugins/UnityUxmlGenerator#v0.0.1`.
61
63
62
64
</details>
63
65
64
66
## :joystick: How To Use
65
67
66
-
To create a custom control, just add the `[UxmlElement]` attribute to the custom control class definition. The custom control class must be declared as a partial class and be inherited from `VisualElement` or one of its derived classes.
68
+
### UxmlElement
69
+
70
+
To create a custom control, just add the `[UxmlElement]` attribute to the custom control class definition. The custom control class must be declared as a partial class and be inherited from `VisualElement` or one of its derived classes. By default, the custom control appears in the Library tab in UI Builder.
67
71
68
72
You can use the `[UxmlAttribute]` attribute to declare that a property is associated with a `UXML` attribute.
69
73
@@ -85,52 +89,124 @@ public partial class CustomVisualElement : VisualElement
By default, the property name splits into lowercase words connected by hyphens. The original uppercase characters in the name are used to denote where the name should be split. For example, if the property name is `CustomAttribute`, the corresponding attribute name would be `custom-attribute`.
155
+
156
+
The following example creates a custom control with custom attributes:
Use the `[UxmlAttribute]` constructor to provide a default value for an attribute. Note that the provided value type and the property type must match. The only exception is for the `Color` type, where you must pass the name of the desired color.
0 commit comments