I am creating a 2D RTS game and am trying to make a interactable and nice looking minimap. Most of the questions I find are either outdated, the minimap is clickable but ugly looking, or I can place the map on the canvas using a rendered texture and Raw Image, but I can't make it clickable. And by clickable I just mean it moves the main camera to the corresponding spot in the scene.
The minimap camera I have currently is/has the following:
Orthorgraphic, with a depth higher than the main camera
The camera is in the top-right corner by fiddling with the viewport rect.
I have it clickable with the following code attached to the minimap camera:
if (GetComponent<Camera>().pixelRect.Contains(Input.mousePosition) && Input.GetMouseButtonDown(0))
Ray MouseRay = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
Camera.main.transform.position = MouseRay.origin;
I would like to be able to make it look nicer with a border and such, but all the answers I found say I need to render it to a texture and place it on the canvas. This, of course, messes with the functionality of making it clickable.
Any ideas on how to make it work and be nice looking?
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
3 People are following this question.
Raycast through rendertexture gui minimap
Draw minimap on panel
Why does my dynamically instantiated UI element have a different scale than the prefab it was instantiated from?
resetting the my default value for camera field of view