Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

[RELEASED] Odin Inspector & Serializer - The Ultimate Workflow Tool ★★★★★

Discussion in 'Assets and Asset Store' started by jorisshh, Jun 15, 2017.

  1. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,278
    Love your Editor toolset. I have one thing I would like to do but do not see the way to get it to happen. Say I get a List of Directory Paths and do not know whether that is 1 or 25 and want to create buttons to handle the loading of the assets in the directory. The only way i can see is to make a few dozen functions with a [Button] attribute with a {HideIf(*condition)] attribute to turn off any buttons over the List count value. What are your suggestions? I am sure I am not the only one ever wanted varied amount of buttons based on a List count.
     
  2. Tarodev

    Tarodev

    Joined:
    Jul 30, 2015
    Posts:
    176
    I'm making a simple grid game and would love to make my levels directly on a scriptable object.
    How would I display a 10x10 grid of squares in the inspector, which could either be clicked multiple times to change the tile, or drag/drop onto them?
     
  3. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,278
    Apparently the brilliant author of this tool expects us to go to free speech banning discord to ask him questions.
     
  4. WryMim

    WryMim

    Joined:
    Mar 16, 2019
    Posts:
    46
    Hi, I wrote my implementation of SerializableDictionary : IDictionary and SerializableDictionaryDrawer : PropertyDrawer, but Odin Inspector is trapping and drawing its own version of Dictionary, how can I disable this? What would make Odin Inspector work EVERYWHERE except Dictionary?
     
  5. VP_no1

    VP_no1

    Joined:
    May 12, 2018
    Posts:
    107
    https://odininspector.com/tutorials/serialize-anything/serializing-dictionaries

    this works just to show in inspector

    ON RUNNING PROJECT ALL DATA ARE GONE !

    https://bitbucket.org/sirenix/odin-inspector/issues/430/dictionary-of-string-and-serialized
    problem solved in 2017 and BACK IN 2021 !!

    any help on this ?


    my steps:

    1. create a new script with the code provided by ODIN, so I can inherit the serialization and dictionary creation

    2. create a new script to use that:

    Code (CSharp):
    1. public class someClass : MonoBehaviour
    2. {
    3. [Serializable]
    4.     public class StringScriptableObjectDictionary : UnitySerializedDictionary<string, List<GameObject>> { }
    5.     public StringScriptableObjectDictionary StringDICT;
    Thing is that even if it shows in inspector and i populate in editor, on RUN = bye bye data.
    fields are serialized and i even tried it with serilaizedfiled on that public stringdict (even if it is allready in the file on point 1) ...

    I am no expert and I am blocked here ... any help would be great .. ty
     
    Last edited: Feb 22, 2021
  6. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    839
    hello, i am wondering how to have a list of items with toggle next to each of them and to force only one to be selected at the time, like a radio button, is something like that built in? i was going through attributes and it seems i have missed something.

    thank you!
     
  7. pretender

    pretender

    Joined:
    Mar 6, 2010
    Posts:
    839
    also using ValueDropdown with list of string that are urls and start with "https:\\" i have strange behavior in dropdown (i believe it's intended) i ger sub menues that are forced with backslashes. how to treat string as is?

    thanks you
     
  8. polypixeluk

    polypixeluk

    Joined:
    Jul 18, 2020
    Posts:
    53
    I have a ScriptableObject called Ability that contains a list of AbilityComponent. AbilityComponent derives from
    MonoBehaviour so when I make an Ability and add an AbilityComponent to the list, the variables in AbilityComponent are not visible in the inspector.

    Is it possible to use Odin to expose the variables to the inspector?

    I'm using Sirenix.OdinInspector and have added [InlineEditor] above both the Ability and AbilityComponent classes.
    I've changed ScriptableObject in Ability to SerializedScriptableObject and MonoBehavior to SerializedMonoBehaviour in AbilityComponent. But so far nothing is showing.
     
  9. cyangamer

    cyangamer

    Joined:
    Feb 17, 2010
    Posts:
    214
    I'm running into an error every time I interact with any inspectors that Odin changes. I'm using 3.0.4.0:

    Code (CSharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. Sirenix.OdinInspector.Editor.Drawers.OnInspectorGUIAttributeDrawer.DrawPropertyLayout (UnityEngine.GUIContent label) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/OnInspectorGUIAttributeDrawer.cs:54)
    4. Sirenix.OdinInspector.Editor.OdinDrawer.DrawProperty (UnityEngine.GUIContent label) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:109)
    5. Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent defaultLabel) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:789)
    6. Rethrow as OdinPropertyException: This error occurred while being drawn by Odin.
    7. Current IMGUI event: KeyUp
    8. Odin Property Path: InternalOnInspectorGUI
    9. Odin Drawer Chain:
    10. > OnInspectorGUIAttributeDrawer
    11. > DefaultMethodDrawer
    12. > CompositeDrawer.
    13. UnityEngine.Debug:LogException(Exception)
    14. Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:866)
    15. Sirenix.OdinInspector.Editor.InspectorProperty:Draw() (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:677)
    16. Sirenix.OdinInspector.Editor.Drawers.UnityObjectRootDrawer`1:DrawPropertyLayout(GUIContent) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/UnityObjectRootDrawer.cs:60)
    17. Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155)
    18. Sirenix.OdinInspector.Editor.Drawers.FixBrokenUnityObjectWrapperDrawer`1:DrawPropertyLayout(GUIContent) (at Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/FixBrokenUnityObjectWrapperDrawer.cs:41)
    19. Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:109)
    20. Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:789)
    21. Sirenix.OdinInspector.Editor.PropertyTree:DrawProperties() (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:485)
    22. Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:389)
    23. Sirenix.OdinInspector.Editor.OdinEditor:DrawTree() (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:93)
    24. Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector() (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:216)
    25. Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:85)
    26. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
    27.  
    28.  
    The Serialization Debugger window also isn't working at all:


    This happened when I backed up my project to test a future version of Unity. When I switched back and checked out my original branch, this started happening. I would have thought everything Odin uses is in Assets folder and is thus protected by version control.

    Can you help me keep these errors from clogging up my console?
     

    Attached Files:

  10. IggyZuk

    IggyZuk

    Joined:
    Jan 17, 2015
    Posts:
    39
    Hello, would anyone be able to show me how to use the OdinEditor to draw an object either as a single property or an array depending on the number of elements?

    Example:
    Code (CSharp):
    1. public class MonoElements : MonoBehaviour
    2. {
    3.     public int[] elements;
    4. }
    5.  
    6. [CustomEditor(typeof(MonoElements))]
    7. public class CustomOdinEditor : OdinEditor
    8. {
    9.     public override void OnInspectorGUI()
    10.     {
    11.         var tree = this.Tree;
    12.         var obj = this.target as MonoElements;
    13.        
    14.         // obj.elements.Length <= 1
    15.         // Draw property, otherwise draw list.
    16.     }
    17. }
     
  11. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,305
    Is there a way to change the alternating background color shades used in collection items? It's really difficult with complex data in lists to tell where one item starts and the next one ends as the color variation is too subtle.

    It seems this behavior is built into Unity itself, but though I'd ask.
     
  12. oliver_unity892

    oliver_unity892

    Joined:
    Oct 28, 2019
    Posts:
    42
    Hi. I just quickly need to serialize a couple of two-dimensional arrays or even dictionaries.

    I'm assuming Odin can help me do this easily, or is it overkill?
    Olly
     
  13. IggyZuk

    IggyZuk

    Joined:
    Jan 17, 2015
    Posts:
    39
    It can, check out the examples.
     
  14. dbordzo

    dbordzo

    Joined:
    Aug 14, 2015
    Posts:
    34
    Hello, someone tried to draw property of Better Event in Custom Inspector?
    I have something like that in my class which inhert from OdinEditor:

    Code (CSharp):
    1. EditorGUILayout.PropertyField(BetterEventProprty);
    But it shows at this way, so you can not edit it:

    Thank you in advance for any help
     
  15. kaiyum

    kaiyum

    Joined:
    Nov 25, 2012
    Posts:
    637
    Does this tool support "Generic Interface" and "Generic MonoBehaviour/ScriptableObject" serialization?
    i.e.
    Code (CSharp):
    1. public interface ITask<T>
    2. {
    3.    void Execute(T t);
    4. }
    5.  
    6. public Controller<T> : MonoBehaviour
    7. {
    8.   [SerializeReference]
    9.   List<ITask<T>> tasks;
    10. }
    11.  
    12. public ControllerAsset<T> : ScriptableObject
    13. {
    14.   [SerializeReference]
    15.   List<ITask<T>> tasks;
    16. }
     
  16. Arkasis

    Arkasis

    Joined:
    Nov 22, 2010
    Posts:
    59
    Hi there,
    I'm in trubble trying to use a "OnValueChanged" attribute on a variable using its own "OdinValueDrawer".
    It just doesn't work.
    Did I miss something or is it not supported?
    Thanks
     
unityunity