- Home /
Rendering a model inside a GUI rect
When I click on a fish model in my scene I want a GUI box to render with the 3D model of the fish and some info about the fish inside of it. I have the GUI box and information set up correctly but I cannot figure out a way to render a fish model in the GUI.
Code to select which fish has been selected and apply the relevant information:
case "Fish Salmon - Avoidance":
//salmon interaction
Info = "Salmon";
PopUp = true;
print("Salmon");
break;
Code to render the GUI:
void DrawInfo()
{
Rect rect = new Rect(350, 20, 300, 200);
Rect close = new Rect(629, 21, 20, 20);
if(PopUp)
{
GUI.Box(rect, Info);
if (GUI.Button(close, "X"))
{
PopUp = false;
}
}
}
Answer by SunnyChow · Dec 06, 2016 at 02:43 AM
It will be easier for you to create a new camera with RenderTexture and use it to render the fish and then draw that RenderTexture to screen in your GUI script.
Right, you will need a camera anyways. You could set the camera's pixelRect to match the GUI rect, however the camera rect is specifed in screen space, not in GUI space. So it starts at the bottom left. With a RenderRecture it's way easier.
Your answer
Follow this Question
Related Questions
How to automate unity editor screen grabs 0 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
picture in picture 3d. 0 Answers
Separating Procedurally Generated Mesh, Based On Triangle Height 1 Answer