Search Unity

  1. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

How do you write code to save values changed during runtime?

Discussion in 'Editor & General Support' started by jerotas, Sep 29, 2014.

  1. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,136
    I'm not sure how this is done, no clue actually. But I have seen that there are a few plugins out there that include such a feature. I want to include this in one of our plugins but don't know where to start. Any ideas anyone? I'm surprised that we still don't have a "commit" button on the prefab to do this already...

    I thought we could just tell our users to make sure and create their own prefab so they can hit "Apply" during runtime, but quite annoyingly, those 3 prefab buttons disappear during runtime. Why? That would be crazy useful.

    Thanks in advance!
    -Brian
     
    Last edited: Sep 29, 2014
  2. secondbreakfast

    secondbreakfast

    Joined:
    Jan 5, 2013
    Posts:
    98
    Running in the player never uses prefabs which is why the buttons disappear and the color of the game object changes to normal in the hierarchy. It instantiates each prefab when yo start the player. You need to do things while in edit mode if you want changes to be applied to the prefab.
     
  3. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,136
    Yeah, that's the normal way. Like I said, I've seen a few plugins that have things specially built to allow the player to save changes made during runtime mode. I'm wondering how they did it? It is possible, just not natively built in.
     
  4. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,136
    Seriously, no one know how to do this? Or am I in the wrong forum with this question?
     
  5. Teku-Studios

    Teku-Studios

    Joined:
    Sep 29, 2012
    Posts:
    257
    We tested one plug-in back in the day that had a "Keep changes after Stop" feature. It is Ultimate Rope Editor, maybe you want to check it out.
     
  6. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,136
    Thanks, I may check that one out.
     
  7. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
  8. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,136
    Thanks. I tried a revert method last week from PrefabUtility, only to find out that it does nothing at runtime. I'll try a couple others.
     
unityunity