Collection editor does not work when in a PropertyTree created from another object

Issue #681 invalid
Ekaterina Vaartis created an issue

1. What happened?

While creating a custom editor, I needed for it to be able to show data from another object (ScriptableObject), so I created a PropertyTree from this other object and was drawing it in the custom editor. This works fine, except for the collection drawer, which does not do any modifications at all, the add and remove buttons do nothing and the object isn’t marked as dirty.

2. How can we reproduce it?

In the attached project, a TestObject has a Test component which uses the TestComponentEditor. This editor tries to take a reference to the TestScriptableObject and draw it by creating a PropertyTree from it. This does draw the contents, but the list cannot be modified. Pressing the plus button does nothing.

4. What version of Unity are you using?

The unity version used is 2019.4.0f1

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

Odin version is 2.1.12

6. Do you have Editor Only mode enabled


7. What operating system are you on?

Windows 10

Comments (4)

  1. Tor Esa Vestergaard

    This is not a bug, but expected behaviour given your editor code. A property tree instance should not be created anew each frame, but kept and reused across frames. Recreating the property tree each frame breaks all behaviour that happens across frames, which is quite a lot, such as (but not limited to) editing collections.

  2. Ekaterina Vaartis reporter

    I see. maybe this should be put in bold text instead of cursive on this page, as it’s not immediately noticable. Nevertheless, thank you for explanation.

  3. Tor Esa Vestergaard

    That’s a fair point - I’ve made that change, as it appears to be a common misunderstanding.

  4. Log in to comment