Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[UPDATED!] Free and Open Source UIElements based controls and attributes available

Discussion in 'UI Toolkit' started by larsolm5853, Oct 29, 2019.

  1. larsolm5853

    larsolm5853

    Joined:
    Oct 24, 2017
    Posts:
    21
    #region UPDATE:

    With the official release of 2019.3 we have pushed a pretty substantial update to this package! We added a couple more controls, more options for old controls, numerous bug fixes and new API that more similarly matches Unity's API for its controls. We also included some much more robust samples, showing UXML, C# and attribute versions of all controls. Because this is a pretty robust update there will likely be a couple of compiler issues from where the API changed but nothing too time consuming to correct. Feel free to access the repository here and let us know if you have any questions or issues!

    #endregion

    Hey everybody!

    I just opened up the editor utility repository I've been slowly building up for some internal projects. It's basically a suite of UIElements based attributes, drawers, controls, and other helpers to aid in making organized and well styled inspectors without the need of additional custom editors.

    The most important feature imho are the List and Dictionary drawers and the ability to add multiple attributes to different fields to combine their effects.

    Right now since Unity is still transitioning and custom property drawers don't work with UIElements it uses a single default custom editor to emulate that behavior. This won't affect your current custom editors.

    This also uses the new git packaging system so it won't clutter up your assets folder! Just add https://github.com/pirhosoft/PiRhoUtilities.git#upm as a git path in the package manager and it will import automatically.

    You can check out the github repository here for a complete lowdown on the available features but here's a quick list of all the attributes that are currently included:

    Custom Controls

    [List/Dictionary]
    (These are by far the two most useful!)

    [ObjectPicker]
    [ScenePicker]
    [TypePicker]
    (show's a searchable, AddComponent like menu for picking)

    [Popup]
    (to show a dropdown of either strings, floats, or ints)

    [ComboBox]
    (enter a custom string or a choose from a dropdown)

    [Group]
    (show multiple difference fields in an organized group)

    [Rollout]
    (show a classes members as a well styled collapsible group)

    [Inline]
    (show a classes members inline)

    [Euler]
    (put on a quaternion field to display it readably)

    [Slider]
    (like the current range attribute but works with Vector2)

    [EnumButtons]
    (show the enum as buttons instead of a dropdown)

    Custom Traits

    [Conditional]
    (conditionally show this field based on the value of another field, method, property)

    [ChangeTrigger]
    (trigger a method when the value changes)

    [InspectTrigger]
    (trigger a method when the owning object is selected)

    [Required]
    (this Object or string cannot be null)

    [Button]
    (show a button that will trigger a method when clicked)

    [Minimum]
    [Maximum]
    [Snap]
    (validate the value to be at least, at most, or an increment of)

    [Placeholder]
    (show placeholder text in a text field)

    [Delay]
    (delay the value change in a text field until it is confirmed)

    [Multiline]
    (make a text field a multiline textbox)

    [MaximumLength]
    (limit the number of characters in a text field)

    [ReadOnly]
    (disable all controls for the field)

    [Stretch]
    (show the control below the label instead of next to it)

    [CustomLabel]
    (change the text of a label to something different than the field name)

    [NoLabel]
    (don't show the label for this field)

    Feedback, bugs, suggestions, requests, are all very welcome!
     
    Last edited: Feb 6, 2020
  2. PassivePicasso

    PassivePicasso

    Joined:
    Sep 17, 2012
    Posts:
    100
    FYI, one of the new features in 2020 is serializing generic classes without requiring concrete implementations.

    https://unity3d.com/alpha/2020.1a

    Scripting: The serializer can now serialize fields of generic types (e.g. MyClass<int> someField) directly; it is no longer necessary to derive a concrete subclass from a generic type in order to serialize it.

    On a side note, I noticed you don't have a license on your project, you may want to add one.
     
  3. larsolm5853

    larsolm5853

    Joined:
    Oct 24, 2017
    Posts:
    21
    Wow that is fantastic news and will likely make a lot of people (including me!) very happy. I feel like that's been a long time coming.

    Also yeah thanks for the heads up. The package branch had a license that shows up in the Package Manager but definitely needed to stick that at the root of the main branch as well.
     
  4. larsolm5853

    larsolm5853

    Joined:
    Oct 24, 2017
    Posts:
    21
    Though part of the reason making a derived class of List is necessary is because Unity special cases arrays and lists to add attributes to every item in that list instead of the list itself. This makes it impossible to have a custom drawer for purely a list without taking over complete control of the inspector and doing reflection magic. As for Dictionary, since they aren't serializable in the first place a custom class is needed to manage the key/value pairs. Hopefully we get Dictionary serialization soon as well because I hate the wrapper class solution.
     
  5. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    On the topic of the generic type serialization, will that also be working with the JSONUtility class? If so I can probably delete TONNES of code and upgrade.
     
  6. larsolm5853

    larsolm5853

    Joined:
    Oct 24, 2017
    Posts:
    21
    Just pushed a pretty big update to this package. See updated original post.