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
    I believe you can change the Camera 2D of Energy Bar Toolkit depth to be lower than NGUI, but then all bars will be drawn behind the NGUI.
     
  2. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    67
    Wow, that was simple. ;)
     
  3. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    67
    Just out of curiosity, in the video about attaching to world objects you disable the camera component and I'm wondering why that is. I assume you reactive it later somewhere in your code?
     
  4. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Just before disabling the camera (1:10) do you see this big white square thing that is on top of everything else?
    Normally this camera is used to draw bar objects. Bars should be placed away from the scene and on the unique layer. But if you want to place your bars in 3D, then you want them to be rendered by the same camera as other 3D objects. If I wouldn't disable the 2D Camera component then it would render completely unnecessary things (like this square that I've mentioned above).
     
  5. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    67
    Ok, that makes sense but... how does changing the depth index of the EBT camera affect draw order if it's not being used? Or am I missing something here?
     
  6. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    But you're not disabling the camera component in your case, are you? I'm not sure if I understand the question.
     
  7. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Thats really nice, Piotr. Thanks a lot!

    Have you planed to add custom labels to the bars? Or o ly the current values of health or whatever. Lets say the name of the player. I know that this will be out of the bars purpose, but anyway, just asking.

    Again awesome asset!!!

    Cheers!
     
  8. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello Danirey!
    I'm glad that you like my asset!

    You can easily add custom labels using Tools -> Energy Bar Toolkit -> Create UI -> Text ;-)

    Cheers!
    Piotr
     
  9. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    67
    I tried both enabling and disabling the EBT camera as well as changing the depth order of all cameras as you suggested and I still wasn't able to get the health bars to appear behind the NGUI elements. No matter what, they're always drawn on top of everything. Any other suggestions?
     
  10. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I will add annotations in a moment:



    I've used two layers and three cameras to show how camera masks and depths are working.
     
  11. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    OH! My wife says i can't find anything!!! Maybe it is true!!! ;)

    Sorry and thanks!!
     
  12. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I didn't realized it earlier, but today is exactly a year from when Energy Bar Toolkit has been bought by the first customer!

    Happy first anniversary Energy Bar Toolkit! :)

    I think I will prepare something special for this occasion, but on the next week ;-)

    And this was the banner for 1.0 version!

     
    Last edited: Mar 14, 2014
  13. ojuzu

    ojuzu

    Joined:
    Jun 29, 2006
    Posts:
    67
    Thanks for putting that video together. Amazing support, Piotr!

    This makes it very clear. Thanks for taking the time to do this.
     
  14. Moukib

    Moukib

    Joined:
    Nov 7, 2012
    Posts:
    7
    Hi! just started using your asset, and it works great, saved me a lot of time, but there's a little issue I found, I think the asset scripts are working and changing vars all time, so the scene is constantly changing, always says a change where made and asks for saving, it's quite annoying.
     
  15. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Hello Moukib,
    Thank you for writing! I'm glad that you like my asset!

    I will be working to fix that issue in the future versions. It is annoying me too! (I am using mine tools in my projects also)

    Cheers!
    Piotr
     
  16. Moukib

    Moukib

    Joined:
    Nov 7, 2012
    Posts:
    7
    Thanks for that quick reply!, glad to know you are already on it, will keep an eye on updates :)
     
  17. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Do you want to test out the new version earlier? I think I've just managed to tame the dirty flag on Energy Bar Toolkit scenes. I've made major changes in rendering system so I don't know how it will behave in the wild ;-)
     
  18. unit_power

    unit_power

    Joined:
    Jun 11, 2013
    Posts:
    21
    Hello.

    I am having a problem using the Energy Bar Toolkit ( Mesh Fill Bar )in my 2D game.

    Because of the sorting system in Unity3d my energy back defaults to the "Default" position. I am trying to bring it to the front using the script below, but i cant find a place to put it, since it doesn't leave on the scene.

    This was my solution but is there another way to do sorting order on the Energy Bar Toolkit


    TY,
    -UP



    ------------------------------------------------------------------------------------------------------------------------------------------------
    public class TextureSortingLayer : MonoBehaviour {

    public string sortingLayerName = "Foreground"; // The name of the sorting layer .
    public int sortingOrder = 4 ; //The sorting order

    void Start(){
    renderer.sortingLayerName = sortingLayerName;
    renderer.sortingOrder = sortingOrder;
    }
    }
     
  19. genail

    genail

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

    Are you trying to use Energy Bar Toolkit with 2D features of Unity? I believe that the sorting layers feature is meant only for Unity3D sprite system. Everything else goes to the "default" sorting layer.

    Cheers!
    Piotr
     
  20. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Just found out from where you've got this script. Interesting... Please try to attach this to the Panel object instead of bar objects.
     
  21. unit_power

    unit_power

    Joined:
    Jun 11, 2013
    Posts:
    21
    That did the trick =)

    Thank you!!!
     
  22. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi,

    Here is the thread of my game. I'm using the energy bar, so you guys can see it there as i update the videos.

    Cheers!
     
  23. Moukib

    Moukib

    Joined:
    Nov 7, 2012
    Posts:
    7
    Hi! I'm sorry I took so long to answer, sure, if you still want some testing, can count on me :)
     
  24. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I am surprised that this is even possible! I will add an official support for sorting layers soon ;-)

    Your game look great! Seeing my toolkit working in it makes me really proud of my work :) I will follow your thread to see more!

    I will send you something today then!

    Cheers!
    Piotr
     
  25. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Hi there, i'm using the NGUI integration to put status bars on some icons representing my ships but i'm coming unstuck.

    I need to be able to instantiate the bars along with the icons, I get that my prefabs will only contain the anchors and i'll have to instantiate the actual bars separately but i'm struggling to 'Set' the 'eneryBar' for the 'EnergyBarToolkitNGUIAnchor' to the instantiated actual bar. It seem's to be accepting only EnergyBar3DBase objects but neither casting nor GetComponent<EnergyBar3DBase>() seems to work :(

    Please help!

    James
     
  26. genail

    genail

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

    I'm not 100% sure what you're trying to achieve, but I will try to guess ;-)
    If you want to instantiate NGUI + EBT prefabs, the best way is to move bars object from Energy Bar Toolkit root to the NGUI anchor object, then make a prefab. I've did a little example movie of this behavior:

    [video=youtube_share;fRF1AVtMyKI]http://youtu.be/fRF1AVtMyKI​

    These videos may be helpful too:
    https://www.youtube.com/watch?v=LXoYSMH_Ato
    https://www.youtube.com/watch?v=eyUgspOGUnk

    I see that this is repeating question. I will add this one into the FAQ and NGUI documentation page.

    Cheers!
    Piotr
     
  27. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Thanks for the quick response and you understand my issue which is great but i'm following the video, but when I drag my bar from the EBT/Camera 2D/Panel it just disappears, drag it back and it reappears :/ pretty sure I have the culling masks set correctly...
     
  28. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Does it disappears in the Scene view, Game view or both?
     
  29. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Both, just upgrading to the latest version...
     
  30. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Do you see any errors? Does this also happens if you try to move bar object to the top level in the hierarchy?
    Please also try to remove your Energy Bar Toolkit directory and import it again.
     
  31. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Upgrading didn't help sadly, I have the GUI, EBT and main cameras on different layers, main camera set to omit both the EBT and GUI layers. but moving the actual bar to make it a child of the anchor and it disappears.... been staring at this for hours now, most annoying!! Appreciate the help..
     
  32. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    To the top of the UI Root hierarchy yes it's still the same, i'll try and remove the directory but won't that kill my existing bars? I'm using the bars elsewhere in the project!
     
  33. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Please do a backup of your project.
    If you haven't changed the provided prefabs then it should be fine, but it won't hurt to do a backup ;-)

    P.S. I highly recommend this tool: http://www.plasticscm.com/home.html
     
  34. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Oh yeah of course i'll do a backup, I was just wondering what to expect :) cheers for the version control recommendation, i'm about to re-write and that will come in very handy. I'll just do as you ask now...
     
  35. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I'm still wondering why you're not seeing any errors. Maybe there is other script that messes with it. It may be a good idea to try this out in newly created project. If reimport won't do any good, please try to create a new project, make the bar disappear, and please send me these project files to support@madpixelmachine.com (by selecing only the scene file, right click -> Export Package, but without dependencies).
     
  36. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Boom FIXED - with a recommendation for a sterling product to boot, 5 stars for that man! :D
     
  37. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    That's good news! I am wondering what was wrong.Unitypackage format is very far from being perfect. I heard that Unity 5 will introduce new packing format.

    Thank you for the rating!

    About Plastic. I am using it for all of my projects. It is blazing fast, intuitive, and simple to use. This is client-server app so you need either to setup the server locally (default package includes server components) or remotely. I am using the second option for at least two reasons: 1) When my PC will explode, the code is still safe somewhere else ;-) 2) I'm not the only person to have the access to the codebase.

    Cheers!
    Piotr
     
  38. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Very good, well impressed mate, PS do everyone a favour and just change EnergyBarRenderer slighty:
    Code (csharp):
    1.  public bool visible;
    in declarations and in OnGUI add

    Code (csharp):
    1. if(!visible) {
    2. return;
    3. }
    Gives us the abilities to show/hide the bars at will - really handy!!
     
    Last edited: Mar 31, 2014
  39. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I could add something like this, but wouldn't gameObject.SetActive(false) do the same? If there is a case when adding "visible" property will be a better solution, please let me know.

    Cheers!
    Piotr
     
  40. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    I remember trying that but it doesn't work in all cases for some reason.

    It might be just me though!

    James
     
  41. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    I will make sure to test that before releasing 2.1.0.
    If someone who is reading this had this kind of issue before, please let me know!
     
  42. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Hey Piotr, just having a small problem with the bars not updating now. I'm using the SetMaxValue and SetCurrentValue function on initialisation of the instantiated bars but for some reason the bars show empty, or very slightly full (< 5%)

    Have doubled checked that the bars actually have the correct values by debug.log them and they are correct, the bars just aren't updating... any ideas mate?

    James
     
  43. genail

    genail

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

    Do this bar is working when these values when set manually? If not, please include screenshots of your scene and inspector window after hitting the play button.

    Cheers!
    Piotr
     
  44. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Heh how weird, if I change the values during runtime the bars update - hmmmm, do I need to pass the values through the EnergyBarToolkitNGUIAnchor or something?
     
  45. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    No, that's not the case. Anchor sets only the bar position. What values are you passing using SetMaxValue and SetCurrentValue? I will try to reproduce the issue.
     
  46. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    I'm passing them the values of another bar in the short term, I know I should have both bars reference a central variable lol tbh i'll probably code that in now!
     
  47. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Sorry dude, I was trying to initialise before instantiating!! Weird that I didn't get a compiler error. Sorry to waste your time.

    Peace,

    James
     
  48. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
  49. fieldrequired

    fieldrequired

    Joined:
    Feb 26, 2014
    Posts:
    108
    Spoke too soon, yeah its strange - so in the screenshot below i'm setting the MaxValue of the bar, debug.log the result to prove the variable is set. But look at the anchored energy reveals that the value is back at default? I don't get it :(

    $problem.png
     
  50. genail

    genail

    Joined:
    Jul 2, 2012
    Posts:
    1,045
    Please make sure that:
    - You're sending the message to BarH object
    - You're sending the message to the right BarH object ;-)

    You can also try to modify EnergyBar.cs SetValueMax method to look like this:

    Code (csharp):
    1.     public void SetValueMax(int valueMax) {
    2.         Debug.Log("setting the max value to " + valueMax, this);
    3.         this.valueMax = valueMax;
    4.     }
    So clicking on the log message will select the game object that produced it.