Search Unity

Energy Bar Toolkit - 2D and 3D Progress Bars

Discussion in 'Assets and Asset Store' started by genail, Mar 30, 2013.

  1. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hmm interesting... I'll egzamine it more deeply as soon as I get home.
     
  2. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Ok I think I've killed the dragon.
    At first I found something like this: http://answers.unity3d.com/questions/38585/access-javascript-variables-on-c-script-android-bu.html
    But now I think I found a workaround. Please try this: https://www.dropbox.com/s/s95l5zd82ru9gz4/android_test.unitypackage?v=0mcn

    What I did is that I wrote C# script EnergyBarAccessor.cs and attached it to playerBall game object:

    Code (csharp):
    1. using UnityEngine;
    2.  
    3. public class EnergyBarAccessor : MonoBehaviour {
    4.    
    5.     public EnergyBar energyBar;
    6.  
    7.     void OnEnergyBarChange(float v) {
    8.         energyBar.ValueF = v;
    9.     }
    10.  
    11.  
    12. }
    Then in playerHealth.js i use SendMessage() function to use Unity messaging system as a provider:

    Code (csharp):
    1. var deadDepth = -10;
    2.  
    3. @HideInInspector var health : float = 1;
    4.  
    5. function Update () {
    6.     health = Mathf.Clamp(health, 0, 1);
    7.  
    8.     SendMessage("OnEnergyBarChange", health);
    9.  
    10.     if (health == 0) {
    11.         GameObject.Destroy(gameObject);
    12.     }
    13.    
    14.     if (transform.position.y <= deadDepth) {
    15.         health = 0;
    16.     }
    17. }
    Please let me know if this will work for you :)
     
  3. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    Thanks!!! Now it work fine.) I really appreciate your support.

    Maybe now you can simplify everything?) Scripts in scene is little confusing. I can move from here but what if someone is unfamiliar with programming at all?)

    I think all what need is only three basic scripts: 1 "Health Restore", 2 "Health Damage", 3 "Health Carrier"

    In "Health Damage" script you can add some checkboxs for "constant damage" (like fire... on_triggerStay), "delayed damage" (Poison), "instant kill".
    I saw this really cool feature in "EasyTouch" asset... (look at the picture). You just set the receiver an wrote what function you need to call in it. So no need to open code.Hit character - call function "death". Easy and simple.)

    And how about to make an example with two health bars? Like in fighting games?
     

    Attached Files:

  4. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    This sounds good! I think I will try to something like that and let you know how I did.

    I don't know why but you attached image with boxes few posts ago and it haven't displayed to me until now. I think I'll make second example like this a little later :)

    P.S. Thank you very much for the review! :D
     
  5. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    Yes I didn't see them too... I thought that it is was "Opera" browser problem. Because in "internet explorer" they were displayed normally. But now even there they gone, and yours still shows normally. Don't know why...
     
  6. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Maybe because I'm hotlinking to my imgur instead of attaching images :)
     
  7. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    For your information: I've created Simple Event script to make manipulation of energy bars more easy. It is inspirated by EasyTouch asset mentioned above. Of course screenshot below is raw inspector view and it will be packed into more human-readable form just later. But what is most important: it is working and energy bars can be manipulated without a single line of code :)


    How it works: Attach trigger target (on what object it will react), set how energy bar value will change, optionally send messages to selected game objects.

    Available values:

    Target Type:
    • GameObjects
    • Tags
    Change Bar Type:
    • Increase By Value
    • Increase By Percent
    • Decrease By Value
    • Decrease By Percent
    • Set To Value
    • Set To Percent
    Argument:
    • Caller
    • BarValue
    • BarValuePercent

    Please let me know if you have any suggestions ;-)
     
  8. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    It looks really promising!) I have some other ideas how to expand your asset. But i think it will be better to finish this part, and then add some new staff.
     
  9. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    Hi genail!
    Just download your update and test it! Works great! I like those new features in «Simple event» script.
    I have a suggestion.
    Maybe HealthBar itself will send a message to? For example I want to play some animation when character gets a full health recover, do some actions when health bar become empty, and maybe when health bar start blinking.
     
  10. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
  11. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    That's interesting idea! But I think that this kind of events can be accomplished by SimpleEvent script just now. Please look at the documentation.

    You can define multiple messages to send when something changes with energy bar and choose what will be passed as the argument. If you want to react when energy falls to 0% or raises to 100% you can send message to FixedGameObject with BarValuePercent argument.

    About blinking I am thinking about message when blinking animation occurs. For example to play "low energy" sound. I don't want to send message just because value drops because bar should be acting as view component, not a controller.

    Thank you for your suggestions!
     
  12. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    Great Work as always,

    every game that need health-bar (most games?) in mobile or native will have buying potential for this asset
    but I think you should concentrate on NGUI atlases and textures, for the mobile developers (specially since now the basic version is free)

    the UnityGUI is a dcs killer, and soon will be replaced with the new unity gui
     
  13. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Thank you :)

    Version 1.6 will bring some more fresh functionality for NGUI. Difference between Unity UI and NGUI version seems to be somewhat big because of configuration option number. The reason why NGUI has it less is that many things you can do using NGUI bundled tools.

    I am about to test EBT on my Android device :) Is there difference between how NGUI should be configured or used on desktop and mobile devices?
     
  14. Frozmat-Games

    Frozmat-Games

    Joined:
    Dec 17, 2012
    Posts:
    25
    Don't want to be annoying or something.))) But... I don't get it...( Maybe I missed something?
    For example I have 15 objects on level, with "simple event", and each one of them can reduce health by 10%... So how do I know exactly what object will be the last one who send "Death" event, if they all works only as a triggers?
    I have a character which receives a various damage from various threats. And everything works perfect except one thing... When his health become zero nothing happen. And I don't know how can I get this "Your HealthBar is empty!" event.
     
  15. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I will provide you with example tomorrow :)
     
  16. Eron198200

    Eron198200

    Joined:
    May 23, 2013
    Posts:
    8
    I have a problem with NGUI filled bar. When i play example scene bar doesn't move. If i change value doesn't work.
     
  17. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
  18. Eron198200

    Eron198200

    Joined:
    May 23, 2013
    Posts:
    8
    i have NGUI 2.5.0b Is this a problem? if i create a new bar it doesn't work too.
     
  19. Eron198200

    Eron198200

    Joined:
    May 23, 2013
    Posts:
    8
    Ok, i update to 2.5.1 and it works!! Great!
     
  20. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I'm happy to hear that :) Have fun!
     
  21. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
  22. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    It will work fine as is in android,
    try testing with multiple unity GUI bars see the fps drops

     
  23. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
  24. Mcg

    Mcg

    Joined:
    Mar 28, 2012
    Posts:
    112
    looks awesome would it be possible to animate textures to create something similar to diablo 3 resource orbs?

    $i8jbidXG2utru.gif
     
  25. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    This one indeed is amazing. I think of making a little simpler version of this. I don't own Diablo 3 but when I'm looking at this I believe it is made using particles and distortion shader. Anyway I'll add it too my TODO list. Thanks for the idea! ;-)
     
  26. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I've just updated example projects. Here's what it looks like now. It's accessible form first post of this thread, wiki page, and images below (click to run) ;-)

     
  27. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
  28. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    177
    Hi genail, I purchased your asset this evening, and it works fine, with one exception: I am using bar 3 from bar pack1, and the bar itself shows up black no matter what colour I set in the inspector, but then it gets weird; whenever the bar passes in front of a game object, the colour shows up on whatever part of the bar has the object behind it, then it goes black again when it leaves the object, and only the skybox is behind it.

    In the game view when it's not running it looks fine, colour and all, but when the game is running it is black. The foreground colour is fine. The bars from pack2 seem to be ok, just seems to affect the horizontal bars in pack1.

    I also have a question: how do I set which energy bar I'm using in the simple event script for an instantiated prefab? As it is, it won't allow me to add one to the prefab, though I have no problems with the other settings. Thanks.

    Update: just ran it again, and any particle effects (in this case snow) that the energy bar passes in front of also puts the colour back into the bar for the duration of the particle effect.
     
    Last edited: Jun 11, 2013
  29. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello wheelbarrow, thank you for the purchase! :cool:

    Please tell me something more. What version of Unity are you using? On what platform? Is it Mac or Windows? What is your graphics card? What is your active platform in Unity build configuration (standalone, web, Android, iOS)? Have you configured shader model emulation of any kind?

    I will try to reproduce this behavior based on this information. Would it be a problem to you to provide me a unitypackage with basic sample scene that reveals this bug? Of course without any dependencies :)
     
  30. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    177
    Sorry, I should have included that in my post. Win7, nvidia gtx560, no shader emulation, and for the standard stand alone PC, Mac or Linux.
    Ignore my question above about an instantiated prefab, I simply put one in the scene(hidden) with the energy bar selection set.
    As for reproducing it, I don't know how much I could help - as you say, my rig as listed should help. I'm assuming its the NVidia card...I have the latest drivers for it btw. I'm using the latest version of unity, Pro version. Thanks again.
     
    Last edited: Jun 11, 2013
  31. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    No problem ;-) And I assume you have latest Unity version? I will try to reproduce this as soon as I get home, and my request about sample scene still stands ;-)

    Edit: You edited your post, so my questions here looks like I can't read :-(
     
    Last edited: Jun 11, 2013
  32. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    177
    Yea my apologies for that genail, I noticed I missed the unity version as soon as I finished posting it, so I edited it lol. The new shader works great, thank you very much for your fast response, and fixing the problem.
    Cheers.
     
  33. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I'm happy to hear that! I will provide you with patch for other 3 shaders because 1.5.3 will be released in a week or so.
     
  34. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Last edited: Jun 19, 2013
  35. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Two things!

    1. I'm proud to announce that 1.6.0 is out!

    This time list of features is quite big and significant. It's strongly recommended for all EBT users to update to the latest version ;-) For more information please use links below to release notes or blog post.

    New features:
    • Infinite number of background and foreground layers for default renderer
    • Background and foreground textures can be set for sequence renderer
    • Radial grow direction configurable angular offset and angular length
    • New grow method: Color Change
    • Bars position and scale can be affected by transform (ability to create hierarchies)
    • Premultiplied alpha support
    • Better resizing (multi-resolution) support
    • Smooth effect for repeat and sequence bars
    Bug fixes:
    • Some materials was created for each frame what caused large performance issue
    [ Release Notes ] [ Blog Post ] [ Mail Support ]

    2. Racing Gauges energy bar pack soon available


    For about two weeks or so I am working on fourth energy bar pack for Energy Bar Toolkit. This time the target is racing games. It will be available as separate asset on Asset Store. [ Read More ] or [ Launch The Demo ]
     
  36. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045

    I'm proud to announce that Racing Gauges for Energy Bar Toolkit is out!

    High quality energy bar pack for Energy Bar Toolkit. Perfect for your racing game! Buy now and get 2 more racing gauges for free! Incoming with next update! Price: $5 (will be raised after updates so don't wait!)

    Features:
    • Speedometer
    • Tachometer
    • Gear indicator
    • Turbo level gauge
    • Fuel level gauge
    • Damage indicator

    [ Demo ] [ Asset Store ]
     
  37. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Here's announcement for today:

    Energy Bar Toolkit 1.6.2 is released!

    With this release you can:
    • Specify on what camera anchoring will be done
    • Animate energy bars using Animation Component
    Also NGUI inspectors were broken due to latest changes. It's fixed now.

    [ Release Notes ] [ Mail Support ] [ Asset Store ]
     
  38. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Energy Bar Toolkit now offers PlayMaker support!


    Available Actions:
    • Get Bar Value
    • Get Bar Value Percent
    • Set Bar Value
    • Set Bar Value Percent
    • Change Bar Value
    • Change Bar Value Percent
    No update needed. Just grab it here!
     
  39. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Ok, let's go with it again :)

    Energy Bar Toolkit 1.6.3 has been released!

    This release introduces new renderer: Transform Renderer. This new renderer gives you many great possibilities to create more interesting progress indicators (gauges for instance).

    Also this release comes with PlayMaker support. It's available as separate package.

    Bug Fixes:
    - NGUI: Blinking effect breaks color tint and burn effect

    Have Fun! ;-)

     
  40. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Small announcement.

    Energy Bar Toolkit 1.6.4 has been released!

    There was only one bug this time but quite important. When "relative to transform" option was selected, scaling the parent transform had quite awful result. Now everything works as expected.

     
  41. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    And here it is!

    Energy Bar Toolkit 1.6.5 has been released!

    This time this release is introducing some bigger changes and big performance improvement (mostly for mobiles)!

    New Features
    • NGUI: Anchoring to 3D game objects support
    • All 4 renderers now supports labels (by now labels were available only for default)
    • New bar example: clock
    • Label position can be defined with normalized values
    Improvements
    • Reduced about 30-50% of total draw calls
    • Default texture color is now white (was black)
    Bug Fixes
    • Progress bar could be rendered twice in some cases
    • Label outline on/off option was not responding
    • Removed (not real) information about leaks when saving scene

     
  42. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    Damn, Nice!
     
  43. Yiorgos

    Yiorgos

    Joined:
    Jun 5, 2013
    Posts:
    26
    Very handy tool, thumbs up genail :)
     
    Last edited: Aug 18, 2013
  44. abbc

    abbc

    Joined:
    Mar 12, 2011
    Posts:
    52
    Hi. In the feature list, you states "Automatic size calculation - just throw in the texture". But in your website, I get the following: "Pivots doesn't support energy bar resizing" and "If you choose to define sizes by normalized coordinates the aspect ratio will be broken". If I am using the NGUI version, should I worry about energy bar resizing and aspect ratio distortion?
     
  45. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    @Yiorgos
    Sorry. I've must missed your message somehow. Thank you! :)

    @abbc
    Hmm it's a difficult question.
    Section about throwing in textures was about how quickly you can setup working progress bar, but setting sizes on different resolutions was always the tricky part.

    If you want to use NGUI integration then its code is solely responsible for how your widgets will be stretched (EBT integration with NGUI introduces new widgets). I'm not NGUI specialist but I believe that it can solve this problem in some way.

    Anyway if you decide (or decided) to buy EBT and have any problems with make it work as you want it to work, then please contact me. This is how I implement most of new features into EBT if there are missing ;-)
     
  46. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    Hi i look for Anchoring by script i'am on java < i don't find him on EnergyBarRenderer
     
    Last edited: Aug 27, 2013
  47. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello kilik128!

    I'm sorry but I don't quite understand your question. Did you mean that you're using UnityScript (JavaScript) and you want to set anchor object on the runtime? You can do so, but you have to create adapter object using C#. If this is the case please let me know, I will prove an example then :)
     
  48. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    Yes is what's i want do i have

    var bar2 = Instantiate (bar);
    bars =bar2.GetComponent(EnergyBar)as EnergyBar ;

    for set valueCurrent

    but for set Anchor when i move EnergyBarRenderer in plugin for java is make missing component
     
  49. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I've updated the wiki for you. Please take a look here: http://redmine.madpixelmachine.com/...nt_Languages#Accessing-using-accessor-classes

    You can find there the explanation and unitypackage with example scene and code.
    Please let me know if something will be unclear :)
     
  50. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    Thanks
    at this time he say me
    SendMessage SetAnchorObject has no receiver!
    UnityEngine.Component:SendMessage(String, Object)
    Bot:OnGUI() (at Assets/Bot.js:57)

    Sample Working the only chance with my code is my Bar is create by Instantiate
    so i don't see where's i'am wrong at this time but i will see