Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

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

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

  1. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    238
    Would something like this work?
    Array Resizer.PNG

    You could in the same way also change the button to accept a string paramater, and manually parse the string :)
     
  2. SpyrosUn

    SpyrosUn

    Joined:
    Nov 20, 2016
    Posts:
    48
    Thanks a lot for this example ! I was actually able to do it by adding a menuItem and then use CreateAsset on each own of my game assets via a custom editor window that I made. But i got to say, Odin parses the results really really nice :)
     
    bjarkeck likes this.
  3. mykillk

    mykillk

    Joined:
    Feb 13, 2017
    Posts:
    49
    Feature request:

    In the Inspector, for testing/troubleshooting, sometimes I need to temporarily remove an added element from a Collection. It's a bit of a hassle to remove and re-add elements as needed, so an additional per-element button or right-click option to temporary disable it (i.e. it still shows up in the Collection in the Inspector, maybe visually greyed out to make it apparent, but is not actually added as an element in the C# Collection at runtime), that would be pretty nifty.

    A related request would be a similar button or right-click option, but for making an element the only enabled one in the Collection. Basically like Mute / Solo buttons on the tracks in most audio production packages.
     
    Last edited: Nov 21, 2018
    bjarkeck likes this.
  4. SergeyGorbunov

    SergeyGorbunov

    Joined:
    Feb 12, 2014
    Posts:
    1
    Hi.

    I use [TableList(DefaultMinColumnWidth = 100)] and i get list which show not all columns and i don't see horizontal scroll bar, how get i scroll bar?

    Thanks.
     
  5. zoltanBorbas

    zoltanBorbas

    Joined:
    Nov 12, 2016
    Posts:
    51
    Hi all!

    I was wondering if someone can help me a bit, i have a SerializedMonoBehaviour script with a 2d array of MonoBehaviour scripts. I managed to show the 2d array in the editor however i cannot seam to show the public field of scripts held in the array. I only get the c# icon as shown in the picture.

    //This is the script with the 2d array
    public class GrndCmbt_Garrison : SerializedMonoBehaviour
    {
    [SerializeField] private GrndCmbt_Garrison_Slot[,] garrisonSlots;
    }

    //This is the script that is held in the 2d array and the field i want to see
    public class GrndCmbt_Garrison_Slot : MonoBehaviour
    {
    public GrndCmbt_Unit_Combat_GroupMember_Garrisonable garrisonedUnitInSlot;
    }

    I want to see that garrisonedUnitInSlot field of the scripts held in the array, i am interested to know when the field becomes empty.

    upload_2018-11-27_15-43-52.png

    Any help would be greatly appreciated, i admit i am a complete noob when it comes to Serialization.
     
  6. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    47
    How can I hide a property defined in a base class?
     
  7. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    238
    You can do that with Odins AttributeProcessors :) There more examples of OdinAttributeProcessors available from "tools > Odin Inspector > Getting Started"

    Code (CSharp):
    1. public class MyCustomClassAttributeProcessor<T> : OdinAttributeProcessor<T>
    2.     where T : MyCustomClass
    3. {
    4.     public override void ProcessChildMemberAttributes(InspectorProperty parentProperty, MemberInfo member, List<Attribute> attributes)
    5.     {
    6.         if (member.Name == "SomeMember")
    7.         {
    8.             attributes.Add(new HideInInspector());
    9.         }
    10.     }
    11. }
     
  8. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    238
    Cells inside matrecies are handles a bit special in Odin as it's rarly ideal to render entire objects in each cell. But you can use the DrawElementMethod to do custom cell drawing.


    Code (CSharp):
    1.  
    2.         [TableMatrix(DrawElementMethod = "DrawGarrisonSlot")]
    3.         public GrndCmbt_Garrison_Slot[,] garrisonSlots;
    4.  
    5.         private static bool DrawGarrisonSlot(Rect rect, GrndCmbt_Garrison_Slot value)
    6.         {
    7.             // Use GUILayout, GUI etc.. to draw the cell for the given value.
    8.             return value;
    9.         }
     
  9. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    47
    Awesome! Thanks!
     
  10. mSkull

    mSkull

    Joined:
    Apr 19, 2016
    Posts:
    10
    Hi @SergeyGorbunov,

    Yes, this is an issue with the TableList drawer currently. Basically, the TableList drawer constrains itself to the available width in the current IMGUI layout and ignores the minimum width property.

    Currently, the easiest way to solve the issue is by using the HorizontalGroup.Width property. Something like this:
    Code (CSharp):
    1. [HorizontalGroup(Width = 2000), TableList(DefaultMinColumnWidth = 100)]
    Alternatively, I also have a new Attribute + drawer that creates a new horizontal space with a horizontal scroll view. It is not perfect, but it does work.
    Code (CSharp):
    1. [HorizontalScrollArea(2000), TableList(DefaultMinColumnWidth = 100)]
    Code (CSharp):
    1. // HorizontalScrollAreaAttribute.cs
    2. public class ServiceAsset : ScriptableObject
    3. {
    4.     [HorizontalScrollArea(2000)]
    5.     [TableList(DefaultMinColumnWidth = byte.MaxValue)]
    6.     public List<Storage> Storage;
    7. }
    8.  
    9. // HorizontalScrollAreaAttributeDrawer.cs
    10. public class HorizontalScrollAreaAttributeDrawer : OdinAttributeDrawer<HorizontalScrollAreaAttribute>
    11. {
    12.     private Rect prevRect;
    13.     private Vector2 scrollPosition;
    14.  
    15.     protected override void Initialize()
    16.     {
    17.         this.prevRect.width = 100;
    18.         this.prevRect.height = EditorGUIUtility.singleLineHeight;
    19.         GUIHelper.RequestRepaint();
    20.     }
    21.  
    22.     protected override void DrawPropertyLayout(GUIContent label)
    23.     {
    24.         var rect = EditorGUILayout.GetControlRect(false, this.prevRect.height + 16);
    25.  
    26.         GUILayout.BeginArea(this.prevRect.AddYMax(16));
    27.         this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition);
    28.         GUILayout.BeginVertical(GUILayoutOptions.Width(this.Attribute.Width));
    29.  
    30.         GUIHelper.BeginLayoutMeasuring();
    31.         this.CallNextDrawer(label);
    32.         var height = GUIHelper.EndLayoutMeasuring().height;
    33.  
    34.         GUILayout.EndVertical();
    35.         GUILayout.EndScrollView();
    36.         GUILayout.EndArea();
    37.  
    38.         if (Event.current.type == EventType.Repaint)
    39.         {
    40.             this.prevRect.position = rect.position;
    41.             this.prevRect.width = rect.width;
    42.             this.prevRect.height = height;
    43.         }
    44.     }
    45. }

    I hope that helps :)
     
  11. chanon81

    chanon81

    Joined:
    Oct 6, 2015
    Posts:
    47
    So, I am extending a MaskableGraphic which has an "onCullStateChanged" property that I want to hide but can't make go away even with the custom AttributeProcessor.

    upload_2018-12-2_2-26-55.png

    Setting any attributes to it in the AttributeProcessor don't seem to do anything.
     
  12. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,059
    when i go to About under Odin in Unity. It says Version 2.0.3
    When I go to the store it says the newest version is 2.0.13?
     
  13. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    197
    Hello,

    Do you guys respond to emails? I've contacted the support email: contact@devdog.io

    Unsure if I should be contacting somewhere else instead..
     
  14. zoltanBorbas

    zoltanBorbas

    Joined:
    Nov 12, 2016
    Posts:
    51
    Cool! Thank you!
     
    bjarkeck likes this.
  15. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    238
    Yeah we do, and sorry about the confusion. DevDog is our publishers. It's actually a different company that's developing Odin (Sirenix). We try to direct our users to http:/www.sirenix.net/support but could do a better job of that.

    Discord For some rapid back and forth chat support.
    Isssue-Tracker If you have an issue that you don't want us to forget about.
    Sirenix.net/support If your question or inquiry is more suited for an email, you can reach of from there.

    And we also answer questions in here, but we're most active on the other channels.
     
  16. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    160
    Hi! Is it possible to speed up scriptable objects in editor? In 2017.2 they work very slow. Or it is not related to Odin?
     
  17. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    238
    Is it maybe because you are storing a lot of data in them? Unity objects are serialized each frame in the inspector, so the more data they serialize the laggier they become. You can get around this by manually saving and loading the data to a file, and use Odin to inspect the data. One of our users on Discord made this thing which helps with just that: https://pastebin.com/FGXVGXfY maybe you kind find some inspiration there.
     
  18. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,059
    when I do
    Code (csharp):
    1.  Vector3[] myVector = new Vector3[10];
    It creates a reordering capable list in the editor. Which is awesome but I have a situation where Id rather it not be possible to reorder. Is there something I can do to remove reordering on it?
     
  19. banksazero

    banksazero

    Joined:
    May 8, 2015
    Posts:
    65
    Do you have any tutorial or sample code for ODIN EDITOR WINDOWS (from asset's page)?
    Like how you create new window and put details.
     
  20. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,059
    @banksazero
    Try this link out man. It shows examples at the bottom.
    This is what I would do. Create a new cs script. Then copy that example into it
    That will instantly get you started with seeing how it works with creating editor windows.

    Code (csharp):
    1.  
    2. public class SomeWindow : OdinEditorWindow
    3. {
    4.    [MenuItem("My Game/Some Window")]
    5.    private static void OpenWindow()
    6.    {
    7.        GetWindow<SomeWindow>().Show();
    8.    }
    9.  
    10.    [Button(ButtonSizes.Large)]
    11.    public void SomeButton() { }
    12.  
    13.    [TableList]
    14.    public SomeType[] SomeTableData;
    15. }
    16.  
    17.  
    Think you need using Sirenix.OdinInspector at the top.
    Its been a long time since i was messing around with this so I kinda forgot.

    http://sirenix.net/odininspector/documentation/sirenix/odininspector/editor/odineditorwindow
     
  21. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    790
    Do you possibly have an Odin build without unityengine.networking for 2019?
     
    Japec and mewlist like this.
  22. Amitloaf

    Amitloaf

    Joined:
    Jan 30, 2012
    Posts:
    67
    Is there a way to not show the odin drawer for a list and use unity's native list inspector? Unity's list have an option to add several items at once by dragging and I need that.
     
  23. Matanpjelly

    Matanpjelly

    Joined:
    Feb 6, 2018
    Posts:
    2
    hi, i have a 2d array of a custom class - that class has an 2 enum properties (enum ArmyType & enum UnitType) of
    i want in the inspector to have a grid for my array where each box in the grid uses the armyType property to draw the background of the entire grid cell. and the other enum type to draw a normal enum button in the middle of the grid cell.
    how can i achieve this with Odin? (i saw in the examples how i can use the Draw rect to color the cell - but i cant manage to put a button over that Rect)
     
  24. Shudrum

    Shudrum

    Joined:
    Apr 3, 2011
    Posts:
    51
    Hello and thank you for this very useful plugin! Can we ask for some improvements? :p

    I think of the AssetList, who may need some fields and properties of the ListDrawerSettings. Particularly the HideAddButton and HideRemoveButton, because we get unwanted prefab added to our target asset folder on each click on the wrong list :(

    Thank you again!
     
  25. Slimmper

    Slimmper

    Joined:
    Aug 18, 2016
    Posts:
    1
    Hi
    I have problems getting an InspectorProperty.Children items.
    When I remove an Item from the list, property after removed lost children. In the resolver I see all the fields, but the number of children remains empty. When I add any item to the collection (after remove), the problem is solved and i can get all children.
    How i can fix it?
    Thanks

    Screenshot_1.png Screenshot_2.png
     
  26. jiangPeng206

    jiangPeng206

    Joined:
    Jan 18, 2017
    Posts:
    2
    how can i Serialized protobuf dataformat? please help me
     
  27. evilack

    evilack

    Joined:
    Nov 13, 2015
    Posts:
    1
    enum's LabelText does not apply to EnumPaging, EnumToggleButtons.

    Code (CSharp):
    1. public class EnumToggleButtonsExamples : MonoBehaviour
    2. {
    3.     [Title("Default")]
    4.     public SomeBitmaskEnum DefaultEnumBitmask;
    5.  
    6.     [EnumPaging]
    7.     public SomeEnum SomeEnumPagingField;
    8.  
    9.     [Title("Standard Enum")]
    10.     [EnumToggleButtons]
    11.     public SomeEnum SomeEnumField;
    12.  
    13.     [EnumToggleButtons, HideLabel]
    14.     public SomeEnum WideEnumField;
    15.  
    16.     [Title("Bitmask Enum")]
    17.     [EnumToggleButtons]
    18.     public SomeBitmaskEnum BitmaskEnumField;
    19.  
    20.     [EnumToggleButtons, HideLabel]
    21.     public SomeBitmaskEnum EnumFieldWide;
    22.  
    23.     public enum SomeEnum
    24.     {
    25.         [LabelText("First:1")]
    26.         First,
    27.  
    28.         [LabelText("Second:2")]
    29.         Second,
    30.  
    31.         [LabelText("Third:3")]
    32.         Third,
    33.  
    34.         [LabelText("Fourth")]
    35.         Fourth,
    36.  
    37.         [LabelText("AndSoOn:5")]
    38.         AndSoOn
    39.     }
    40.  
    41.     [System.Flags]
    42.     public enum SomeBitmaskEnum
    43.     {
    44.         [LabelText("A:1")]
    45.         A = 1 << 1,
    46.         [LabelText("B:2")]
    47.         B = 1 << 2,
    48.         [LabelText("C:3")]
    49.         C = 1 << 3,
    50.         [LabelText("All:4")]
    51.         All = A | B | C
    52.     }
    53. }
    out.png
     
    Thermos likes this.