Search Unity

What means use camera.Render() to render the camera manually?

Discussion in 'General Graphics' started by LeavesFalls, May 11, 2015.

  1. LeavesFalls

    LeavesFalls

    Joined:
    Apr 30, 2015
    Posts:
    5
    Well... I'm a newbie in Unity3D...
    Recently I noticed the introduction of Camera.Render() in "Script API" of unity documentation mentioned that
    "To make use of this feature, create a camera and disable it. Then call Render on it".
    I don't know what this means, so I make a test. Just attach a script to the main camera.
    The c# script attached to my main camera :
    public class Test : MonoBehavior{
    void Start(){
    camera.enable = false;
    }
    void Update(){
    camera.Render();
    }
    }

    I think this could render something, but nothing appear except for black, and the blue background is also disappear. So I guess I was wrong.
    The introduction of Camera.Render() shows an example, but it just render to texture. Does it mean this method cannot render to window?
    I wanna close the automatic rendering, and the camera just render the scene when I call some method, meanwhile I wanna control the frame count of rendering, and get the duration of render...
    Sorry, this is the first time I write a thread, maybe the question is unclear...
    But I really need help.
    That's all. Thanks for reading.
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    You have to disable the camera first as it says, otherwise the camera will render automatically. It just lets you control `when` the graphics are actually drawn.
     
  3. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Could you give an example when this would be useful to use?
     
  4. CodeMonke234

    CodeMonke234

    Joined:
    Oct 13, 2010
    Posts:
    181
    The textbook example would be using a RenderTexture.

    In this case, the camera is disabled until you call Render() when you want to capture the camera view to ta texture.
     
    theANMATOR2b likes this.
  5. LeavesFalls

    LeavesFalls

    Joined:
    Apr 30, 2015
    Posts:
    5
    Thank you for your reply.
    My test case shows that I use "camera.enable = false" to disable the camera, then the automatical render is stopped.
    But after that, the camera.Render() seems like of no use. Just like I described before.
    I just wanna know whether camera.Render() can only render to RenderTexture.
    Because I use camera.Render() in Update() but the "Game" window didn't show any thing...
     
  6. LeavesFalls

    LeavesFalls

    Joined:
    Apr 30, 2015
    Posts:
    5
    What if I want to capture the view to window ?
    And do I get one frame by call the method once ??
    If it's true, then I can render arbitrary number of frames by this way...
     
  7. LeavesFalls

    LeavesFalls

    Joined:
    Apr 30, 2015
    Posts:
    5
    Thanks for all the replies.
    I did some cases just now, and figure out that, I cannot use camera.Render() method to render to window, because once it was disabled, it couldn't draw any thing on the screen, except for the Texture.
     
    lauraaa likes this.
  8. squeaky-clean

    squeaky-clean

    Joined:
    Jan 19, 2015
    Posts:
    5
    I know this is an old thread, but it's at the top of google for this type of search, and the comments here ignore important portions of the OPs question.

    Disabling the camera and calling camera.Render() will work in a Build, but within the Play View in the Editor it will show "Display 1: No cameras rendering". I can't find a way to manually control the camera rendering, AND have it render in play mode.

    For now I'm using #IF UNITY_EDITOR and falling back to a simpler rendering pipeline when I need to see things in the Play View.

    In case anyone else finds this from some search engine, try building your game and see if it works. I was searching forever until I found a Reddit thread which had a couple hints about play view in the editor vs builds.
     
  9. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    I think this behavior should be considered a bug. I also need to render my main camera manually, but can not
     
  10. edwardoo22edward

    edwardoo22edward

    Joined:
    Apr 25, 2019
    Posts:
    2
    It just lets you control `when` the graphics are actually drawn.