- edited description
[HideReferenceObjectPicker] Doesn't seems to affect nested dictionaries.
Here is the code sample that causing the issue at the moment:
[CreateAssetMenu]
[HideMonoScript]
public class SinglePlayerLevelSettings : SerializedScriptableObject
{
[System.Serializable]
[InlineProperty]
public struct WordsCountSetting
{
[OdinSerialize]
[HideLabel]
[HorizontalGroup]
[MinValue(0)]
public int MinCount { get; private set; }
[OdinSerialize]
[HideLabel]
[HorizontalGroup]
[MinValue(0)]
public int MaxCount { get; private set; }
}
[System.Serializable]
[InlineProperty]
public class LevelInfo
{
[OdinSerialize]
[HideReferenceObjectPicker]
[DictionaryDrawerSettings(DisplayMode = DictionaryDisplayOptions.OneLine, KeyLabel = "Letters count", ValueLabel = "Words count")]
private Dictionary<int, WordsCountSetting> wordsSettings = new Dictionary<int, WordsCountSetting>();
}
[OdinSerialize]
[HideReferenceObjectPicker]
[DictionaryDrawerSettings(DisplayMode = DictionaryDisplayOptions.OneLine, KeyLabel = "Initial level", ValueLabel = "Settings")]
private Dictionary<int, LevelInfo> levelsInfo = new Dictionary<int, LevelInfo>();
}
In fact it’s doesn’t seems to affect values of the dictionary in any way.
I’am want to see no reference field for some cases, but I can’t change it in the any way except mentioned below:
I managed to hide parameter by adding the attribute to the class definition:
But I don’t think it’s perfect solution because you might not want to have this at some other place. Is it possible to add something like [HideReferenceValuePicker], [HideReferenceValuePickerIf(“MyFunc”)] attribute or something like that?
Reproducing on macOs High Sierra.
Unity 2019.2.6f1
Comments (4)
-
reporter -
reporter - marked as enhancement
- edited description
-
reporter - edited description
-
- changed status to resolved
This is the challenge of working with dictionaries - there's no straightforward way to "target" attributes at keys or values in the dictionary. What I would suggest is to use an attribute processor to conditionally apply HideReferenceObjectPicker only if you are in a dictionary (for example, the property name is "Value" or the parent is an EditableKeyValuePair or whatever you'd like to distinguish it). You can have a look at our tutorials for attribute processors.
- Log in to comment