+1
Fixed

"Could not get a Unity SerializedProperty for the property" bug with Odin + Peek

Meatloaf 1 month ago updated by Lazlo Bonin (Lead Developer) 1 week ago 2

Description

I think due to the way Peek overrides the default UnityEngine.Object inspector it causes a conflict with Odin drawing inspectors properly. See Repro Steps & Reference Image below for more details.

Bug message "Could not get a Unity SerializedProperty for the property 'key' of type ..."

Reproduction Steps

  1. Import Odin (3.0.1 or 2.1.10 tested)
  2. Import Peek (1.3.1)
  3. Create Monobehavior with the following code
    public class NewBehaviourScript : SerializedMonoBehaviour
    {
    /// <summary>
    /// Maps a unique unity GameObject / Scriptable Object to a global reference id used for saving & loading.
    /// </summary>
    [Tooltip(
    "Maps a unique unity GameObject / Scriptable Object to a global reference id used for saving & loading.")]
    [DictionaryDrawerSettings(DisplayMode = DictionaryDisplayOptions.OneLine)]
    public Dictionary<UnityEngine.Object, long> references;
    }
  4. Add Monobehavior to Scene gameobject.
  5. Ensure Dictionary is initialized with type Dictionary<UnityEngine.Object,long>()
  6. Set any prefab or Scriptable Object from the project as a key in the dictionary.
  7. Set the id to 0
  8. Press Add button
  9. See error appear. 

Reference Images

Unity Version:
2018.4.17f1
Peek Version:
1.3.1

ReferencePropertyDrawer.cs seems to be the conflict here.

As a stop gap I'm wrapping the whole script in #if !ODIN_INSPECTOR -> #endif to prevent peek from utilizing this PropertyDrawer which fixes the issue. It also means I lose out on some peek functionality too though (no more eyeglass next to objects.

I would love to see a more permanent fix here :).

Fixed

Just forwarding from Discord, Sirenix fixed this issue on Odin's side in version 3.0.2:

Tor Vestergaard - Sirenix11/23/2020

Hey, just wanted to let everyone in here know that we fixed this issue on our own end in Odin's patch 3.0.2 which we released today.