Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to properly preserve native plugin's data after I restart the editor?

Discussion in 'Editor & General Support' started by landings, Dec 12, 2019.

  1. landings

    landings

    Joined:
    Jan 23, 2018
    Posts:
    5
    I don't have much experience on interaction between C# code and native plugin. It seems that when Editor exits, the plugin's variables are all gone.

    I want my variables in native plugin to completely restore after Editor restart, as if the Editor never exit. What is the best practice?

    1. Make native plugin stateless?
    2. Let my plugin frequently save himself to a file on any change?
    3. When Unity does serialization, transfer plugin's data to Unity and let Unity serialize it?

    Or is there some better ways?