Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

odd GUItoggle behaviour, same code, some on, some off

Discussion in 'Scripting' started by arumiat, Jul 7, 2014.

  1. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
    Oddly, although using 'identical' code some of the toggles in a menu I've made are on by default when I hit play to preview the game, whilst others are off. Can anyone help me figure out why please? Using pictures as the code was previewing weirdly.

    These toggles are all linked to if/else statements which I'll post as well.

    Thanks in advance
    A

    oddtoggle.PNG oddtoggle2.PNG
     
  2. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
  3. Pysassin

    Pysassin

    Joined:
    Dec 27, 2012
    Posts:
    87
    You double check the inspector? Even if you hard code the variables during initializing them in code if they are different in inspector the inspector overrides it.
     
  4. arumiat

    arumiat

    Joined:
    Apr 26, 2014
    Posts:
    321
    Perfect, thanks Pysassin.
    togglesolved.PNG
     
  5. Pysassin

    Pysassin

    Joined:
    Dec 27, 2012
    Posts:
    87
    Not a problem, I recently had that issue and it was really obnoxious to say the least. Now if I NEED to hard code something like that I tend to do it on Fx Awake so it overrides whatever is in the inspector.