How to clamp icon in minimap's border when the minimap shape is random?
Hi,
I am working on minimap. I was able to clamp the distant icons in the minimap border when the minimap shape is Rectangular or Circular.
I am searching for a way to clamp the icons in the border in case of different shapes like the attached image.
I've used Unity's default UI Mask for creating different shaped minimaps.
I was thinking, if I could detect the edge of the Mask image according to alpha value and clamp the icons in the edge. But couldn't find any way for it. Any suggestion is appreciated. Thanks in Advance.
Hey, this isn't an answer but how are you able to clamp icons on a circular $$anonymous$$imap?
You can follow the above method, I mentioned above. To be precise you can: 1. take a Circle Collider 2D around your $$anonymous$$imap(Black circle in the attached image). 2. raycast from the out of $$anonymous$$imap icon(start in the attached image) to the center of the $$anonymous$$imap(red circle) 3. $$anonymous$$ove the $$anonymous$$imap icon from it's original position to raycast hit point(green box in image) from step 2. https://imgur.com/a/CiNba
Answer by Determined · Aug 04, 2017 at 09:45 PM
I was able to solve the issue. So, writing it down here, in case anyone needs it.
I tried using RaycastMask and was able to solve it.
However, it was not optimised at all, checking pixel by pixel if the alpha was > 0.
So, I came up with an idea using polygon collider and it worked much more efficiently.
1. I raycasted from the out of minimap icon(red icon in the image) to the center of the minimap(green icon).
2. Then detected the point where it hit the polygon collider.
3. Changed the position of the out of map icon to this hit point.
In case anyone is interested, my minimap plugin is now available here:
https://www.assetstore.unity3d.com/en/#!/content/91675