I’m looking for suggestions on how to draw a border around a minimap. Here’s the map (and the failed first attempt at using a GUITexture) as the border.
One thing is, the size of the minimap changes slightly dependent on resolution.
The options I can think of are:
Square GUITexture with transparent centre
Use OnGui to draw boxes
A plane above the camera with transparent centre
Which would you suggest, and any pointers on going about it?
Try this, it is assuming your minimap viewport settings were assigned for a 16:10 aspect ratio. What it does is calculate how much to expand the viewport width and move the viewport left by (compared to 16:10 or aspect 1.6).
#pragma strict
public var minimapCamera : Camera;
private var correctionFactor : float = 1.0;
private var baseRect : Rect;
private var adjustedRect : Rect;
function Start()
{
CorrectMinimapViewport();
}
function CorrectMinimapViewport()
{
baseRect = minimapCamera.rect;
var correctionFactor : float = 1.6 / Camera.main.aspect;
adjustedRect = new Rect( baseRect.x - ( ( baseRect.width * correctionFactor ) - baseRect.width ), baseRect.y , baseRect.width * correctionFactor, baseRect.height );
minimapCamera.rect = adjustedRect;
}
Edit : I just modified the first answer so you don’t have to fill in the baseRect values, it reads them first from the minimap camera.
You can also use the popular KGFMapSystem (unity3d minimap). It is fully customizeable, and is doing all the border stuff automatically. You can also use alpha masks in the pro version to make the minimap appear in a custom shape like a circle…