Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    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:
    229
    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:
    27
    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:
    45
    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:
    42
    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:
    30
    How can I hide a property defined in a base class?
     
  7. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    229
    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:
    229
    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:
    30
    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:
    30
    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:
    958
    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:
    190
    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:
    42
    Cool! Thank you!
     
    bjarkeck likes this.
  15. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    229
    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:
    137
    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:
    229
    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:
    958
    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:
    60
    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:
    958
    @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