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

Changing variables with the Editor overrides script initialization forever?

Discussion in 'Scripting' started by vreference, Oct 25, 2011.

  1. vreference

    vreference

    Joined:
    Mar 22, 2011
    Posts:
    154
    I've been struggling with variables - and arrays especially - that I make the mistake of altering via the editor. In fact I'm still not sure how to purge this data. Once I've altered the length of an array with the editor, the editor now takes precedence and I can no longer change the length of the array in the script no matter if I reset the script on the object or not. Other variables are similar. I like the idea of being able to make variable changes on entities to tweak things but I need a way to purge this data. As it is, once I've altered a variable in the editor I'm forced to reset the script every time to make an initialization in the script take effect and resetting the script does not help with arrays; their initialization is ignored; I have to change the length in the editor.
     
  2. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224
    You can make the variables private or use @HideInInspector.