- Home /
The question is answered, right answer was accepted
Using a game object as a UI image for inventory slots
Hello, I'm building an inventory system for my game, and I'd like the UI images for items to be an actual object of the object I that I picked up, so it would be 3d, and maybe I could have it rotating or something, and I would not have to make an inventory image for it. The main problem that I see with this is that it can be a bit tricky using 3d objects for the UI, and the object would have to have be resized to be larger or smaller so that it will fit in the inventory slots visually. Any ideas would be much appreciated. :)
Answer by Hellium · Oct 19, 2017 at 07:47 PM
You can do this by using Render Textures
Create a Render Texture in your project
Add a
Raw Image
to your UI and set the Render Texture in theTexture
of theRaw Image
Create a new Layer
Put the desired object in this layer
Create a new camera and set the
Culling mask
to be the layer in step #4Adjust your camera to look at the object
Alright, this worked and I now have a camera that will show the object that I am focusing it on, but there are a couple problems.
I can't see the camera that is on the object unless I disable my FPSController camera, is there some way I could have a little box on the screen that shows what the camera for the inventory object is seeing?
I don't know if this would change If I had a little box to show the other camera in, but even when I set the camera to cull everything except the object that I want it to look at, it still shows the grey empty infinity below my game, and the blue sky of my game.
You should be able to see what the camera is rendering by clinking on the latter In the hierarchy.
Set the
Clear Flags
of the camera toDepth only