Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Assets [WIP] Odin Inspector & Serializer Looking for Feedback

Discussion in 'Works In Progress' started by jorisshh, Feb 22, 2017.

  1. SuneT

    SuneT

    Joined:
    Feb 29, 2016
    Posts:
    33
    The latest version of Odin is out, and here's the changelog :)

    Odin Inspector & Serializer v. 1.0.4.0 + 1.0.4.1 changelog
    Upgrade notes for 1.0.4.0:

    • Delete the Sirenix/Demos folder before upgrading, as we have deleted a demo script that is now obsolete.
    Highlights:
    • Added a new attribute called InlineProperty which can be applied to classes, structs and members. Instead of drawing the value in a foldout, Odin will draw the label to the left and its inner content to the right.[​IMG]
    • Added a new attribute Called LabelWidth which changes the width of the label.
    • Deprecated the ShowForPrefabOnly and EnableForPrefabOnly attributes and added 8 new prefab related attributes which gives you much more control.
      • Added a new attribute called DisableInPrefabs which disables a property if it is drawn from a prefab asset or a prefab instance.
      • Added a new attribute called HideInPrefabs which hides a property if it is drawn from a prefab instance or a prefab asset.
      • Added a new attribute called HideInPrefabInstances which hides a property if it is drawn from a prefab instance.
      • Added a new attribute called HideInPrefabAssets which hides a property if it is drawn from a prefab asset.
      • Added a new attribute called HideInNonPrefabs which hides a property if it is drawn from a non prefab instance or asset.
      • Added a new attribute called DisableInPrefabInstances which disables a property if it is drawn from a prefab instance.
      • Added a new attribute called DisableInPrefabAssets which disables a property if it is drawn from a prefab asset.
      • Added a new attribute called DisableInNonPrefabs which disables a property if it is drawn from a non-prefab asset or instance.
        [​IMG]
    • Added a new attribute called HideInInlineEditors which hides a property if it is drawn within an InlineEditorAttribute.
      [​IMG]
    • Completely revamped the [ValidateInput] attribute. It can now detect changes to child values, as well as customize the error message and type - see the updated demo example. Additionally, it now also runs validation when an undo or redo is performed. Finally, support for preventing/rejecting invalid value changes has been removed from [ValidateInput], as it did not work correctly before in many cases, and proved infeasible to implement properly.
      [​IMG]
    • Upgrades to HorizontalGroup
      [​IMG]
      • Added PaddinLeft, PaddingRight, MinWidth and MaxWidth properties.
      • All properties now supports percentage. This includes Width, Min and Max Width, Padding and Margin. Values between 0 and 1 will be treated as percentage, 0 = ignored, otherwise pixels.
      • All properties are no longer private set.
      • Fixed an issue where horizontal groups start out too wide and slowly becomes the right size over time as the inspector window updates.
      • HorizontalGroup no longer sets the label width based on the width of the columns. This means that you can now do stuff like this: (and still maintain a proper label width which you couldn't do before).
        [​IMG]

    Fixes:
    • Fixed bug where Color and Color32 couldn't be properly copy pasted.
    • Unity's own context menu for Color and Color32 fields no longer shows up when the field is right-clicked.
    • Fixed issue where references to members with [HideInInspector] on them would not be drawn when the reference is expanded.
    • Fixed case where strings and boxed enums that were exact the same object instance would count as references to each other in the inspector.
    • Fixed rare error where changing a value's type between two different strongly typed list types would cause internal errors in the property system when updating a property's chlidren.
    • Fixed error where [ValueDropdown] wouldn't work properly with polymorphism.
    • Fixed error where [ValueDropdown] wouldn't work on list elements.
    • Fixed various errors with flag enums causing invalid cast exceptions. These should no longer happen, regardless of the enum's values and underlying type.
    • Fixed issue in DeepReflection with invalid IL code being emitted for invoking methods on value type instances. This was causing various attributes such as ShowIf and HideIf to throw exceptions when used in structs and referring to property and method members.
    • Fixed case where dictionaries that were referenced polymorphically would cause the inspector to break.
    • Fixed a lot of GUI Spaceing issues.
    • InfoBoxes now also work on methods.
    • Fixed issue, where int fields couldn't be changed with sliding, if mouse movement was too slow.
    • Fixed possible compiler error when compiling to iOS on xcode.
    • Fixed invalid generic argument exceptions being caused by enum serialization on the new .NET 4.6 scripting backend.
    • Fixed bug on the new 4.6 experimental scripting runtime where emitting a serialization formatter for an empty type with no values to serialize would cause Unity to crash, due to incorrect parsing of the emitted empty IL code.
    • Fixed compiler errors in new group system source code when using Unity's old compiler.
    • Fixed rare case where a missing editor type could cause compiler errors when generating editors.
    • MemberFinder now correctly includes the requested method parameters in the error message when it fails to find a member.
    • 1.0.4.1: Fixed case where AssemblyUtilities might throw an ArgumentOutOfRangeException when processing assemblies that are not located anywhere within the project folder.
    • 1.0.4.1: Fixed an issue where interacting with an object field in a box group, would cause all box backgrounds change color slightly.
    • 1.0.4.1: Button size now works with ButtonGroups.
    • 1.0.4.1: Fixed an issue where the hover effect for foldouts was delayed.

    Changes:
    • Lowered most error logs in DelegateFormatter to warning level, as many of them can occur in perfectly legitimate situations.
    • All members marked with [HideInInspector] now have a default property order value of int.MaxValue, by default placing them last in the order of properties. This ensures that it is only in very rare cases that there will be references to members that are hidden.
    • Enum flag names in the flag dropdown now have nicified names.
    • OdinEditorWindow now implements a scroll-view, and ensure the window is repainted when needed. A bit of padding around the drawn content has also been added.
      [​IMG]
    • DefaultSerializationBinder now also tries to resolve type names using AssemblyUtilities.GetType.
    • Slightly altered the sensitivity of field sliding to be a bit higher around a value of 0.
    • Updated Demo Scene and Documentation.
    • Improved error messages received when incorrectly applying the [ShowOdinSerializedPropertiesInInspector] attribute to classes that are not specially serialized and do not support special prefab serialization.
    • Property labels in tab groups now align with labels outside of tab groups.
    • Changed InfoBoxAttributeDrawer's priority to (0, 10001, 0)
    • Changed SpaceAttributeDrawer's priority to (1.1, 0, 0)
    Additions:
    • Added a very rudimentary Delegate drawer.
    • Odin now correctly guesses that fixed size buffers are serialized by Unity in version 2017.1 and up.
    • Added RectExtensions.ExpandTo.
    • Added new constructor to [OnInspectorGUI] that lets you specify two methods to invoke: a method to prepend, and a method to append.
      [​IMG]
    • Added support to Odin for drawing types derived from NetworkBehaviour, and added the SerializedNetworkBehaviour type. Note that [SyncVar] and SyncLists still have the exact same limitations as before, regardless of whether Odin is serializing the type or not.
    • The HideIf and Showif attributes now have an options to disable the fade in and fade out animations.
    • The DictionaryDrawerSettings attribute now has an option to marke a dictionary ReadOnly as well as changing the labels for the Key and Value columns.
    • Added a TextureUtilities class containing static helper functions.
    • Added support for injecting GUI before and after each element is drawin inside a list. This is achived using the [ListDrawerSettingsAttribute(OnBeginListElementGUI = "OnBeginListElementGUIMethodName", OnEndListElementGUI = "OnEndListElementGUIMethodName")].
      [​IMG]
    • Added support to the ListDrawerSettings attribute for defining custom label text for each list element. This is achived using the [ListDrawerSettingsAttribute(ListElementLabelName = "ListElementLabelName")].
      [​IMG]
    • Added PropertyTree.OnUndoRedoPerformed
    • 1.0.4.1: You can now override the number of items per page for lists via the ListDrawerSettings attribute.
      [​IMG]
    • 1.0.4.1: The TabGroup attribute now also supports naming tabs dynamically using the $ sign.
      [​IMG]
    • 1.0.4.1: Added a very rudimentary VerticalGroup attribute. This is particularly usefull if you want to make columns using HorizontalGroups.
      [​IMG]
      We'll be introducing more features to this attribute in the future.

    Check out Odin Inspector & Serializer on the Asset Store!
     
    Last edited: Jul 30, 2017
    Peter77 likes this.
  2. Dennin-Dalke

    Dennin-Dalke

    Joined:
    Aug 10, 2014
    Posts:
    7
    Hey guys, just to get an update, any news regarding UWP support? Is there any work around or any rudimentary support that would possible to use on this platform at the moment?
     
  3. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    65
    There is currently no workaround I'm afraid. :( But we are actively working on it. If you want to get the build as soon as possible, and are up for testing it a bit as well, then shoot us an email with your Odin Invoice id (for verification), and I'll send you a build as soon as we have something working.
     
    Last edited: Aug 2, 2017
  4. Dennin-Dalke

    Dennin-Dalke

    Joined:
    Aug 10, 2014
    Posts:
    7
    I'll be definitely happy if I can help testing the builds, I sent the details to the support contact on the Sirenix site.
     
    bjarkeck likes this.
  5. vudong

    vudong

    Joined:
    Feb 6, 2015
    Posts:
    13
    While I execute as Button a function and Start game function miss ?!
     
  6. Tor-Vestergaard

    Tor-Vestergaard

    Joined:
    Mar 20, 2013
    Posts:
    82
    I'm afraid I'm not sure what exactly your issue is. Could you please clarify, or post some screenshots?
     
  7. SuneT

    SuneT

    Joined:
    Feb 29, 2016
    Posts:
    33
    Here's a GIF of the latest work on displaying lists and two-dimensional arrays as tables in Odin.

    [​IMG]
     
  8. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    729
    Tables gui.... yes please.
     
    bjarkeck likes this.
  9. Dennin-Dalke

    Dennin-Dalke

    Joined:
    Aug 10, 2014
    Posts:
    7
    OMG Looks amazing! Good stuff!!
     
    bjarkeck likes this.
  10. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    803
    is it possible to have scroll for texts/string or to have inline for TextAssets?
    great asset btw!
     
  11. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    65
    Thanks!

    Like this?

    Code (CSharp):
    1. [SerializeField]
    2. [TextArea(minLines: 10, maxLines: 20)]
    3. private string textArea;
    4.  
    5. [InlineEditor]
    6. [SerializeField]
    7. private TextAsset inlineTextAsset;
    I've just added a MaxHeight property to the InlineEditor attribute so that you can get a scroll wheel on that as well:

    Code (CSharp):
    1. [InlineEditor(MaxHeight = 200)]
    2. [SerializeField]
    3. private TextAsset inlineTextAsset;
    If the inline editor exceeds the specified maximum height, a scrollbar will appear. Setting MaxHeight to 0, will disable MaxHeight and show the entire Editor inline. Default MaxHeight is 0.

    asagfwe.png

    There is also the [OnInspectorGUI] attribute which is can be useful if you want a quick custom solution. In the next patch, we've added a new [CustomValueDrawer] attribute which is often an even better solution as it supports, multi-selection and undo, and can be combined with other attributes as well.

    CustomValueDrawer.gif

    If it doesn't quite suit your needs, or have any suggestions let me know :)
     
  12. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    803
    That's great, it works!
    I was using SerializedScriptableObject but wanted to convert to OdinEditorWindow, it works good but i have noticed that it doesn't serialize, list are cleared every time when i open window also, all other things are nulled...is there something that i am missing?

    also i can't name the window, i tried

    Code (CSharp):
    1. var window =  GetWindow<InfoWindow>()
    2. window.name = "window";
    3. window.Show();
    but it doesn't work

    thank! this asset is essential!
     
  13. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    65
    Yeah, Editor windows do not store any permanent data out of the box. They are destroyed whenever you close them, so you still need to store the data somewhere, somehow, manually. If you want to store the data per-user, you can use Unity's EditorPrefs.Get/SetField, or you could keep your SerializedObject, and just draw that directly in the EditorWindow if you want. That is btw actually exactly what we are doing in the Odin Preferences window. Each editor within the window is just a ScriptableObject, that has an attribute telling what menu item it is.

    https://jumpshare.com/v/E85cHTytRusmtMI07LEs

    Instead of inheriting from ScriptableObject directly, we have a GlobalConfig base-class that is basically a ScriptableObject singleton. It's quite handy, for cases exactly like this.

    You can see the documentation for it here:

    http://sirenix.net/odininspector/documentation/sirenix/utilities/globalconfig(t)

    You can draw a ScriptableObject in an EditorWindow like this:
    Code (CSharp):
    1.  
    2. public class InfoWindow : EditorWindow
    3. {
    4.      private Vector2 scrollPos;
    5.      private Editor editor;
    6.  
    7.      [MenuItem("Test/Test")]
    8.      private static void OpenWindow()
    9.      {
    10.           GetWindow<InfoWindow>().Show();
    11.      }
    12.  
    13.      private void OnEnable()
    14.      {
    15.           this.editor = Editor.CreateEditor(InfoDataSingleton.Instance);
    16.      }
    17.  
    18.      private void OnGUI()
    19.      {
    20.           this.scrollPos = EditorGUILayout.BeginScrollView(this.scrollPos);
    21.           GUIHelper.PushHierarchyMode(false);
    22.           this.editor.OnInspectorGUI();
    23.           GUIHelper.PopHierarchyMode();
    24.           EditorGUILayout.EndScrollView();
    25.  
    26.           this.RepaintIfRequested();
    27.      }
    28.  
    29.      private void OnDestroy()
    30.      {
    31.           DestroyImmediate(this.editor);
    32.      }
    33. }
    34.  
     
    Last edited: Aug 14, 2017 at 5:04 PM
  14. zsaladin

    zsaladin

    Joined:
    Jan 20, 2015
    Posts:
    7
    Hi.
    Thank you for providing this awesome asset.
    This is my favorite asset.

    I usually use it on serializing Dictionary.
    But I have faced a problem of it.

    I just added simple codes like this.

    Code (CSharp):
    1. public class TestSerialization : SerializedMonoBehaviour
    2. {
    3.     [SerializeField] Dictionary<int, GameObject> _test;
    4. }
    I've tried to drag and drop this prefab on Hierarchy.
    Then Unity Editor crashed or froze on Windows and Mac.
    Sometimes it depends on the number of Dictionary's items.
    I tested it on 5.5.2f, 5.6.0f3, 5.6.3f1 and 2017.1.0f3. It occurs on all of them.

    I attached the sample project able to reproduce it.
    You just drag and drop the object named 'GameObject' located in 'Assets/' on any scene.
    Also Odin asset is excluded from this sample. So you should add Odin asset before test.
     

    Attached Files:

    Last edited: Aug 15, 2017 at 4:28 PM
  15. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    65
    Thank you, nice to hear you like it, thanks! And thank you for providing the sample, We'll have a look at this tomorrow and give you an update.
     
  16. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    803
    Thanks for looking into this, that was what i needed!
    I was wondering is it possible to have list displayed horizontally? I have some sprite list that would be nice to display horizontally? Is it possible?
     
  17. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    65
    Not ATM atm I'm afraid. But I've added it to our list of suggestions.:) If you want to go through the trouble of making something custom for your specific use case. You could hide the list itself using HideInInspector, then add a method with an OnInspectorGUI attribute, and start using GUILayout etc to build your custom UI. But introducing something like an HorizontalList attribute or a ListGallery attribute would currently require a lot of work. Our current ListDrawer is 900 lines of nightmare. But I do like the idea of some gallery type list view!