Search Unity

start method not overriding inspector variabes

Discussion in 'Scripting' started by AnalogUniverse, Jul 5, 2019.

  1. AnalogUniverse

    AnalogUniverse

    Joined:
    Aug 10, 2018
    Posts:
    64
    Hi all I have some inspector variables which I want to keep so I can optionally set some values in the Editor but any code I place in the start method which changes those values, logs as changing them but when the game runs it runs with the inspector variables, I logically thought start was called after the serialised variables were applied and as such the start method would override them, but it doesn't appear to be doing this, how do I work around this.

    Thanks in advance
     
  2. AnalogUniverse

    AnalogUniverse

    Joined:
    Aug 10, 2018
    Posts:
    64
    Sorry my bad it was another subtle error in my code which used the serialised values and not the new values to change another key value in the code, before the public variables were set to the new non serialised values, silly me I was tearing my hair out trying to figure out what was wrong with it I assumed it was something to do with how Unity does things