Search Unity

4.6 Beta MiniMap and WorldMap Questions

Discussion in 'Immediate Mode GUI (IMGUI)' started by TacoSauce42, Oct 11, 2014.

  1. TacoSauce42


    Mar 20, 2014
    Hello. So I've learned quite a bit over the small amount of time I've been using Unity and I rather enjoy it quite a bit compared to other options out there. So now I want to try and make a MiniMap and WorldMap for my game project. However, I am at a stand still because I'm not sure where to go and how to go about it. I've read and watched several tutorials out there, most being with 2nd cameras. But I had several problems with this.

    The first being that I don't like it as just a second box camera in the top right/left of my screen. And two, I can't figure out how to get the water looking good in that anyways with reflections.

    I'm also using the new test phase 4.6 to try out the new GUI options and found I like the direction they are going. But I still can't figure out a good way to do this. My most recent attempt involved a image on screen that represented a border, a second one that filled the border which represented a mask. But then I tried to use a camera to be masked with an orthographic view and of course that didn't work. So at this point, I was hoping someone could shove me in the right direction. I don't want to buy a asset, I'd like to learn as I go and build from the ground up.
  2. TacoSauce42


    Mar 20, 2014
    Hmmm, I still haven't figured this out. In fact I stepped away temporarily just to work on another UI feature to give my brain a moment to think. Now I'm working on the life and mana bars and already I've come across more problems. I couldn't figure out how to adjust the height of the new images in inspector mode. Finally I figured that I had to use sizeDelta to reach it's height. I then made 3 variables for both mana and life involving minLife, maxLife, and LifePerc. I set lifePerc to minLife/maxLife and same to mana. Then changed the scaling to the texture by doing
    Code (csharp):
    2. var isLIFE = false;
    3. var isMANA = false;
    5. var MinLife = 100;
    6. var MaxLife = 100;
    7. var MinMana = 100;
    8. var MaxMana = 100;
    9. var LifePerc = MinLife/MaxLife;
    10. var ManaPerc = MinMana/MaxMana;
    12. var HealthImage : UI.Image;
    13. var ManaImage : UI.Image;
    15. function Start () {
    17. }
    19. function Update () {
    20.     if(isLIFE){
    21.         LifePerc = MinLife/MaxLife;
    22.        //same happens for the scaling with the texture
    23.         //HealthImage.transform.localScale.y = 160 * LifePerc;
    24.         HealthImage.rectTransform.sizeDelta = new Vector2( 160, 160 * LifePerc);
    25.     }
    26.     if(isMANA){
    27.         ManaPerc = MinMana/MaxMana;
    28.     }
    29. }
    Note that the variable/s isLIFE and isMANA are checked in the inspector. What ends up happening is unless min and max life are the same the % equals 1 for some unknown reason and the height always equals 0 or 160.....