Search Unity

Prefab script variable always resets on play

Discussion in 'Scripting' started by deffan, Jun 12, 2019.

  1. deffan

    deffan

    Joined:
    May 24, 2015
    Posts:
    7
    I have a script on my prefab, in which I have a public variable set to some "original value" i once set, i dont even remember when.
    If change this value to something else, then press play, it resets back. Always.
    I can change the value, save & exit Unity, then load it again, and I can see my new value is set. Great. But what happens when I press play? BAM... its back to the original value again.

    Clearly. I dont want this to happen. If i set a new value, thats the damn value i want it to have...
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    Are you setting the value of this field anywhere in the script?