How to Create a reusable Resource Bar in Unity 💛 For HP, MP, Energy,...

Опубликовано: 01 Октябрь 2024
на канале: Christina Creates Games
1,342
73

Learn how to create a Resource Bar in Unity you can easily reuse across projects and use cases! Straight, Circle and Arc Shaped.

We start at having a look at the core basics of a health bar or mana bar and after that, we will expand on the concept by:
- adding some sliding animation
- displaying a value in direct numbers or percentages
- changing colors based on resource availability
- calling an event once the bar is filled up completely
- make it into a circular bar
- add options for an arc form! (or part of a circle)

Plus, a little bit about implementing a good Component Layout in the inspector while doing so - that will make working with the system much more convenient and enjoyable.

Wrapping up, we’ll have a look at how Odin Inspector can improve our component layout even further. You can find the script on my github in case you get lost.

🎆 Github 🎆
https://github.com/Maraakis/Christina...

💬 Discord 💛
You are very welcome to join!
  / discord  

🛍️ Store links 🛍️
If you'd like to support my channel, consider using my affiliate link when buying cool stuff in the Unity asset store: https://assetstore.unity.com/?aid=110... [Affilate link]
Or on Humblebundle: https://www.humblebundle.com/?partner... [Affiliate link]
Or in the Synty Store: https://syntystore.com/98327 [Affiliate]

🎮 Play my games on Itch.io 🎮
https://christinacreatesgames.itch.io

📖 Chapters 🔖
00:00 Intro
00:13 Structure and Contents of this resource bar tutorial
00:58 Create a basic resource bar from UI images
02:38 The basic script
04:58 A simple skill script to test the resource bar
05:30 Adding sliding animation to the bar by code
08:04 Adding Text to our resource bar: Displaying whole values or percentages
10:33 Adding color changes: Smooth and percentage based
11:39 Adding a Unity Event for a filled up bar
11:52 Changing the maximum Amount
13:45 Add Cofigurations to streamline work in the editor
14:24 Add a Setup method to initialize the resource bar from other scripts
14:44 Tiny bonus: [SelectionBase] to jump to the correct GameObject when clicked on in the inspector
15:06 Changing from a straight to a circular resource bar
15:17 Adding support for an arc shaped resource bar
16:55 One step further: Optimizing the Component layout with Odin Inspector (completely optional!)


💬 Discord 💛
You are very welcome to join!
  / discord  

🛍️ Store links 🛍️
If you'd like to support my channel, consider using my affiliate link when buying cool stuff in the asset store: https://assetstore.unity.com?aid=1101lr4hF [Affilate link]

Odin Inspector: https://assetstore.unity.com/packages... [Affilate link]

UI Particle Image: https://assetstore.unity.com/packages... [Affilate link]


🎮 Play my latest game on Itch.io 🎮
https://christinacreatesgames.itch.io...

#unitytutorial