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
    Hello Amaresh,

    Thank you for purchasing EBT!

    Are you using OnGUI renderers? Please consider switching to modern Mesh renderers that should not have any memory issues. If you're using mesh renderers, then most probably some other helper scripts are rendering something in OnGUI function?

    Cheers!
    Piotr
     
  2. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello There,
    Ohh... Of course I care... I will check this out Thank you!
     
  3. Amaresh

    Amaresh

    Joined:
    Jan 22, 2014
    Posts:
    21

    Yes, I think I'm using OnGUI renderers. The GUI.repaint() shows up in profiler almost every 25-30 frames, and its killing my game on low-end mobile devices. Thank you for the reply. Can you tell me how can I switch to the mesh renderers...I'm a bit new to unity.
     
  4. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    OnGUI functions are generally bad for mobiles, so there's no surprise :)
    Please read this page: http://energybartoolkit.madpixelmachine.com/doc/2.1.5/components/renderer_types.html

    If you will have any further questions, please ask freely!

    Cheers!
    Piotr
     
  5. mobeeDREAM

    mobeeDREAM

    Joined:
    Aug 2, 2014
    Posts:
    3
    hello, nice asset by the way... I got that error, every frame, for every energybar i have in my scene, and i'm confused why...

    NullReferenceException: Object reference not set to an instance of an object
    EnergyBarToolkit.MadAnchor.FromPosition (Position position)
    EnergyBarToolkit.MadAnchor.UpdateScreenAnchor ()
    EnergyBarToolkit.MadAnchor.Update ()

    in the inspector, when i click on the anchor, the "Mode" is set to "ScreenAnchor" and the "Position" is set to "Center".

    any idea ?
     
  6. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello There!
    Thank you for writing!

    Can you attach a screenshot from your inspector?

    Cheers!
    Piotr
     
  7. mobeeDREAM

    mobeeDREAM

    Joined:
    Aug 2, 2014
    Posts:
    3
    take note even when not in play mode the error is logged

    here it is for the anchor

    energybar_anchor.jpg
    here it is for the lifebar

    energybar_lifebar.jpg
     
  8. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello There!
    Thank you for screenshots!

    Unfortunately you cannot use anchors having your bars outside the panel at the same time. If you want your bars to be anchored to screen corners, then you have to place them under a panel. I see that you want your bars to be displayed above your units. It will work just fine if you remove the anchor object (and move your bar object one level higher in the hierarchy).

    Please write if you have any other questions!

    Cheers!
    Piotr
     
    mobeeDREAM likes this.
  9. mobeeDREAM

    mobeeDREAM

    Joined:
    Aug 2, 2014
    Posts:
    3
    Fantastic ! It fixes everything and my game is now back at 60 fps !!! Thanks a lot

    I'll now try to delete the panel as it looks like unused now !
     
  10. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Do not delete the panel. It is still used, because the panel is the renderer for all your bars :)
     
  11. AlenBrk

    AlenBrk

    Joined:
    Feb 17, 2014
    Posts:
    33
    Are there any news regarding the SortingLayers?
    I am trying to use it in my 2d Game.. Is there any way to set the SortingLayerName?

    I have tried to use this Script:

    publicclassTextureSortingLayer : MonoBehaviour
    {
    publicstringsortingLayerName = "Foreground"; //Thenameofthesortinglayer .
    publicintsortingOrder = 4 ; //Thesortingorder

    voidStart(){
    renderer.sortingLayerName = sortingLayerName;
    renderer.sortingOrder = sortingOrder;
    }
    }

    but it does not work..
    What i would like to do is to attach the Bar to an Player to follow him..
     
  12. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello AlenBrk,
    Please try attaching this script to the Panel instead of bar object.
    I haven't found the time to implement sorting layers to EBT although it should be easy. If you will have difficulties, please write back to me!

    Cheers!
    Piotr
     
  13. AlenBrk

    AlenBrk

    Joined:
    Feb 17, 2014
    Posts:
    33
    Hi Piotr,
    thank you for your fast reply.

    I have tried to add it to the Panel too but it doesn't work for me.

    What i have tried also to take it away from the panel and attach the Bar to the Player ( make it as child of the Player ) which works nice only the Problem is that it is behind my Background Sortinglayer.. and not visible.

    The Script does not bring it to the front.
    Should i add the rendere Component maybe?

    Or maybe if you have some time to check the script and make a short video or and short description how to do it would help alot.

    Many thx,
    Alen
     
  14. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I'm not sure how sorting layers for regular Unity renderers are working, so I need to check it myself before I can reach any conclusion. Would you give me some time (til tomorrow), so I can check what's wrong and maybe even write support code for sorting layers?

    P.S. Adding renderer won't work. I suspect the camera setup is the culprit.
     
  15. AlenBrk

    AlenBrk

    Joined:
    Feb 17, 2014
    Posts:
    33
    Of course take your time... I just thought you will maybe know some workarrounds how to do it.
    I will try it also at home later .. if i get it working i will post the solution here.

    Thanks for your help.
    Alen
     
  16. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello Alen,
    I'm sorry. I haven't found the time to try this this today. I will try to work it out tomorrow morning...

    Piotr
     
  17. AlenBrk

    AlenBrk

    Joined:
    Feb 17, 2014
    Posts:
    33
    Hi Piotr,

    no problem, thx for letting me know.
    I was also not lucky to get it working. everything works fine except when attached to a player directly to follow him..

    Many thanks.
    Br, Alen
     
  18. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    OK, I've checked it and I forgot that I've moved renderer from MadPanel to hidden draw call object. Here's the script that should be attached to MadPanel to make it work:

    Code (CSharp):
    1.  
    2. [ExecuteInEditMode]
    3. public class TextureSortingLayer : MonoBehaviour {
    4.  
    5.     public string sortingLayerName = "Foreground"; //Thenameofthesortinglayer .
    6.     public int sortingOrder = 4; //Thesortingorder
    7.  
    8.     void Start() {
    9.         Set();
    10.     }
    11.  
    12.     void Update() {
    13.         if (!Application.isPlaying) {
    14.             Set();
    15.         }
    16.     }
    17.  
    18.     void Set() {
    19.         var bigMeshRenderer = GetComponent<MadBigMeshRenderer>();
    20.         var rend = bigMeshRenderer.drawCall.renderer;
    21.  
    22.         rend.sortingLayerName = sortingLayerName;
    23.         rend.sortingOrder = sortingOrder;
    24.     }
    25. }
    26.  
    To make it work you must ensure that only one camera is rendering sprites and bars. To achieve this you would want to set your sprites and MadPanel at the same layer. Then you have to decite to either:
    - Make your main camera rendering the bars by disabling Camera 2D under Energy Bar Toolkit object
    - Make Camera 2D render bars and sprites, but this will break your scale at first.

    I will play with this somewhat more and I think I can introduce "native" support somewhere near 2.2.0.

    Please write if you will have any other issues!

    Cheers!
    Piotr
     
  19. Keitaro3660

    Keitaro3660

    Joined:
    May 20, 2014
    Posts:
    86
    hi there, just want to ask question (sorry if this question has been asked multiple times)

    with unity GUI 4.6, is there will be a change with energy bar toolkit?
    i mean the implementation, feature, etc
    because now unity has their own progress bar, is there will be 'something'?
     
  20. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello,
    I need to take a peek at uGUI first. I think I will do this in a few days. Most probably I'll have to introduce an integration code, but I will think about moving to uGUI if it is good enough :)

    Cheers!
    Piotr
     
  21. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Hi genial,

    Sorry if this has already been asked as well, but is there a way (through your asset or scripting API) to adjust where on the model the health-bar sits? For instance, I noticed in your video that all of the healthbars are at the unit's transform.position (it looks like) -- which is typically at the unit's feet or mid-section. I want my healthbars to be over my unit's heads a little bit. So I'd need a vector offset from the unit's default transform position -- up in the "y" value.

    Thanks for any help.

    Velo
     
  22. Keitaro3660

    Keitaro3660

    Joined:
    May 20, 2014
    Posts:
    86
    ok, but please take it slowly before moving. looks like unity 4.6 still have many bugs :v
     
  23. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello There,
    Thank you for writing!

    It sounds like you want to set up an anchor:
    http://energybartoolkit.madpixelmachine.com/doc/latest/other/following.html

    If you put your bar under an anchor it will stick relatively to it on the panel-space (EBT space). You can also adjust it on the world space. Here you can read how I did it for the Bot Run example: http://energybartoolkit.madpixelmac...s/mesh/filled.html#anchor-mode--object-anchor . In other worlds I'm using a helper object to place it in the desired location :)

    Please write if you have any other questions!

    Cheers!
    Piotr
     
  24. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437

    Thank you for the reply. I have not purchased your asset yet, but wanted to know if your system was capable of doing what I needed in my game. It sounds like it is, that's great. So thank you for answering my question.

    Velo
     
  25. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I've installed Unity 4.6 today and uGUI looks very promising. I'm now running some tests on it, but I'm now seriously considering to moving EBT rendering to uGUI. It will make all the things much, much simpler to maintain!
     
    jasonMcintosh likes this.
  26. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    Yes, please.
     
  27. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Check this out!

    It will take me some time to have the stable version though, but uGUI is simply great!
     
    Keitaro3660, sandboxgod and OnePxl like this.
  28. AlenBrk

    AlenBrk

    Joined:
    Feb 17, 2014
    Posts:
    33

    Thank you Piotr, i will give it a try asap.
    Many Thanks!
     
  29. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    New version of Energy Bar Toolkit has just been released!

    It's a bugfix release, but remember to backup your project before upgrading!
    upload_2014-9-15_16-53-38.gif

    Improvements
    • Improved performance for scenes that are using atlases
    • MadSprite preview now takes sprite color into the account
    • When initializing an empty scene with no camera, Camera 2D is tagged as MainCamera
    • Warnings and info boxes about incorrect camera setup when using anchors
    Bug Fixes
    • In some cases changing bar settings during play mode caused exceptions to be thrown
    • NGUI, DF-GUI: Fixed crash on using atlases
    • DF-GUI: Fixed PlayMaker state rename issue
    • DF-GUI: Bars wouldn’t hide when widget shouldn’t be seen
    • Windows Store: Fixed compilation error
    • Windows Phone 8: Fixed MadFontData parsing
    • Unity Remote: fixed touch issues
     
  30. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Will this fix issues with DK2 oculus Rift? I cant see my Bar in exported rift builds.
    Either its the GUI or multiple cameras? Anyone else using this in the DK2?
    Can I use it as a 3D object/mesh with no 2D camera associated?
     
    Last edited: Sep 17, 2014
  31. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello HeadTrip, long time no see :)
    There were no significant changes to Oculus Rift support. It's a shame that we couldn't test it through Skype :-(

    What about uGUI? I'm currently working on uGUI version. Will it work better for you? I can send you the early preview version if you want to test it out on Unity 4.6.

    Cheers!
    Piotr
     
  32. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    finally got it, but theres this jittering. slight lag...still looking into it.
    Sorry i cant skype it...biz reasons
     
    Last edited: Sep 22, 2014
  33. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    uGUI will be the standard GUI for unity, so its great to see an update for it :)
     
  34. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Edit1: updated again...
    I just noticed that the stuttering i'm seeing only happens when I move, not when I look around.
    So it must be an issue with my player controller. The energy bar is stuck on there good :)

    Edit2:
    it does actually happen when i look , but just much less. the stuttering is pretty bad, but its the only element shacking when i move...weird

    After watching your vids again, I've parented the 'filled Progress Bar' to the "camera right", it works well except there is allot of juttering/shaking. Also when I moveforward and Back, it moves separately. Its like its on a small spring...
     
    Last edited: Sep 22, 2014
  35. kuolema

    kuolema

    Joined:
    Sep 22, 2014
    Posts:
    5
    Hey Piotr -
    I'm using DF-GUI along with this toolkit. I'm having a problem with the gui depth in that the energy bar is always displayed on top of other DF-GUI controls regardless of z-order used on the DFAnchor element that you provided. I've also tried adjusting the depth on the Filled Renderer panel (all values, negative and positive) to no avail. Any ideas on what I'm doing wrong? Thanks!
     
  36. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello HeadTrip,
    In that case I will try to prepare for two example projects.

    The first one will try to replicate your issue. This is caused because of the script execution order. Let's assume that you have one script that is moving your anchor (ANCHOR_MOVER, not necessary EBT anchor) bar renderer script (BAR_RENDERER, the MadPanel script) and at the end the actual RENDERING is done. The wrong setup may look like this:

    Executing BAR_RENDERER then ANCHOR_MOVER then RENDERING

    This will result in slight visual offset, because the bar on the current frame is rendered before its anchor is moved. The correct setup should be looking as follows:

    Executing ANCHOR_MOVER then BAR_RENDERER then RENDERING

    Would you give me 1-2 days?

    Cheers!
    Piotr
     
  37. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello kuolema,

    That's one important limitation of DF-GUI integration and it's listed in here: http://energybartoolkit.madpixelmachine.com/doc/2.1.6/tutorial/df_gui.html

    In the simplest setup you won't be able to put the bars on different layer than on the top, but if you're experienced with Unity, layers, and cameras, you can try to put some DF-GUI elements on the other Panel (I don't know how this is called in DF-GUI). If you'd like, I can prepare an example for you.

    The issue exists because each GUI toolkit has it's own rendering implementation. This will no longer be a problem with uGUI that is comming with Unity 4.6.

    Cheers!
    Piotr
     
  38. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    of course! I'm just glad you can help me, thank you very much! I really appreciate it.
    I'll try to re-order again. its been a while, I had forgotten about that.
    thanks!
    Drew
     
  39. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    this is my setup, I haven't touched it.

     

    Attached Files:

  40. kuolema

    kuolema

    Joined:
    Sep 22, 2014
    Posts:
    5
    Haha, I watched all the youtube tutorials and followed the packed instructions, but I must have missed that little bit! Thanks for the information, I will try and work around the limitation. You rock!
     
  41. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    1. Please try adding EnergyBarToolkit.MadAnchor somewhere at 10.
    2. How's about the object that the bar is attached to? It is attached to something, am I right? Try to attach let's say a cube to it and see if the effect will be similar. If yes, then something else may be wrong here.
     
  42. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    You welcome! Please write if you will have any difficulties with that :)

    Cheers!
    Piotr
     
  43. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    I did that, no changes. Could it be a scale issue? I have to shrink it down incredibly small to be at a usable scale, it is at "0.0003442961", and that still big. the helmet next to it is at "448.0" scale factor for the mesh is 0.01
    I attached a box the same way I attached the energy bar, it also vibrates but much less.
    It doesn't slide around like the bar. the scale of the box is 0.446533, the scale of the energy bar is 0.001294085
     
    Last edited: Sep 24, 2014
  44. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    This could be the case. Can you send me a video of your current issue? I will create a similar setup to yours and I will try to provide you a working example.

    What exactly is scaled to 0.0003442961? It's damn small number and definitely it will have effect on precision.
     
  45. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    Hi Piotr,

    any ideas when can we expect the update with uGui support? :)

    Cheers!
     
  46. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello Barjed,
    It should be available shortly after Unity 4.6 release. Please send me your invoice id in a private message if you want me to send you the beta version when it will be available.

    Cheers!
    Piotr
     
  47. lenzchu

    lenzchu

    Joined:
    Dec 7, 2013
    Posts:
    15
    Hi there! Just wanted to say I love ETB and using it in my project. I was wondering if I can post a feature request or if it's already possible?
    Would it be awesome if the kit has something like a flashing consume preview bar. Let's say a wizard is about to consume this amount of MP and that amount of bar would be flashing on top of the current MP bar before the player uses the spell.
    Something like the bleed effect before it's used!
     
  48. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello lenzchu,
    I'm glad that you like Energy Bar Toolkit!

    Do you have any example of this particular effect?
     
  49. lenzchu

    lenzchu

    Joined:
    Dec 7, 2013
    Posts:
    15
    Thankyou for the fast reply! And yes, there're 2 examples actually that fits in this situation. One for 'consumption preview bleed' and one for 'additive preview bleed'

    between 29 to 44 secs. It's tiny unless you full screen the video. It's the best i can find that shows the two situations


    It can flash like that. Maybe the best way is to have a Boolean to activate the bleed to whatever buff numbers we apply for it. Weither if it's a negative or positive number that determines an increase or decrease of the bleed.
    Hope that helps!
     
    Last edited: Oct 19, 2014
  50. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Thank you for the example!

    I think it can be achieved right on quite easily. All you have to do is to create a second bar in the exact position of the first one, but only with the bar texture. Adjust its gui depth to be displayed below the first one. Then set it to blink always (at any value). You will need to do some scripting:

    1. If your second blinking bar (let's call it change) should be invisible, set its value to 0
    2. Next step depends if change is positive or negative. If change should be visible and...
    3a. ...target value is lower than origin value, set the main bar value to the target value,and change value to the origin value.
    3b. ...target value is higher than origin value, set the main bar value to the origin value and change value to the target value.

    If you will be having any issues with this, please let me know. I can prepare an working example for you :)

    P.S. I will think about implementing this as an effect in the future. Thanks!

    Cheers!
    Piotr