Attributes don't work in ScriptableObject edtor

Issue #366 invalid
Alex Slavski created an issue

I have a project in Unity 2018.2.0f2. Here is my scriptable object:

using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;

[CreateAssetMenu]
public class GameEvent : ScriptableObject
{
    [ReadOnly]
    public string Description;

And this is how my Object looks in the editor: http://take.ms/M1u4j I have also tried some other attributes and they also don't work.

However in monobehaviour object [ReadOnly] attribute works fine.

Comments (5)

  1. Tor Esa Vestergaard
    • changed status to open

    Have you confirmed in Tools -> Odin Inspector -> Preferences -> Editor Types that Odin is actually drawing the scriptable object in question?

  2. Tor Esa Vestergaard

    There is an editor called GameEventEditor already drawing GameEvent - therefore, Odin is not drawing it, and you are not getting the benefits of Odin. You can derive from OdinEditor instead of Editor in the GameEventEditor class, and manually use Odin's utilities via the PropertyTree (base.Tree) to do the drawing.

    However, the recommended approach with Odin is to never make your own custom editor. If you want that Raise button, for example, simply make a Raise() method and put [Button] on it. You should never have cause to create a custom editor class when using Odin. However, if you do that, then you need to use Odin manually.

  3. Alex Slavski reporter

    WOW!!! Thanks a lot, it worked, this is a very detailed and personal approach! A tech support on an extremely high level!!!

  4. Log in to comment