- Home /
How to make some objects' colour not affected by half-transparent UI?
I'm trying to implement a mechanics of examination of some game objects so that you can rotate them around like in Skyrim's inventory. I've made the whole thing, but what I can't figure out is how to make all objects in background darker, but examined object stay normal during examination. I was thinking about making a half-transparent image just behind examined object, but the image was crossing some close background objects making this look very bad. Maybe there's a way to make examined object not affected by half-transparent image? I don't have any ideas how to make it. Could you please help me?
Answer by ImpOfThePerverse · Apr 07, 2018 at 03:36 PM
It's probably going to take multiple cameras. One way would be to put the inventory item being viewed on a special layer that only renders to the preview camera. The preview camera should be a child of the main camera, should have its culling mask set to only the preview layer (your other cameras should not render that layer), its clear flags set to "depth only", and its depth set to something higher than the main camera and UI camera if you have one. You can set the layer of the object via script after you instantiate it:
https://docs.unity3d.com/ScriptReference/GameObject-layer.html
A second method would be to have a stationary camera somewhere on the periphery of the scene, pointed away from any scene geometry. It should also have its clear flags set to "depth only" and depth set to something higher than the main camera and UI camera. Instantiate the item to be viewed in front of this camera. This saves you from having to set the layer, and lets you set up special lighting for the object without effecting the scene.
Thank you! I haven't thought about making second camera. I think I'm gonna try your second proposition.
Your answer
Follow this Question
Related Questions
UI behavior on resolution change 1 Answer
How to align pixel art with UI system ? 0 Answers
HDRP - Exclude wroldspace UI from post processing 0 Answers
How can we access panel' s children for take Tags ? 1 Answer
Inconsistent transparency with images 0 Answers