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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question public inspector variables

Discussion in 'Web' started by super_mario92, Mar 8, 2023.

  1. super_mario92

    super_mario92

    Joined:
    Feb 19, 2023
    Posts:
    3
    Hello,

    I was wondering if I have a public speed variable set to 10 in a script, but in the inspector I set it to 15 when I build the game to upload to webGL will the speed variable be set to 10 or 15 when I play the game in my broswer?

    Thanks
     
  2. sumpfkraut

    sumpfkraut

    Joined:
    Jan 18, 2013
    Posts:
    241
    15.

    10 in the script is only the preset value if you add the script to a gameobject.
     
    super_mario92 likes this.
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,336
    You don't even have to make a build, it takes effect in editor Playmode too.
     
    super_mario92 likes this.
  4. super_mario92

    super_mario92

    Joined:
    Feb 19, 2023
    Posts:
    3
    if I attach the script to a gameobject and then change the speed value to 15 in the inspector will the speed value still be set to 15 when I upload the game to webGL?
     
  5. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,516
    Yep, the value in the editor is the one it takes.
     
    super_mario92 likes this.
  6. super_mario92

    super_mario92

    Joined:
    Feb 19, 2023
    Posts:
    3
    thank you!