Hi, I have a script that I have attached to my camera to make a fade in and out between the same scene, I have found the script in unity documents, its very simple but very effective on doing it.
The problem is that when I try to run the application on my phone using Cardboard SDK the fade in and out doesnt work, but it works fine in my computer.
Looking at the Cardboard documentation I found this https://developers.google.com/cardboard/unity/reference
I think this is exactly the source of my problem, OnGui() doesnt work with cardboard instead I should be implementing the CardboardUI but I have absolutely no idea on how to implementing it on my code.
I havent found info on how to implement CardboardUI in code, if someone can provide an answear would be great also for others to find it.
Thanks!
Here is the code:
// FadeInOut
//
//--------------------------------------------------------------------
// Public parameters
//--------------------------------------------------------------------
public var fadeOutTexture : Texture2D;
public var fadeSpeed = 0.3;
var drawDepth = -1000;
//--------------------------------------------------------------------
// Private variables
//--------------------------------------------------------------------
private var alpha = 1.0;
private var fadeDir = -1;
//--------------------------------------------------------------------
// Runtime functions
//--------------------------------------------------------------------
//--------------------------------------------------------------------
function OnGUI(){
alpha += fadeDir * fadeSpeed * Time.deltaTime;
alpha = Mathf.Clamp01(alpha);
GUI.color.a = alpha;
GUI.depth = drawDepth;
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
}
//--------------------------------------------------------------------
function fadeIn(){
fadeDir = -1;
}
//--------------------------------------------------------------------
function fadeOut(){
fadeDir = 1;
}
function Start(){
alpha=1;
fadeIn();
For Calling it I use:
Camera.main.SendMessage(“fadeIn”)