我有一个问题要理解为什么我最初的黑色淡入动画会在第一帧出现毛刺。在统一编辑器中,在游戏开始时,我的淡入动画可以完美播放,但是在Android构建之后,当我开始游戏时,淡入第一个场景(主菜单)无效。在第一帧上,整个场景闪烁,然后淡入淡出部分地进行,游戏继续进行。没有错误消息,游戏没有其他问题。
有趣的是,我为退出按钮创建了一个淡出动画,并且效果很好。
我尝试了有关场景过渡的教程,在场景之间淡入淡出,但这些教程无济于事。他们从已经存在的场景开始过渡。
以下是该教程的链接,该链接部分帮助了我: https://www.youtube.com/watch?v=Oadq-IrOazg
场景管理器
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class GManager : MonoBehaviour
{
public GameObject menu;
public GameObject options;
public GameObject pause;
public GameObject levelChanger;
public bool hide;
public bool show;
public void UIDefaults()
{
hide = true;
show = false;
}
//Start is called before the first frame update
void Awake()
{
Application.targetFrameRate = 60; //Set the target frame rate to 60fps
QualitySettings.vSyncCount = 1; // Sync framerate to monitors refresh rate
levelChanger.GetComponent<Canvas>().enabled = true;
menu.GetComponent<Canvas>().enabled = true;
options.GetComponent<Canvas>().enabled = false;
pause.GetComponent<Canvas>().enabled = false;
}
void Start()
{
StartCoroutine("OnStart");
}
IEnumerator OnStart()
{
yield return new WaitForSeconds(2.15f);
levelChanger.GetComponent<Canvas>().enabled = false;
}
}
UI管理器-退出按钮
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine.UI;
using UnityEngine;
public class UIManager : MonoBehaviour
{
public GameObject menu;
public GameObject levelChanger;
public Animator animatorLevelChanger;
public Animator animatorMain;
public bool hide;
public bool show;
public void UIDefaults()
{
hide = true;
show = false;
}
/* --- EXIT APPLICATION --- */
public void Exit()
{
UIDefaults();
animatorMain.SetBool("MainBool", hide);
StartCoroutine("OnExit");
}
IEnumerator OnExit()
{
yield return new WaitForSeconds(1.15f); // wait for animation to end.
menu.GetComponent<Canvas>().enabled = false;
levelChanger.GetComponent<Canvas>().enabled = true;
animatorLevelChanger.SetTrigger("LevelFadeOut");
yield return new WaitForSeconds(1f);
Application.Quit();
}
/* --- EXIT APPLICATION --- */
}
我只需要帮助或教程的链接即可向我展示如何在android上启动应用程序时在第一个场景(主菜单)中创建淡入淡出效果。