ValueDropdownAttribute for Dictionary's key?

Issue #218 resolved
wavebit created an issue

Hi, I am trying to implement an object struct like json[see the code below], members are stored in a dictionary. The dictionary's key is a string, it is inconvenient to type a string and easy to make a mistake, hope the ValueDropdownAttribute can work for it. The enum type can show a dropdown, but the enum keys are hard coded.

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

public enum MemberKey

public class MemberKeyTable : ScriptableObject
  public List<string> keys = new List<string>();

public class DomObject : SerializedScriptableObject
  public DomObject Parent;

  public Dictionary<MemberKey, DomObject> Members = new Dictionary<MemberKey, DomObject>();

  public MemberKeyTable MemberKeys;

  //Need a DictionaryKeyDropdown attribute from MemberKeys 
  public Dictionary<string, DomObject> Members1 = new Dictionary<string, DomObject>();

Comments (6)

  1. Tor Esa Vestergaard
    • changed status to open

    I'm afraid this isn't something you can do right now. It's something we want to allow people to do, but right now we would have to get really (really) hacky to do it. However, the property system rework planned for patch 1.1 is intended to accomodate exactly cases like this, so at that point, support will be added for this.

  2. wavebit reporter

    hi, json format also contains List data struct. If 1.1 can support List, that will be perfect, at that time all base data structs are supported.

  3. Tor Esa Vestergaard

    I'm afraid I'm not sure exactly what you're talking about. Odin supports lists in almost every way I can imagine lists being supported. Could you clarify what you mean by that?

  4. wavebit reporter

    The demo code in Odin only shows some scalar properties and the ValueDropdownAttribute's code document does not mention List too, I thought List is not supported as Dictionary. Sorry, now I know Odin supports List. p1.PNG p2.PNG

  5. Log in to comment