![]() ![]() Rect rect = EditorGUILayout.GetControlRect() Protected override void DrawPropertyLayout(GUIContent label) Public class MyStructDrawer : OdinValueDrawer Value.Y = EditorGUI.Slider(rect.AlignRight(rect.width * 0.5f), "Y", value.Y, 0, 1) Value.X = EditorGUI.Slider(rect.AlignLeft(rect.width * 0.5f), "X", value.X, 0, 1) We can also use this property to assign any changes. ![]() We can get the current value of the property from ValueEntry.SmartValue. Rect = EditorGUI.PrefixLabel(rect, label) Īnd, finally, we can draw our struct's fields. Keep in mind that in Odin labels are optional, and so the label passed to this method might be null. We also want to draw a label for our property. This also lets our drawer work with the rest of Unity's IMGUI system. We can get this by calling into Unity's layout system. The first thing we will need in this drawer is an area to draw in. protected override void DrawPropertyLayout(GUIContent label) We need to override the DrawPropertyLayout method for this. Next, let us start implementing the actual drawing. public class MyStructDrawer : OdinValueDrawer Since we are making a drawer for MyStruct we will specify MyStruct for the generic argument for the OdinValueDrawer. The Serializable attributes tells Unity to serialize fields of this type.įor the drawer, we will create a new class named MyStructDrawer and inherit from OdinValueDrawer. Our drawer will draw these two fields, each with its own slider and on a single line. The struct for this purpose will contain two public float fields, an X and a Y. For this reason, they are often among the last drawers in the drawer chain, and will usually not continue the chain. Value drawers are the most basic types of drawers in Odin, and are often the drawers that actually end up doing the final drawing of a property in the inspector. The goal of this guide is to create a simple custom Odin value drawer for a custom struct type. Manage licenses through Unity with Odin DRMĭownload and import an Odin DRM enabled build Inviting a license manager to your organization Invite members to your organization and assign licensesĪutomatically assign licenses to team membersĪssign a specific license to a single user Manage and distribute Odin licenses within your organization Using Property Resolvers and Attribute Processors Understanding Generic Constraints On Odin DrawersĬreate A Custom Group with Unity and Odin Inspector Serializing Without Serialized base classes Making Save Games With The Odin Serializer How to Use Odin Inspector with Scriptable ObjectsĬustom Editor Windows Made Easy with Odin Inspector Save Space with Odin Composite Attributes The OdinSerialize And The ShowInInspector Using The Validator In Your Custom Pipeline How to Create a Custom Inspector with Odin? Install Odin Inspector as a Unity package ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |