ViewData API - Custom Visual Element

Hello,

I have a custom Visual Element, which is essentially my own interpretation of ListView which suits my custom needs.

I wish the the EditorWindow to “remember” which item was selected, between editor reloads. ViewData sounds perfect for this.

Can I, if so How can I, use the ViewData API to make my editor which item was selected between editor reloads

Thanks in adavance!

1 Like

Unfortunately, the ViewData API is currently still mostly internal and only exposed on some of our own official controls (like ListView). Here’s a fuller description of the current state:

We do intend to re-open this API in the future but for now you’ll have to use another approach to remember selection in your ListView. I didn’t explore this much, but in theory, you could use something like a Slider (which has view data support) as a “holder of view data” inside your custom control. You can then listen for the first GeometryChangeEvent on this Slider, which will be called after view data has been restored to it. Finally, read the value of Slider to get your restored “view data” and interpret it as an index for your selected elements. Might even be doable with an actual ListView inside your custom ListView.

Thank you for getting back to me, I look forward to when the feature being open to the public :slight_smile:

thank you for the idea of using a slider to hold the information, however I feel a far simpler solution would be to user EditorPrefs to store my persistent data :slight_smile:

1 Like