That depends on, whether or not the player is in the middle of the minimap, if he is it is easy:
public Texture2D marker;
void OnGUI() {
Handles.DrawCamera (new Rect (5, 5, 105, 105),camera, DrawCameraMode.Normal);
GUI.DrawTexture(new Rect(55,55,marker.width,marker.height),marker);
}
if not then you will have to get the normalposition of the player this depends on how much space the camera is covering in worldspace. If it draws the whole terrain then:
public Texture2D marker;
void OnGUI() {
Handles.DrawCamera (new Rect (5, 5, 105, 105),camera, DrawCameraMode.Normal);
GUI.DrawTexture(new Rect(5+minimapPosX,5+minimapPosY,marker.width,marker.height),marker);
}
void Update() {
minimapPosX = (transform.position.x/Terrain.activeTerrain.terrainData.size.x)*100;
minimapPosY = (transform.position.x/Terrain.activeTerrain.terrainData.size.z)*100;
}
For the enemies you could do this:
//Remember using System.Collections.Generic;
public Texture2D enemyMarker;
public Texture2D marker;
List<Vector2> enemyPos;
void OnGUI() {
Handles.DrawCamera (new Rect (5, 5, 105, 105),camera, DrawCameraMode.Normal);
GUI.DrawTexture(new Rect(5+Vector3ToMap(transform.position).x,5+Vector3ToMap(transform.position).y,marker.width,marker.height),marker);
foreach (Vector2 Pos in enemyPos) {
GUI.DrawTexture(new Rect(5+Pos.x,5+Pos.y,enemyMarker.width,enemyMarker.height), enemyMarker);
}
}
void Update() {
enemyPos.Clear(); //This might be .clear instead, I do not remember
foreach (GameObject enemy in GameObject.FindGameObjectsWithTag("Enemy")) {
enemyPos.Add(Vector3ToMap(enemy.transform.position));
}
}
Vector2 Vector3ToMap(Vector3 pos) {
Vector2 ret = Vector2.zero;
ret.x = (pos.x/Terrain.activeTerrain.terrainData.size.x)*100;
ret.y = (pos.z/Terrain.activeTerrain.terrainData.size.z)*100;
return ret;
}