Search Unity

Keeping persistence in runtime

Discussion in 'UI Toolkit' started by Kaiymu_, Jun 3, 2020.

  1. Kaiymu_

    Kaiymu_

    Joined:
    Jun 1, 2016
    Posts:
    47
    Hello everyone,

    I have a question regarding keeping persistence in your UI.
    In my case, I have 5 pages that each contains a UXML of a TemplateContainer of the same UXML.

    This bottom page has 5 buttons that each can be toggled on / off, which, when clicked, changes it's class and display a new page.
    Obviously, when I change page, the bottom page state just reset itself.

    Would their be any way to keep the data persistent? Keeping the information that I clicked on button 3 for exemple?
    Right now I mainly use UI instead of code, but, would spawning that TemplateContainer by code would be better?

    I know that viewDataKey exist, but I don't think it works in the case I'm giving.

    Thank you for your help.