Search Unity

NJG Minimap [Released]

Discussion in 'Assets and Asset Store' started by hjupter, Apr 23, 2013.

?

Do you need DF-GUI support for this asset?

Poll closed Jun 3, 2015.
  1. Yes

    56 vote(s)
    60.9%
  2. No

    36 vote(s)
    39.1%
  1. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    1.5.4 version has been released to the store:

    https://www.assetstore.unity3d.com/en/#!/content/8339

    - NEW: Map Zones can now generate the texture map on trigger. Added toggle to the MapZone component.
    - NEW: NGUI 3.6.4 support.
    - NEW: Updated Demo scenes.
    - NEW: Optimized shaders for mobiles.
    - NEW: Performance optimizations.
    - NEW: Switched to LeanTween for better performance and more platforms supported.
    - NEW: Simplified the prefab. All you have to do now is drop it inside your UIRoot.
    - DEL: Removed "Layer" option from NJGMap inspector since its no longer needed.
    - FIX: Fixed some issues with inspectors.
    - FIX: Fixed a bunch of issues with the prefabs.
    - FIX: Render camera will work fine on unity 4.3 with occlusion culling.
    - FIX: FOW shaders will change properly when FOW its turned on.
     
  2. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    Hi! I just finished ripping out another Minimap middleware and replacing it with your extension. I have a couple of quick questions though if you could point me in the right direction:

    1) Fog of War with a very light color doesn't seem to work well (black works perfectly well though). Ideally I'd love to see a version of the shader that allows FoW to reveal away a texture (for say a parchment map that gets drawn into as opposed to a black map that gets revealed). This is no big deal, just a quick request if it's easy.

    2) Is there any way to quickly determine what % of the map is revealed? This I definitely need since I have a gameplay feature that requires it, but I can hack this in myself if need be (if there is an existing method that's great though).

    Thanks!
     
    99thmonkey likes this.
  3. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Hey thank you for getting my minimap.

    1. Yeah I've planned a few new features shader wise including this.

    2. I was curious about this feature then I just found out it was pretty simple to add so I added it, coming to the next update, but you can send me your invoice # and I will send this small update.


     
    99thmonkey likes this.
  4. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    Thanks for the prompt response! PMing you now!
     
  5. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    I've got this working almost perfectly, but I'm having one final issue. Icons on the map don't seem to update properly under fog of war. I believe the problem is related to this line:

    Code (csharp):
    1.  
    2. UIMapBase.cs - 968
    3.  
    4. item.isRevealed = (item.revealFOW ? true : NJGFOW.instance.IsVisible(pos)) && (item.revealFOW ? true : NJGFOW.instance.IsExplored(pos));
    5.  
    This seems to be returning false for both IsVisible and IsExplored in situations where it should be true. Zooming the map in and then back out again seems to force all of the icons to update properly.
     
  6. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    Hi hiupter, how to change icon type through code and runtime? e.g. When player is dead I would the the marker type changed from "Player" to "Death", how can I do it?
     
  7. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    What its happening exactly? Icons doesnt dissapear under FOG?

    NJGMapItem mapItem = GetComponent<NJGMapItem>();
    mapItem.type = 0; <- here you set whatever type you have setup on icons section whithin the NJGMap inspector
     
  8. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    This is exactly what I've tried but end up with a weird problem: if i change the type with mapItem.type = 2 in Start() function it works just as I expected. But if I do this at runtime after game starts, maybe in Update() function, the icon won't change at all. Any idea?
     
  9. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    The opposite actually, they don't want to appear. I believe it's related to the 'pos' variable being sent to IsVisible and IsExplored being a 'Map' position, but IsVisible and IsExplored expecting it to be a 'World' position maybe.
     
  10. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Are you using the latest version 1.5.4?

    I will take a look at this.
     
  11. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    No I'm using v1.5.3. I will take a look at the newest version.
     
  12. IndieGameHustle

    IndieGameHustle

    Joined:
    Jul 25, 2012
    Posts:
    66
    @hjupter

    I just updated via The Asset Store and received an error:
    I tried a clean install but the error still is there.

    Error appears: Version 1.5.5 via The Asset Store

    File: NJGTools.cs (104,37) "errorCS0103: The Name 'UICamera' does not exist in the current context"

    It was working fine before the update, :( .....
     
    Last edited: Jul 12, 2014
  13. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    I don't know when he decided to change the whole setup and not really provide instructions or info on it anywhere, but the new setup requires you put the prefab under your normal NGUI UICamera. It no longer has its own camera in the prefab.
     
  14. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Let me take a look at that.

    I mentioned that on the changelog, I decided to do this to simplify the prefab hierarchy and to avoid to have 2 UIRoots and UICameras. If you guys want I can provide another prefab which have everything as before.
     
  15. IndieGameHustle

    IndieGameHustle

    Joined:
    Jul 25, 2012
    Posts:
    66

    Hi,

    Okay I will stand by and wait for a fix.
     
    Last edited: Jul 13, 2014
  16. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    I just fixed this on a new update.

    PM me your invoice number and I will send you the new version fixing this issue, I'm going to submit it to the store soon anyways.

    Here are the changes so far:

    1.5.6
    - NEW: NJGMapItem now reacts properly with FOW showing and hiding if its covered by FOW.
    - NEW: Added a new prefab standalone prefab for NGUI version if you want to use outside of your UI.
    - NEW: Added a new scene for standalone prefab.
    - FIX: Fixed an issue with NJGTools.
    - FIX: Fixed a small issue with NJGZones.
     
  17. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    Where is the logic / checking for when an icon is going to appear on the screen? Since I have my own XYOverhead version, I kind of have to stand on top of something for it to activate, since the setting is XYSizeScroller. Can't seem to find where this is set. Thanks.
     
  18. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Hmm I modified a few scripts, any chance you could send me your version via PM or email so I can integrate your changes?
     
  19. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    Well, I save my player's rotation and use it to rotate everything more or less, so it's not so easy to integrate as you'd need to find the target's rotation. I guess you could get it somehow from the "me" icon, taking the parent's Z rotation or something like that. I'll see if I can pack up what I've done.
     
  20. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Would be easier if you simply use the UIMinimap target property then get the rotation from that.
     
  21. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    Then make a third option for XYOverhead and have it grab the rotation from the map target. You'd solve all my issues, and anyone else who uses a XY Overhead. As I stated somewhere else, the 2D physics only work on XY plane (for now) so I can't be the only person who ran into this issue.

    I have it set to XYSidescroller currently.

    When I rotate my camera, I have to anti-rotate (just opposite direction) all 2D objects in my game that need it. I just use my cached Z rotation value and apply it to everything as needed, including the map items. I have the north icon, map rotation, map locking, icon rotation for player/others all working. Arrows currently are flipped 180 degrees, but I'll figure that out. Icons for other things don't appear until I'm right on top of them, so I think it doesn't quite know what's going on. Fog of war works splendidly too.

    Also, I had to turn the bounds settings off else it just didn't work. Still, when I get to the edge of the map it will draw some line forever on the map, but I figure if I put enough 'dead space' of a tilemap that a player can't access on the edge, I'll fix that, so no big issue. Also had some depth issues with my project, but figured it out. Weird stuff, map going black at times if there's a depth conflict with other NGUI stuff.

    So just wondering where the map icon enable is set so I can make it work. Since you pretty much know what I'm doing for a solution, not sure if me sending the files would help or not. I just had to find where you were determining rotation and change it to my static rotation variable.
     
  22. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Would be easier if you couId send me your changes so I can add it theh XYOverhead mode.
     
  23. DirtyHippy

    DirtyHippy

    Joined:
    Jul 17, 2012
    Posts:
    224
    Have you switched back to UITexture yet for maps? I'm not sure why this was reverted to the method that is used now, but I use UITexture in many places with no issue. Can you move back to this paradigm? It is much cleaner in terms of NGui.
     
  24. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    I removed UITextures because something changed since NGUI 3 and everytime I update the matrix of the material and new icon appeared the UITexture matrix resets to 0,0,0 then back to the original position so it looked like the texture was shaking, but few days ago found out that I can get back to UITextures if I put them into their own panel that will make this small glitch disappear. I will see what I can do for the next update.
     
  25. goy

    goy

    Joined:
    Jul 15, 2012
    Posts:
    10
    Hi hjupter!

    I found a little bug with the FOW Icon revealing.
    I need different distance revealing values for my gameobjects. The global value works perfect.
    For this example I have a player with a map item, that has reveal FOW activated and overrides the global value.
    The other Icons won't appear on the world map, as long as the value is overriden. If I change the reveal distance to something like 30, which is of course way to big for map revealing, all the icons that i missed suddenly pop up on the world map. As far as I can tell, for global and overriden, the isReveal variable on the map item will be set correctly for the mapItems, but the visible calculations of the mapItems themselves seem to be off. Could you please take a look at it?

    I did a bit more testing and even with the global value the same problem occurs, if the object is instantiated far away. Here a little picture of my problem. On the mini map it works fine, but not on the world map.

    https://www.dropbox.com/s/mn8kp1v8l3lfgy0/missing_icon.png
     
    Last edited: Jul 31, 2014
  26. goy

    goy

    Joined:
    Jul 15, 2012
    Posts:
    10
    One more thing I found out. The double click on the mini map gives the wrong world position back (method: MapToWorld). I suspect that it doesn't work well with NGUI. I needed it also for the world map. Here is a solution I came up. I use the localScale (from NGUI) of the _MapTexture to calculate the mouse position. This code can be used for both maps (world, mini)

    Code (CSharp):
    1.  
    2.        public void OnDoubleClick()
    3.     {
    4.         //find the position of the world map on the screeen
    5.         Vector3 F_screen = UICamera.currentCamera.WorldToScreenPoint(planeRenderer.transform.position);
    6.         //calculate the mouse position on the worldmap
    7.         Vector3 F_mouse = new Vector3(Input.mousePosition.x - F_screen.x, 0f, Input.mousePosition.y - F_screen.y);
    8.         //apply the scale of the world map vs screen and the zoom
    9.         F_mouse = new Vector3(F_mouse.x * NJGMap.instance.bounds.size.x / planeRenderer.transform.localScale.x / zoom, F_mouse.y, F_mouse.z * NJGMap.instance.bounds.size.z / planeRenderer.transform.localScale.y / zoom);
    10.         //apply paned position
    11.         Vector3 v2 = WorldScrollPosition();
    12.         F_mouse.x = F_mouse.x + v2.x;
    13.         F_mouse.z = F_mouse.z + v2.z;
    14.  
    15.         if (onMapDoubleClick != null) onMapDoubleClick(F_mouse);
    16.     }
    17.  
     
  27. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Ok, I will take a look at this.

    Thank you, I totally forgot to disable this since did not had time to finish it, I will add this for the next update.
     
  28. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hi,

    i have the version 1.5.3 and don't want to update to 1.5.5 because it needs the newer Unity version. Everything looks fine, very simple first steps. I drag and droped one of your minimap prefabs in my scene, and somehow it just worked, whithout assigning the terrain, that i did later by the way. I have just some questions before i hack around your code:

    (I use it with NGUI)

    - Is it possible to change the size of the icons on the map when i zoom in and out? (smaller icons if the whole map is visible, larger if i zoom in) I working on a starategy game, where all the icons should have the collider
    size (x,z) in the best case. Probably you have already a solution for this problem.
    - In your NGUI examples you have a NGUI root (i guess empty) and then you have another NGUI root which comes with the minimap prefab. Is it the way how we should use the minimap, or is the right way to have just one NGUI root? My idea is to merge together your NGUI with the available NGUI part.

    Thanks in advance
     
  29. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    *cough cough* I did my part and sent my changes to you... so... Where is the logic / checking for when an icon is going to appear on the screen? I haven't had time to look at it myself, but it looks like I'll have to do it I suppose.

    Any word on new version?
     
  30. Catacomber

    Catacomber

    Joined:
    Sep 22, 2009
    Posts:
    682
    How do you call the world map on mobile as my players can't hit any M key?
     
  31. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Well if you could upgrade your Unity that would be the best.

    1. Right now the only way to change the icon size on zoom is to play around with NJGMap.instance.iconSize.
    2. On the latest version there is 2 prefabs a standalone version which comes with its own UIRoot, camera etc and another that is ready to drop it inside your own UIRoot.

    Yeah I'm still trying to find a good way to integrate this. Sorry about that I've been uber busy doing lot of things at the same time.

    For the new version I'm trying to get back to UITextures to avoid certain z-sort issues, there is also a few new cool features coming.

    For the NGUI version there are some scripts ready for buttons to handle zoom, open world map and other stuff, you can check out that on the example scenes.
     
  32. vitah

    vitah

    Joined:
    Jul 21, 2014
    Posts:
    1
    Hello , I try to use NJG MiniMap to make a mini map , but I don't know how to make a map like this picture just show the road and the background is transparent , can you teach me ? My mail is linw1225@gmail.com , many thanks.
     
  33. nigel-moore

    nigel-moore

    Joined:
    Aug 28, 2012
    Posts:
    26
    Hey there,

    Is it possible to not have the minimap showing but still use the worldmap? I have tried but am left with the player icon still visible ...

    FYI - I have used the relative offset in UIAnchor in the Minimap prefab but wondered if there was a more elegant solution

    Thanks
     
    Last edited: Sep 1, 2014
  34. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    @vitah - I thought I read that the picture was made in photoshop or whatever, used as the background, and the minimap just moves the player icon along it. Something like that.

    @nigel.moore - Have you tried: UIMiniMap.instance.Hide() ? What about disabling the gameobject, or even just moving the map off-screen?

    Lastly, I asked a good while ago (6 weeks it seems) about where the logic is for revealing icons. I'm given a reply that, oh hey it's going to be changing so hold on. Well, it hasn't changed yet, the code isn't really a secret obfuscated DLL so perhaps you could just actually tell me where this logic is at rather than me having to spend another 4 hours wading through everything to figure it out. I would really appreciate some information.
     
  35. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    All I did on that map was just put the road on a separate layer then generate an image at editor time and then edit the texture in photoshop.

    So you want to use only the world map? I actually have not tried that but on the new version I'm revamping a bit the code so there is only one map script so you can use as mini or world map but its the same thing.

    You can find that on the UIMiniMapBase.cs inside the UpdateIcon method.
     
  36. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    Thank you.
     
  37. Rodmanix

    Rodmanix

    Joined:
    Dec 4, 2012
    Posts:
    14
    First off, I really like this package. It works great and is intuitive. I do have one issue that I'm having an issue solving. I'm working a sidescroller and everything works fine except the map is stretched on the y-axis. Looks to be about 2x that of the x-axis. Any idea how to fix this?
     
  38. cool9

    cool9

    Joined:
    Sep 10, 2014
    Posts:
    2
    Hi
    I am developing a game using NJG Mimimap Asset.
    But has a problem.
    resolution 2560 * 1440 does not create a mini-map on the cell phone.
    I hope you tell us how to solve.
     
  39. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Maybe you can try setting custom bounds manually.

    This is odd, are you getting any error?
     
  40. cool9

    cool9

    Joined:
    Sep 10, 2014
    Posts:
    2
    Hi
    I am developing a game using NJG Mimimap Asset.
    But has a problem.
    the cell phone does not create a mini-map.

    Samsung Galaxy S5 LTE-A SM-G906S
    Display size : WQHD(2560*1440)

    I hope you tell us how to solve.
     
  41. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    This only happens on your phone? I'm not sure whats going on but I think I've never tried with that resolution.
     
  42. lzt120

    lzt120

    Joined:
    Apr 13, 2010
    Posts:
    93
    Is any plan for supporting uGUI in Unity4.6 ?
     
  43. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Yes I'm working on it ;)
     
    hopeful likes this.
  44. karlozalb

    karlozalb

    Joined:
    Jan 16, 2014
    Posts:
    3
    Hi !

    I'm having some problems with the minimap. I'm using a circled shape, but the elements are showed in the corners (I've attached a screenshot). The symbols that are showed outside the minimap bounds aren't arrows. Any tips? :)

    simbolos-Fuera-minimapa.png
     
  45. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    I hope this support for uGUI of Unity 4.6
     
  46. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Try increasing the culling radiu on the minimap inspector.
    Yes it will support uGUI :)
     
  47. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    When you release with uGUI support version ?
     
  48. jonkuze

    jonkuze

    Joined:
    Aug 19, 2012
    Posts:
    1,709
    Hello, I have a huge problem with this Mini-Map Asset. I would really like to keep using it but it is causing major performance issues with my game. Please see screenshots below, when I have NJG Mini Map enabled I only get about 90FPS, but when I disable I get about 130FPS or more.... I have even disabled all of the other game objects in my scene to test the MiniMap alone with a Camera in my Scene and still I got the same results.... Why? Please Help...

    NOTE: I am using FPS Graph to Report the FPS as Unity Statistics is not accurate at all... see the FPS at the Left Side, Toward the Bottom Left in the FPS Graph UI.

    NJG Mini Map Enabled = 90 FPS

    NJG Mini Map Disabled = 130 FPS
     
  49. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Hi Kuroato I think this might be a small issue with the inspector can you try the same but without having the NJGMap object selected? Also the profiler is better to find out what is going on with the performance of your game. There might be something updating on the inspector that its causing you this so its nothing to worry about I encourage you to open your profiler so you test properly.

    I have battle tested this asset with many devices and there is a lot of users using it for mobile devices even re-generating the map very often.
     
  50. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    I have no ETA on this but probably early next month.