当我淡入淡出场景并尝试淡入原始屏幕时,遇到黑屏。例如,从暂停屏幕返回到主菜单让我看到黑屏,我认为这是我的代码的问题。我应该如何解决这个问题?在统一中淡入场景无法正常工作
using UnityEngine;
using System.Collections;
public class Fading : MonoBehaviour
{
public Texture2D fadeOutTexture;
public float fadeSpeed = 0.8f;
private int drawDepth = -1000;
private float alpha = 1.0f;
private int fadeDir = -1;
void OnGUI()
{
alpha += fadeDir * fadeSpeed * Time.deltaTime;
alpha = Mathf.Clamp01(alpha);
GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, alpha);
GUI.depth = drawDepth;
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), fadeOutTexture);
}
public float BeginFade (int direction)
{
fadeDir = direction;
return (fadeSpeed);
}
void OnLevelWasLoaded()
{
alpha = 1;
BeginFade(-1);
}
}
试着问上http://answers.unity3d.com/你很可能会得到一个答案有 – kentor
你真的不应该使用古代遗留下来的GUI系统。现在只使用普通的Unity.UI。使用遗留系统只是不切合实际。 – Fattie
由于kentor提到有这个容易googleable〜100完整的工作示例http://answers.unity3d.com/questions/780323/unity-ui-fading-canvaspanel.html – Fattie