Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

change Camera.targetDisplay ?

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

  1. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    529
    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:
    529
    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,640
    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:
    529
    Well never mind, I'm just stoopid :)
    Setting targetDisplay to 1 does not select "Display 1", it's the index, resulting in "Display 2".