Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

change Camera.targetDisplay ?

Discussion in '2019.2 Beta' started by Innovine, Jul 22, 2019.

  1. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    509
    I recently upgraded my project to use 2019.2 and notice the following odd behavior.. I am creating a camera which writes to a render texture, and in my initialization code I have:
    Code (CSharp):
    1. camera.targetDisplay = 1;
    However, when I press Play, and go to the camera in the Heirarchy, I can see that it is still set to Display 2. If I manually change this now to 1, it starts rendering to the texture as planned. I don't see why it does not work via the script though.

    Any suggestions?
     
  2. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    509
    Can anyone try this and see? Just set the camera.targetDisplay to an int. Using a script to get the value returns the newly set value, however the camera behaves as if a different value is set, one which is shown in the inspector. I have been unable to actually change the value from a script...
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,326
    If you post a sample project that I just need to open and press play, I can give it a try.
     
  4. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    509
    Well never mind, I'm just stoopid :)
    Setting targetDisplay to 1 does not select "Display 1", it's the index, resulting in "Display 2".