Search Unity

Make an image out of a 3d object?

Discussion in 'Scripting' started by Corva-Nocta, Mar 5, 2019.

  1. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    801
    Not totally sure if this post will be in the right place but I hope I guessed right!

    I have a selection of different projectiles the player can choose for their weapon, a simple capsule and sphere for now, and I am working on displaying them in a selecrion screen. I have two buttons set up and a simple toggle when they are selected, nothing fancy. I would like to have an image for the buttons that show the projectile, and if at all possible have then spin or have the shaders attached to then play.

    I have been poking around but haven't been able to find how this is done, does anyone know wht this is called? I've tried sesrching for turning a 3d model into an image but I seem to find nothing but the opposite.

    If this is not possible I'll just take a simple picture of it in blender and do it that way, I just would prefer something with a little more flare :)
     
  2. jasrei

    jasrei

    Joined:
    Apr 19, 2018
    Posts:
    15
    RenderTexture is what you want I believe.
     
  3. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    801
    Hm I found a little information on Render Textures, but I'm not finding anything that would do what I am looking for. Do you by chance have a link? I guess what I am looking for is how to put 3d objects onto a canvas, if that is possible
     
  4. Corva-Nocta

    Corva-Nocta

    Joined:
    Feb 7, 2013
    Posts:
    801
    I found some info on it finally. It is possible, but I would have to switch my canvas to screen space rather than overlay. Not that it would be horrible to switch but I just don't feel like doing it that way right now haha. Its not that important for me to change it. Appreciate the help though!
     
  5. jasrei

    jasrei

    Joined:
    Apr 19, 2018
    Posts:
    15
    I'll see if I can find an article. I recently had a similar problem, I have a little RPG type character/inventory screen and I wanted to show an image of my character on the inventory screen. I could have just taken a static image and put it there, but I wanted the image to update in real time as I equipped items.

    What I did was add a camera to the scene pointed at the front of my character, set it's Culling Maskso that it could only "see" my character and the equippable items, set it's clear flags to solid color(black) instead of skybox and set it's target texture to a render texture. Then I was able to add the render texture to my canvas just like any other texture. What I ended up with was this. It obviously looks pretty ugly as I've made no attempt to make it actually look good, but it accomplished I think basically what you are asking for. Of course, it takes a camera pointed at the object to do it, but I'm not aware of any other way.
     

    Attached Files:

  6. WheresMommy

    WheresMommy

    Joined:
    Oct 4, 2012
    Posts:
    890
    You just need a camwra rendering to a rendertexture and then a rawimage in your canvas fed by your rendertexture