Search Unity

Progress bar is not updating

Discussion in 'Scripting' started by LumoKvin, Apr 4, 2020.

  1. LumoKvin

    LumoKvin

    Joined:
    Sep 28, 2019
    Posts:
    195
    I set the image type to "Filled". When I move the fill amount slider, it seems to be working properly.

    I am trying to update it in code:
    Screen Shot 2020-04-03 at 8.14.18 PM.png

    The print statement confirms that the fill amount should be one:
    Screen Shot 2020-04-03 at 8.13.37 PM.png

    However, the progress bar fill amount is zero:
    Screen Shot 2020-04-03 at 8.14.00 PM.png

    Whatever I set the fill amount slider to, I cannot change it while playing the game. What am I doing wrong?
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Are you sure you're targeting the right image?
     
  3. ShamusO

    ShamusO

    Joined:
    Jan 12, 2016
    Posts:
    6
    Hey, LumoKvin if you change the "Fill Amount" to 3 before playing the game what does the console read?
     
  4. LumoKvin

    LumoKvin

    Joined:
    Sep 28, 2019
    Posts:
    195
    I found the problem. When I name the the Image "Progress Bar", it doesn't work. When I name it anything else, it works. That was a hard bug to track down. This must be a bug.
     
    Last edited: Apr 4, 2020
  5. LumoKvin

    LumoKvin

    Joined:
    Sep 28, 2019
    Posts:
    195
    I found the problem. When I name the the Image "Progress Bar", it doesn't work. When I name it anything else, it works. That was a hard bug to track down. This must be a bug.
     
    Last edited: Apr 4, 2020
  6. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    If that is really a bug, that would be an odd one. Feels like you might have something else going on that is creating an issue.
     
  7. LumoKvin

    LumoKvin

    Joined:
    Sep 28, 2019
    Posts:
    195
    I think I figured it out.
    I can name the object anything and it works. When I name it "Progress Bar", it doesn't work. I can even name it "ProgressBar" and it works fine. I don't know why. There has to be something in the code that finds objects by name, which is causing a naming collision.
     
  8. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    There is nothing I know of in Unity's code that would have issues with a GameObject name, which is why I suggest it could be something else. Something in custom code that you have or in a package you've installed possibly. The test would be to create a new project, Toss an Image in there and name it Progress Bar and then just add code to update it's fill amount. If it works correctly, then it's not a Unity bug.