0
나는 장면 간 페이드 (fade) 방법에 대해 Brackeys (here)에서 자습서를 따랐습니다. 내가 할 수있는 한 최선의 튜토리얼을 따라 갔지만 장면을 실행하면 장면이 페이드 인 (일어나지 않아야 함)하고 단추를 누르면 아무 일도 일어나지 않지만 장면이 바뀌기로되어있다.버튼을 눌렀을 때 새로운 장면이 사라지게하려면 어떻게해야합니까?
내 코드가 잘못되었습니다. 버튼을 눌렀을 때 새로운 장면이 사라지도록 수정하는 방법은 무엇입니까?
changeScene.cs
using UnityEngine;
using System.Collections;
public class changeScene : MonoBehaviour {
public IEnumerator changeToGameScene() {
float fadeTime = GameObject.Find("managerObject").GetComponent<fadeScript>().BeginFade(1);
yield return new WaitForSeconds(fadeTime);
Application.LoadLevel("gameScene");
}
}
fadeScript.cs
using UnityEngine;
using System.Collections;
public class fadeScript : MonoBehaviour {
// All Variables
public Texture2D fadeOutTexture;
public float fadeSpeed = 0.8f;
private int drawDepth = -1000;
private float alpha = 1.0f;
private int fadeDirection = -1;
void OnGUI() {
alpha += fadeDirection * 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) {
fadeDirection = direction;
return (fadeSpeed);
}
void OnLevelWasLoaded() {
BeginFade (-1);
}
}
코드에 대한 도움이 필요했지만 귀하의 방식대로 작동 했으므로 어쨌든 답변을 수락했습니다. :) –