Strings and enums drawn by attribute drawers and value drawers get reset

Issue #604 resolved
PJ Legendre created an issue

1. What happened?

Setting “ValueEntry.SmartValue“ inside of attribute drawers or value drawers does not appear to work for enums or strings.

2. How can we reproduce it?

  1. Open up the scene named “Test”
  2. Click on the game object named “Test Script“ to inspect it
  3. Change the properties “My Enum” and “My String” for the “Test Script” component
  4. Click anywhere to un-inspect the game object (or enter play mode)
  5. Re-inspect the game object named “Test Script”
  6. Notice that the values have been reset

3. If screenshots would help explain or demonstrate your issue, please include these.

In this gif, I change the values, un-inspect the game object, and re-inspect it. It might be hard to tell since it loops.

(The enum drawer that I made draws enum values in alphabetical order, so Bat is actually the first/default value.)

4. What version of Unity are you using?

2018.4.14f1 - Personal

5. What version of Odin are you using? (See "Tools > Odin Inspector > About")

2.1.8

6. Do you have Editor Only mode enabled?

No.

7. What operating system are you on?

Windows 10 64-bit

When attaching ZIP files then please remember to remove Odin from the archive.

Comments (7)

  1. Tor Esa Vestergaard
    • changed status to open

    It looks like your drawer is resetting the value every time the value is inspected, since you are never looking at what the value is, only setting new values. I’m fairly certain this is not a bug in Odin, but in your drawers - you should make sure to get your initial selection value out of ValueEntry.SmartValue, not just leave it uninitialized as zero, like you're currently doing it, since that will make your drawer change the value back to default the moment the inspector opens.

  2. PJ Legendre reporter

    This is not a bug, rather a logical error on my behalf. I forgot to initialize the default value for selection in Init so upon initializing the value drawer, the value got reset to 0. My apologies.

  3. PJ Legendre reporter

    @Tor Esa Vestergaard yes, you are correct, I just realized this myself - sorry about this!

  4. Log in to comment