Skip to main content
added 249 characters in body
Source Link

Some things I noticed:

  • onGUI and onLevelWasLoaded should be OnGUI/OnLevelWasLoaded
  • You forgot to set the red component here, so you are not setting the alpha value of the color

GUI.color = new Color (GUI.color.g, GUI.color.b, alpha);

  • Try to set the alphaBlend parameter to true on the DrawTexture function (I think it's true by default, but I didn't test it, so give it a try):

GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeOutTexture, ScaleMode.StretchToFill, true);

  • You shouldn't change the alpha value in the OnGUI function, it's better to do in the Update

    You shouldn't change the alpha value in the OnGUI function, it's better to do in the Update

  • I don't know how you are using the code, but remember that Unity will destroy the object you attached the script on when you load a new scene. I suggest you to write a static class to switch levels, or use DontDestroyOnLoad on your GameObject

Some things I noticed:

  • onGUI and onLevelWasLoaded should be OnGUI/OnLevelWasLoaded
  • You forgot to set the red component here, so you are not setting the alpha value of the color

GUI.color = new Color (GUI.color.g, GUI.color.b, alpha);

  • Try to set the alphaBlend parameter to true on the DrawTexture function (I think it's true by default, but I didn't test it, so give it a try):

GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeOutTexture, ScaleMode.StretchToFill, true);

  • You shouldn't change the alpha value in the OnGUI function, it's better to do in the Update

Some things I noticed:

  • onGUI and onLevelWasLoaded should be OnGUI/OnLevelWasLoaded
  • You forgot to set the red component here, so you are not setting the alpha value of the color

GUI.color = new Color (GUI.color.g, GUI.color.b, alpha);

  • Try to set the alphaBlend parameter to true on the DrawTexture function (I think it's true by default, but I didn't test it, so give it a try):

GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeOutTexture, ScaleMode.StretchToFill, true);

  • You shouldn't change the alpha value in the OnGUI function, it's better to do in the Update

  • I don't know how you are using the code, but remember that Unity will destroy the object you attached the script on when you load a new scene. I suggest you to write a static class to switch levels, or use DontDestroyOnLoad on your GameObject

Source Link

Some things I noticed:

  • onGUI and onLevelWasLoaded should be OnGUI/OnLevelWasLoaded
  • You forgot to set the red component here, so you are not setting the alpha value of the color

GUI.color = new Color (GUI.color.g, GUI.color.b, alpha);

  • Try to set the alphaBlend parameter to true on the DrawTexture function (I think it's true by default, but I didn't test it, so give it a try):

GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeOutTexture, ScaleMode.StretchToFill, true);

  • You shouldn't change the alpha value in the OnGUI function, it's better to do in the Update