Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by nyahoon · Apr 04, 2017 at 10:30 PM · camerarenderingrendertexture

How to call Camera.Render from Update

Hi,

From Unity 5.6, I got the following error when Camera.Render() is called in Update() function:

Rendering camera 'DrawSomethingToRenderTexture', but calling code does not set it up as current camera (current camera: 'Main Camera') UnityEngine.Camera:Render()

I noticed that Camera has SetCurrent(Camera) static function, but this function did not help.

Is there any way to remove this error? Or, Camera.Render() should not be called in Update function? I need to call it in Update function to see a rendered texture in Editor. The script has "ExecuteInEditMode" attribute but camera events such as OnPostRender are not called in edit mode. So, I had to manually call Camera.Render() in Update function which will be called in edit mode.

Thanks

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Apr 04, 2017 at 10:54 PM

Camera.Render directly renders that camera. It should not be called from Update. While the Update methods are called the rendering engine is not "active".

Have a look at the flowchart in the docs. From there you should call Render() highly depends on the reason why you want to render the camera manually.

If you want to render the camera after all enabled cameras has been rendered you may want to use a coroutine with WaitForEndOfFrame or simply render it during the Repaint event in OnGUI.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nyahoon · Apr 06, 2017 at 03:13 PM 0
Share

Thanks for the reply. That makes sense, but I still got the same error.

I would like to call Camera.Render() between user input in edit mode and Scene View rendering though, I tried OnDrawGizmos, OnGUI, and WaitForEndOfFrame. (OnGUI and WaitForEndOfFrame were not called unless Game View is visible)

I feel like it is a bug of Unity now. If the scene has one object that calls Camera.Render, I got this error:

Rendering camera 'DrawSomethingToRenderTexture', but calling code does not set it up as current camera (current camera: '$$anonymous$$ain Camera') UnityEngine.Camera:Render()

And if the scene has two objects, I got this:

Rendering camera 'DrawSomethingToRenderTexture1', but calling code does not set it up as current camera (current camera: 'DrawSomethingToRenderTexture2') UnityEngine.Camera:Render() Rendering camera 'DrawSomethingToRenderTexture2', but calling code does not set it up as current camera (current camera: 'DrawSomethingToRenderTexture1') UnityEngine.Camera:Render()

I don't know why the current camera at the first error is not $$anonymous$$ain Camera but DrawSomethingToRenderTexture2, it seems like the current camera remains after Camera.Render finished.

avatar image meat5000 ♦ nyahoon · Apr 06, 2017 at 03:13 PM 0
Share

please dont post comments as answers

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

RenderTexture flickering while multiple RenderTexture rendering 1 Answer

Graphics.DrawTexture with multiple camera on mobile device not working 0 Answers

How can I force FPS per camera? 1 Answer

Render texture and shader issues 0 Answers

How to make a custom GrabPass-like sampler2D in MRT shader? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges