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

    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.

  2. Log in to comment