How to create Progress Bars in Unity

Поділитися
Вставка
  • Опубліковано 2 чер 2019
  • In this video we take a look at how to create a linear progress bar and a radial progress bar, as well as how to control them both from the same script and add them to the create menu for easy instantiation.
    Be sure to LIKE and SUBSCRIBE if you enjoyed this guide! Share the video for extra love!
    - - - - - - - - - - - - -
    I've set up a Discord so viewers can hangout, chat and share their own game dev tips and tricks. It's also a perfect place to hear about what videos I'm working on, or discussing episodes in more detail with other members of the Game Dev Guide community.
    So, if that sounds like your thing you're invited to join the Game Dev Guide Discord at / discord
    - - - - - - - - - - - - -
    Socials:
    Twitter - / gamedevguideyt
    Facebook - / gamedevguideyt

КОМЕНТАРІ • 124

  • @DavidJones-tp7td
    @DavidJones-tp7td 5 років тому +85

    Hey thanks a lot. That was actually really easy to follow and execute. Good video, great pacing. I don't think "thumbs up" is quite enough.

  • @android272
    @android272 4 роки тому +2

    Oh my goodness, thank you so much for this video! I was looking for a video on how to make a radial progress bar, remembered I also need a linear progress bar as well. Not only that I have been wanting to learn how to make my own components I can easily create with the Create Asset Menu > UI or where ever. I was not expecting you to take it all the way to that level. Amazing video!

  • @viniciusps01
    @viniciusps01 4 роки тому +4

    Hey Matt, thanks a lot for this tutorial. You have a really straightforward approach that covers what is really important in a fast way. I would say that I'm kind of a fan of your great work!

  • @jacksquat5372
    @jacksquat5372 4 роки тому +4

    Great tutorial! Well planned, presented and easy to follow along. Thanks for making this, I look forward to seeing more of your tutorials.

  • @andreiardelean9324
    @andreiardelean9324 Рік тому

    Your tutorial was really helpful! I was looking for an exact tutorial on LEVEL THRESHOLDS!! It's insane how accurate your tutorial is for my RPG game. Thank you!

  • @bausHuck
    @bausHuck 4 роки тому +7

    Great tutorials. I love the flexibility of your work. It really shows how larger projects should be handled.

  • @jensvoigt9963
    @jensvoigt9963 4 роки тому +1

    Excellent tutorial - everything included to implement great looking progress bars. Including the link to kenney, which I didnt know yet. Good work, many thanks!

  • @ConspiracySociety
    @ConspiracySociety 2 роки тому +1

    This was an awesome tutorial compared to most so far! Thank you a lot! I was even hoping to get into scripting the bars at the end so will follow and hoping for more content! :)

  • @daichi_devs
    @daichi_devs 4 роки тому +1

    admittedly some of the things you did went right over my head, but this was amazing. You achieved it with just a few lines of codes what another youtuber did in about 20+ lines. Cheers!

  • @JadenDragonX
    @JadenDragonX 2 роки тому +1

    your videos are really freaking great! thank you so much for all your uploads and I hope you keep them up, I'm learning so much on how to actually develop systems and making them efficient as well

  • @thepolygonpilgrimage
    @thepolygonpilgrimage 5 років тому +7

    Very well done! Clear, concise, and lot's of handy tricks. I'm subbed and looking forward to more! Thank you sir!

  • @jorgealis3945
    @jorgealis3945 4 роки тому +2

    You deserve more subs. I was looking for an alternative and this fits right in. Thank you!

  • @shinnykatemerlynn5996
    @shinnykatemerlynn5996 4 роки тому +1

    Glad I ran into this channel. learned more than what I clicked here for. Subscribed!

  • @LesP56
    @LesP56 Рік тому

    Fabulous! Gets right to the point without unimportant information and provides examples that are easy to understand.

  • @user-pf6th7oo5m
    @user-pf6th7oo5m 3 роки тому +2

    This video is sooo easy to understand for a Unity beginner like me thanks to your great explanation! Thanks!

  • @djpersonalspace2406
    @djpersonalspace2406 2 роки тому +1

    What a great video! Thanks a lot, keeps it simple but also takes it to the next level. Really enjoyed that.

  • @No_name_to_give
    @No_name_to_give 6 місяців тому

    4 years later and still helped me with a progress bar for my platformer thanks so much

  • @Lelouchishere
    @Lelouchishere 4 роки тому

    watch 2 videos and I subscribed, Your videos are just amazing, to the point, no bullshit, good content.

  • @kerandonovan7255
    @kerandonovan7255 3 роки тому +1

    Your videos are very well explained and a pleasure to follow.

  • @HadiLePanda
    @HadiLePanda 4 роки тому +1

    Really love this type of tutorials, very modular! :)

  • @chimichangle
    @chimichangle 4 роки тому +1

    This, Brackeys, and Mix n Jam are my Holy Trinity for Unity tutorials. Thank you for these high-quality videos!

  • @_Simoose
    @_Simoose 3 роки тому

    It took me way to long to find a decent answer to this question. Thanks for the video!

  • @visarbaci268
    @visarbaci268 3 роки тому +1

    amazing stuff, another sub. hope you keep them coming.

  • @ryolu4799
    @ryolu4799 4 роки тому +1

    YO I JUST FOUND U WHEN I NEED U THE MOST! WHY THANK YOU AUTO SUBSCRIBE AND BINGE WATCH WITH MY SCHOOL TEAM

  • @NotRealVoyduzzz
    @NotRealVoyduzzz 6 місяців тому

    Thank you so much! It looks so amazing!

  • @AQW9111
    @AQW9111 4 роки тому +1

    How can you not have more than 10k views? jeez christ so so so good videos! keep it going and you will grow! you will be big! a lot bigger!

  • @Shinobi31415926
    @Shinobi31415926 4 роки тому +1

    Very helpful tutorial! Thank you so much!!

  • @trunghieu974
    @trunghieu974 4 роки тому

    This is one of the best unity youtube channels i have been subcribed!
    Why haven't this channel get 100.000 subcribed yet?

  • @harshmudhar96
    @harshmudhar96 4 роки тому +4

    Just a small addition for any comment readers. Prefer PrefabUtility.InstantiatePrefab() to Instantiate as it automatically creates the Prefab Link for you (notice how his instantiated Linear Progress Bar is a clone and not a prefab instance).
    Of course, if your goal is to have modular components like the normal Unity UI, cloning is better :)

  • @sexypotato
    @sexypotato 4 роки тому +3

    I just discovered your channel and subscribed!

  • @allanramos6855
    @allanramos6855 2 роки тому

    Awesome video, I've learned a lot from it! You really helped me

  • @civilviking7121
    @civilviking7121 3 роки тому +1

    Quick and amazing, thanks!

  • @user-qe2ci7vf8b
    @user-qe2ci7vf8b 4 роки тому

    My fav channel now

  • @andreashanna6060
    @andreashanna6060 2 роки тому +1

    You earned a new subscriber!
    Thanks for this video :D

  • @andylockhart257
    @andylockhart257 4 роки тому +1

    Love it! Need more tutorials

  • @RiksevStreams
    @RiksevStreams 4 роки тому +1

    Incredible! It's nice experience ;) Thank you!

  • @jumpkut
    @jumpkut 9 місяців тому

    Great, easy to follow tutorial with some hidden gems. Thumbs up!

  • @Tymon0000
    @Tymon0000 5 років тому +1

    Very good tutorial, thanks!

  • @Chronomatrix
    @Chronomatrix 3 роки тому +1

    This is fantastic, thank you very much!

  • @bausHuck
    @bausHuck 3 роки тому +3

    Great tutorial. Easy to follow. Easy to start using straight away. This channel is in my Top 5 for Unity tutorials.
    Few things about this Progress Bar that might trip up some beginners like myself.
    At 10:30 , the Fill Image is used for both Mask and Fill slots. Took me a few seconds to see that. It is not exactly like the Linear Bar.
    I turned the Original Radial Bar into 2 separate bars, Ring and Radial (without the mask). This seemed to make more sense to avoid having an extra UI element always being added.
    To get a real Ring Progress Bar without the inner mask image, you will need a proper Ring image. Then at this point you do not need the mask element for this bar as well.
    I tried putting the prefab into a Prefab folder but it did not work, it must go into Resource/UI folders.
    Not 100% sure about this one, but it might not be the best to keep the GetCurrentFill in the Update. This is good for constantly updating things like a timer but not so much for health and experience bars that usually update once and wont need to be updated until the next change.

    • @Anansipelli
      @Anansipelli 7 місяців тому

      Absolute hero, I was about to go crazy

  • @Adroan98
    @Adroan98 Рік тому

    amazing video! it really helps for people like me who just got into scripting and coding alot to learn still Haha.
    but that saves me alot of time thanks alot

  • @J_E_N_T
    @J_E_N_T 3 роки тому +1

    Great video, just like all of your others!

  • @johnx140
    @johnx140 4 роки тому

    Youre amazing man. Subbed.

  • @luameduardo9611
    @luameduardo9611 4 роки тому

    Thank you very much, subscribed

  • @manishotaval8316
    @manishotaval8316 4 роки тому

    Solid Tutorial !!

  • @tyleranders9972
    @tyleranders9972 4 роки тому

    Great video!

  • @paranormalgamesstudios
    @paranormalgamesstudios Рік тому

    Thanks this video helped me solve my own similar problem

  • @fulgencejuniorlohore854
    @fulgencejuniorlohore854 Рік тому

    Thanks for this nice tutorial! 2023 and still relevant!

  • @DJLKM1
    @DJLKM1 4 роки тому +1

    You really should have far more subs. More tuts please :)

  • @angeldevops532
    @angeldevops532 2 роки тому

    great tutorial thanks

  • @aroldo1959
    @aroldo1959 4 роки тому +5

    Nice Tutorial.
    Since the Fill Amount is at a different images depending on the Progress Bar type (Linear and Radial), in order to make both Progress Bars work with the same Progress Bar Script I did the following:
    Add two Tags ; Radial and Linear and assign them to each respective Prefab .
    change the GetCurrentFill to check for each tag.
    void GetCurrentFill()
    {
    float currentOffset = current - minimum;
    float maximumOffset = maximum - minimum;
    float fillAmount = currentOffset / maximumOffset;
    if (gameObject.CompareTag("Linear")) { // Check if it is Linear or Radial Progress Bar
    mask.fillAmount = fillAmount;
    Debug.Log("Linear");
    } else if(gameObject.CompareTag("Radial")) {
    // Radial
    fill.fillAmount = fillAmount;
    Debug.Log("Radial");
    }
    fill.color = color;
    }

  • @AlexSprites
    @AlexSprites 5 років тому +2

    Thank you loads. I've been making games for 3 years now and your videos are showing me all the little tips and tricks I've never known of.

    • @GameDevGuide
      @GameDevGuide  5 років тому +1

      Ah you're so welcome. Yeah, I try to tie in lots of small extras into these guides for people who might already know how to do things. There's ideally little bits of useful info for any skill level! Glad you're enjoying it.

    • @AlexSprites
      @AlexSprites 5 років тому

      @@GameDevGuide Most definitely! Greatly love that you also go the extra mile and emphasize re usability and flexibility. Great job, I'm looking forward to your future content!

    • @GameDevGuide
      @GameDevGuide  5 років тому +2

      Yeah, well I'm teaching stuff based off of my own experience trying to develop games.
      I think there's often a disparity between how the engine thinks you should do something (and what many tutorials show you) verses what's actually a "production friendly" approach to doing something.
      So, as someone who is working on production tools and systems, I tend to focus on the latter.

  • @JonathanbmillerZIG
    @JonathanbmillerZIG 3 роки тому

    You the best, bro.

  • @BaziJo
    @BaziJo 3 роки тому

    thank you for this video plz make more video like this

  • @cruzchaps3662
    @cruzchaps3662 9 місяців тому

    This is the good stuff

  • @F3L0
    @F3L0 4 роки тому

    5TH VIDEO I AM WATCHING, TIME TO SUBSCRIBE !!!!!!!

  • @user-jp1mf3iy4m
    @user-jp1mf3iy4m 4 роки тому

    awesome! thx u

  • @user-tz5zt1mb6f
    @user-tz5zt1mb6f Рік тому

    It`s GREATE, thank you

  • @brunogattai9262
    @brunogattai9262 4 роки тому

    Wow, thanks a lot.

  • @Endoo95
    @Endoo95 4 роки тому

    :o
    You are genius!

  • @Rhino123freak
    @Rhino123freak 4 роки тому

    Best tutorials on youtube, don't @ me.

  • @noicenoise8718
    @noicenoise8718 2 роки тому

    Awesomeness

  • @j55intelphil
    @j55intelphil 4 роки тому +1

    Great tutorial! One question: when I use the custom menu item to create the progress bar, the created object in the hierarchy seems to be unpacked from the progress bar prefab (it appears with black name rather the blue), and when I edit the prefab the changes aren't reflected in the object in my scene. Is there any way to have the menu item instantiate a GO that's still linked to the prefab?

  • @ChuckiBinner
    @ChuckiBinner 2 роки тому

    hey, thanks, great tutorial! Is there also a way to make the progress bar fill with a moving/stretched image with a rounded tip ?

  • @ConcreteJungleGames
    @ConcreteJungleGames 4 роки тому +32

    3:15 I followed the tutorial and kept getting Stretchy Blurry Janky Looking Messes...
    Applying a square-cornered sprite to the mask fixed the mask from cutting in over the fill, I hope this helps anyone else that went through this.

    • @lordkakabel76
      @lordkakabel76 3 роки тому +1

      Awesome tip, thank you! A 1x1 white pixel did it for me.

    • @sanketvaria9734
      @sanketvaria9734 3 роки тому +1

      It doesn't work for me. It still get's stretched.

    • @catlikeanimation8651
      @catlikeanimation8651 Рік тому

      thank you!!!!

    • @janzaloudek4957
      @janzaloudek4957 8 місяців тому

      You just saved my ass, thank you so much for this comment, I used a jpg from google and it works now

  • @jeremyinvictus
    @jeremyinvictus 5 років тому +7

    Very nice video. I'm not particularly adept with unity or programming in general, but is it a good idea to have this all taking place in the Update() method? I don't know how much overhead that is, maybe it's not much, but it seems like it would be better to update it only when something changes, like you receive new xp from something. Maybe using delegates or something like that?

    • @GameDevGuide
      @GameDevGuide  5 років тому +8

      Hey, Jeremy great question!
      So, putting it in Update was just easiest for the purposes of teaching this topic and being able to preview it easily in Edit mode, and while it shouldn't be a huge problem in the Update method, there's definitely AN overhead of updating the variables every frame.
      If you're wanting to do this in a more permanent way, some kind of delegate system or callback is definitely recommended. I've actually got a video on building an event system here on the channel which goes over how to approach something like that.
      Thanks for watching!

    • @jeremyinvictus
      @jeremyinvictus 5 років тому

      @@GameDevGuide thanks. I actually watched that video and enjoyed it.
      And yeah I assume this kind of task isnt much strain, but perhaps if somebody made a habit of always doing things in the Update() method it could become an issue down the road, in a complex game.

    • @DynamicalisBlue
      @DynamicalisBlue 4 роки тому +1

      @@jeremyinvictus For something this simple, I just used properties that will call the methods to update it. I moved the stuff in the Update() method to OnGUI() and added the if UNITY_EDITOR expression. This way you can still mess around in Edit mode but the overhead will be gone in the actual build.

  • @vrfarmer2905
    @vrfarmer2905 4 роки тому

    Could you do a video about how to make a level system?

  • @fariahuq6473
    @fariahuq6473 3 роки тому

    Hi, Is it possible to add a 'wholenumber' option like default unity slider? So that We can enforce dragging only to fixed set of positions over the radial slider?

  • @danielmarton4388
    @danielmarton4388 3 роки тому +1

    Hello,
    It's a great and very helpful tutorial, but I have a question.
    How can I make a progress bar wich is just a segment of a full circle?

  • @aissadaoud-ot1qd
    @aissadaoud-ot1qd Рік тому

    thannnnnnnnnnnnnnkkkkkkkkkkks💓💓💓💓💓💓

  • @Indiedude
    @Indiedude 5 місяців тому

    Nice tutorial! I just have one question. How to make radial progress bar progress shown by rotation degree? Are there some tricks in script file?

  • @GameAndJokes
    @GameAndJokes 4 роки тому

    Hey i need You Help man i m making a game in which the camera follows the player but the problem is that when the camera hits or collides with a building or something the object is no longer being seen but i want the player to be seen and the obj to dissapear.Thanks Man love your videos

  • @fabianlo234
    @fabianlo234 8 місяців тому

    Thanks! Keep up the good work! I am a begginer, and this was great but... I can I ask you a question? What is the mask for?

    • @fabianlo234
      @fabianlo234 8 місяців тому

      Super great tutorial man!

    • @fabianlo234
      @fabianlo234 8 місяців тому

      Thumbs up, but it is not enough...

  • @MilanObrtlik
    @MilanObrtlik 3 роки тому

    You are the best. Sorry Brackeys.

  • @hamyazilim
    @hamyazilim 3 роки тому +2

    Perfect. But i have a problem. When i want to add to my script "fill" and "color" fields and set it from unity editor it throws null pointer. I don't know why it throws that exception. I tried to get it with GetComponent it isn't throws null pointer exception but it doesn't set color again.

  • @shaded8476
    @shaded8476 4 роки тому

    Can we use slider for the progress bar

  • @juanan_zzz
    @juanan_zzz Рік тому

    👑

  • @Darkry
    @Darkry 3 роки тому +1

    I think that a very easy way of making progress bars is using Sliders... it is prectically the same as shown in this video, but you have everything already set up and you don't need to write a code that contains maximum and current values, since Sliders have this already implemented as Slider.value and Slider.maxValue. They also have Rect Transform if you ever need it for each component and since you are using UnityEngine.UI for images, it is better to just use Slider instead.
    Hope somone will find this useful :)
    (If you don't want any component in your slider, just remove it... no problem. I use sliders often and just remove the Handle object and mark slider as "non interactable"...)

    • @angeldevops532
      @angeldevops532 2 роки тому

      with the slider the image is distorted when it reaches a certain point

    • @Darkry
      @Darkry 2 роки тому

      @@angeldevops532 this depends on the settings for the image.
      If you click the image in the file editor, a panel should show up with the settings. You can set up resolution and scaling there. There should be an option to set colours to 16RGBA and very close to that an option to set "Point" or something like that.
      When you do that, it should be much crispier and it shouldn't get distorted too much.
      And the same applies to sliders like these... If the scale is off, it will get distorted as well. UI sliders just have higher resolution.
      Everything can be handled :)

  • @ShaneSalisbury
    @ShaneSalisbury Рік тому

    How do you make a progress bar with an image at the end like shown at 2 seconds in the video with the bird?

  • @newruler8417
    @newruler8417 2 роки тому

    thank

  • @kenrogoway7234
    @kenrogoway7234 4 роки тому

    Does the radial progress bar work with Unity 2019.4.0f1? It doesn't seem to work for me. Also, why does the video show that the FILL image is used in the Inspector for both the Fill and Mask properties of the ProgressBar script?

  • @SanyaBane
    @SanyaBane 4 роки тому +2

    Thanks a lot, very useful video.
    However video thumbnail shows us that inner circle inside RadialPB is invisible (unless its just filled with same color as background).
    Is it possible to mask inner circle such way that i could see background? (you can imagine there is picture in background, or part of camera render - i mean it cannot be just filled with solid color in this case)

  • @igorabdoaguilar9331
    @igorabdoaguilar9331 3 роки тому +1

    So let's say We want to make a radial bar as a tool for the user. Similar to a knob on a control board. Can I shift the starting point in which it begins to fill from 12 o'clock to 7 o'clock? And let's say that the 100% filled would be at 5 O'clock. Any ideas? I just started learning UNITY. Love your videos!

  • @vincentproud6589
    @vincentproud6589 Рік тому

    So, I know this is 3 years old, but great video!
    I'm having a slight issue, though, importing any sprite for the bars get seriously deformed towards the ends when I stretch them. For instance, if I try to use a square sprite with an outline as you have here, the left and right parts of the outline become extremely thick. Any idea what I can do to fix this? :)

  • @lastidea4925
    @lastidea4925 4 роки тому +2

    Why you didnt use slider for exp bar ?

  • @457Deniz457
    @457Deniz457 4 роки тому

    Hey there and thank ! :)
    Do you upload some stuff to GitHub ?

  • @user-qr9zj7on7x
    @user-qr9zj7on7x 6 місяців тому

    GAZAB

  • @PreslavKolev
    @PreslavKolev 4 роки тому

    I have a problem. When I use the ProgressBar script on the RadialBar it just won't work. It don't want to change the current value. Please help!

  • @moysser
    @moysser 3 роки тому

    can you make a bar the get fill when you click a button ? and goes down when you are not clicking ? the faster you click the faster it goes up and when you dont click it goes down fast too.... so it gonna be a challenge clicker microgame.

  • @His-Games
    @His-Games 3 роки тому

    have my subsciption

  • @android272
    @android272 4 роки тому

    I added properties for Minimum, Maximum , and current and an OnValidate method to validate these fields. With the code below Minimum can not be greater than Maximum, Maximum can not be less than Minimum, and Current is clamped between these two values. The properties ensures that you can't set these fields to invalid values in code while the OnValidate method ensures that you can't set invalid values in the inspector.
    public int Minimum {
    get => minimum;
    set {
    minimum = (int) Mathf.Min(value, Maximum);
    }
    }
    public int Maximum {
    get => maximum;
    set {
    maximum = (int) Mathf.Max(Minimum, value);
    }
    }
    public int Current {
    get => current;
    set {
    current = (int) Mathf.Clamp(value, Minimum, Maximum);
    }
    }
    private void OnValidate() {
    minimum = (int) Mathf.Min(minimum, maximum);
    maximum = (int) Mathf.Max(minimum, maximum);
    current = (int) Mathf.Clamp(current, minimum, maximum);
    }

  • @freakymundo
    @freakymundo 2 роки тому

    What if we don't want to use a Canvas (image) and want to just use a Sprite Renderer?

  • @chronoabi
    @chronoabi 4 роки тому

    It says the object you want to instantiate is null how to fix it

  • @keelanbowker-obrien2222
    @keelanbowker-obrien2222 4 роки тому +3

    For some reason I can get this to work up until the last bit where I add...
    public Image fill;
    public Color color;
    once I assign the fill image, it stops playing nice.

    • @keelanbowker-obrien2222
      @keelanbowker-obrien2222 4 роки тому

      Even weirder, I can't seem to get the fill behavior to work unless I assign my "fill" object an image type of filled, parented to "Mask" with an image type of sliced.

    • @MysticThistle
      @MysticThistle 4 роки тому

      @@keelanbowker-obrien2222 pm me your code

    • @lenartbence
      @lenartbence 4 роки тому +2

      @@keelanbowker-obrien2222 I had a similar issue, I assigned a fully transparent color so it became invisible. Hope it helps you out.

    • @gabrielepeloso8593
      @gabrielepeloso8593 2 роки тому

      I had the same issue. Check the color you assign from unity has alpha = 1.

  • @Zereze
    @Zereze 2 роки тому +3

    Great tutorial, but the bar doesn't move smoothly. If anyone wants it to move smoothly, I can tell you how I did it myself.
    First I made a float named "displayCurrent", then added this piece of code:
    private void Update()
    {
    if (Mathf.RoundToInt(displayCurrent) > current)
    {
    if (displayCurrent - current != 0)
    displayCurrent -= (displayCurrent - current) / 10;
    }
    else if (Mathf.RoundToInt(displayCurrent) < current)
    {
    if (current - displayCurrent != 0)
    displayCurrent += (current - displayCurrent) / 10;
    }
    GetCurrentFill();
    }
    And then replace all "current" references in GetCurrentFill() with "displayCurrent"

  • @poppers7317
    @poppers7317 8 місяців тому

    7:16 but that sets the color for every Update. I wouldn't fill my game with who knows how many useless calls every second. That stuff can add up.
    Is it necessary to change the color in game? Wouldn't it be better to put this in the Start method?

  • @mariosmichael5116
    @mariosmichael5116 3 роки тому

    💙💙💙💙💙

  • @idle.observer
    @idle.observer Рік тому

    Did I missed the reason why you don't use Slider?

  • @thedude4039
    @thedude4039 3 роки тому

    For me, there's no image type.

  • @medalimakhlouf1508
    @medalimakhlouf1508 2 роки тому

    Your videos are very well explained and a pleasure to follow.