How to modify canvas independently for each rendering camera?
Hello wise people,
the thing is: I need to modify canvas rotation so it faces each of two cameras while they render their view. Starting with something smaller/easier, I managed to change cube color separately for each camera and tried to affect canvas text color (it's a bit easier to see the effect clearly), but failed. The setup looks like this: (Green script works, red scripts dont.)
And the result is: http://imgur.com/LG1M5y9
I want the text in left view to be red, but it is blue. Both texts change colors to red when I click or drag with lmb.
Cube color changing script is just (this works):
private void OnWillRenderObject()
{
if (Camera.current == Cam1)
{
Obj.GetComponent<MeshRenderer>().sharedMaterial.color = ColorForCam1;
}
else if (Camera.current == Cam2)
{
Obj.GetComponent<MeshRenderer>().sharedMaterial.color = ColorForCam2;
}
}
Text color is being changed by each cameras OnGUI, since Canvases don't trigger OnWillRender. This snippet does not work as expected, resulting with text in the same color in both views:
private void OnGUI()
{
Text.color = RenderOnColor;
}
As far as I understand this, both OnGUI color changes happen before both views rendering (so using OnPreRender/OnPostRender/OnRenderObject would give similar result). I know canvases are being rendered after all geometry, but how should I change their color/rotation so it happens right before rendering, but after second camera render, so I can modify them independently? I don't want 3d text nor two canvases on separate layers.
Project files are here: project zip
Cheers! :)
@Sziler Did you solve the issue? I'm also searching for solution for similar setup. Thanks!