I'm building a DayDream VR game. I've previously had a script to fade out the screen when the user is clicking somewhere to change levels/scenes.
Since I've migrated to Unity 5.6 / Google VR SDK 1.2, any fading effect stopped working. But it still works in Preview mode on my desktop. This is because they changed the way the Camera works. I've tried different scripts online but none of them work, would anyone have an idea on how to do a screen fade on scene change please?
Here is the current main part of the code:
// Derived from OVRScreenFade
float elapsedTime = 0.0f;
Color color = fadeColor;
color.a = 0.0f;
fadeMaterial.color = color;
while (elapsedTime < fadeTime)
{
yield return new WaitForEndOfFrame();
elapsedTime += Time.deltaTime;
color.a = Mathf.Clamp01(elapsedTime / fadeTime);
fadeMaterial.color = color;
}
I've also attempted to use Autofade script. As I mentioned they all work when tried the game on my desktop, they just don't work on the Android phone :(.
Any idea why please?
EDIT: Here is some extra code
public Material fadeMaterial = null; //starts NULL
//applied to cameras inside a function
foreach (Camera c in Camera.allCameras)
{
var fadeControl = c.gameObject.AddComponent<ScreenFadeControl>();
fadeControl.fadeMaterial = fadeMaterial;
fadeControls.Add(fadeControl);
}
FINAL SOLUTION
Using the answer given here, I've created a script file with instructions, feel free to download it and use it if you need the same thing:
https://gist.github.com/xtrimsky/0d58ee4db1964577893353365903b91a