- Home /
Can you project a camera texture onto a 2d object instead of a 3D object?
I've been working on this system where I record my mini games in pieces with cameras, but the only way I've found out how to project them is to create the render texture and dragging them onto a quad.
Normally, this would be just fine, I think, but my game is in 2D and plays in a 2.5D fashion and it specifically utilizes sorting layers, sorting order, and z positions to organize everything. I've been trying to get the quads to fall into line somehow, but anytime I mess with their z position, things get really messy. it would be best if I could have a 2D sprite house the render texture so I could organize it like any other 2D object in the scene.
I've found very little about this online. Some hints pointed to raw image, making a material with the render texture as a texture and putting that on a sprite, but nothing has worked so far.
Thanks for any advice!
Game so far:
https://www.youtube.com/watch?v=9dzxUfK-J_I&feature=youtu.be
Answer by KISP · Jan 28, 2019 at 03:17 PM
I'm currently doing that in my project without a quad. I left my render texture in my Assets folder, set my camera to render to it, and then dragged the render texture itself (not a material based on it) to the Texture spot on a Raw Image UI script. That should be enough to get it working, but you may need to muck around with the parameters.
Answer by Barzona · Jan 28, 2019 at 06:23 PM
I have tried doing that myself, but it wasn't visible. Would you mind sharing some of your parameters? Can it be sorted like a sprite? By that I mean, access to both the sorting layers and sorting order?
Well, apparently I can't upload images. Here's the parameters:
Dimension: 2D Color Format: ARGB32 Depth: 24 bits with stencil sRGB: Off Dynamic Scaling: off
It's not a sprite, so I don't believe you can use sort order on it. Where in the UI (back, front, etc) are you trying to render it? You might be able to achieve the same effect by changing the render queue of the material or using a mask.
Im not at my computer right now. Is there a way to render this camera texture onto a sprite? That would literally solve everything.
As to where I tried rendering the raw image, I just dragged it onto the stage like anything else. Hmm
I'm not aware of any way to do it, but you could try using Sprite.Create and create the sprite from the render texture's texture at runtime. Would be a pain though if you want to be able to position things in the editor. Sorry, I meant what place would the render texture take in your sort order? If it's behind or in front of everything, you can probably achieve that by changing the material render queue.
Answer by TheLastVoidMage · Apr 08, 2019 at 12:40 AM
I found this video and it really helps. https://www.youtube.com/watch?v=28JTTXqMvOU