change Camera.targetDisplay ?

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:

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?

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…

If you post a sample project that I just need to open and press play, I can give it a try.

Well never mind, I’m just stoopid :slight_smile:
Setting targetDisplay to 1 does not select “Display 1”, it’s the index, resulting in “Display 2”.

1 Like