- Home /
Camera render to texture, draw on GUI?
So I'm faced with the task of implementing a minimap in my game.
I have a secondary camera "camera" in ortographic mode, positioned in the center of my terrain, pointing straight down.
I then created a texture in my assets, and told the camera to render to that texture. Then, in my "Main Camera", I have a "minimap" script which has a property 'texture', I drag'n'dropped the texture that the secondary camera is rendering to, into that slot in the editor. The script is as follows:
using UnityEngine;
using System.Collections;
public class Minimap : MonoBehaviour {
public RenderTexture texture;
public Rect position = new Rect(0, 0, 400, 240);
// Use this for initialization
void Start () {
}
void OnGUI() {
//doesn't work :(
GUI.DrawTexture(position, texture);
}
// Update is called once per frame
void Update () {
}
}
And... nothing. No errors but still nothing is being drawn. What am I missing?
Thanks in advance.
Your answer
Follow this Question
Related Questions
MiniMap Border! 1 Answer
Releasing render texture that is set to be RenderTexture.active! (error on android only) 0 Answers
How do I attach a Camera to a GUI (for a Mini map) 4 Answers
How to Hight light object First Person Controller in MiniMAP 2 Answers
Get Intersection of a Line and a Circle? 4 Answers