Search Unity

  1. 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 to Prevent value from being wiping out when changing property name?

Discussion in 'Editor & General Support' started by better_walk_away, May 24, 2019.

  1. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    170
    Hello,
    When we change the name of a property in a Monobehaviour script, for example, a property name violates the naming conventions, we want to modify the name, after Unity recompiling the script, the value assigned to that property in the inspector will get wiped out completely. This is dangerous when we have a lot of game objects that have this script attached to them and we have assigned values to all of them, it will wipe out all the values we assigned in every game object that has this script attached in every scene.
    If we want to change the property name, is there a safe method to do so other than backing up the values in a file or a script? Is there an attribute that does this?
     
    Last edited: May 27, 2019
  2. Yozaro

    Yozaro

    Joined:
    Jun 28, 2015
    Posts:
    70
  3. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    170
  4. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    1,374
    Joe-Censored likes this.
unityunity