Forum begins after the advertisement:
[Part 9.5] Scene doesn’t load because scene fader remains black
Home › Forums › Video Game Tutorial Series › Creating a Metroidvania in Unity › [Part 9.5] Scene doesn’t load because scene fader remains black
- This topic has 32 replies, 5 voices, and was last updated 1 week, 6 days ago by tai.
-
AuthorPosts
-
November 19, 2024 at 1:05 pm #16416::
Hi, i am trying out the Part 9.5 project files the project worked fine but all the ability is unlock so i delete all the save files in the folder
C:\Users\phamh\AppData\LocalLow\DefaultCompany\Metroidvania Tutorial
.View post on imgur.com
When i reload the project and open from Main Menu scene its normal but when i clicked Play the screen turned black and i can only hear sound in the background as in the video.
I have tried redownload the project files but its not working anymore.
November 19, 2024 at 7:54 pm #16425November 19, 2024 at 7:57 pm #16426November 20, 2024 at 11:04 am #16444::That is strange. Try expanding the Cave_1 file in your Scene after loading the new level:
View post on imgur.com
I suspect the Scene is loading, but the Scene Fader isn’t deactivating so it looks like the scene isn’t loading.
November 20, 2024 at 11:12 am #16447November 20, 2024 at 11:18 am #16448::Yesterday, I tried to do part 9 from scratch in another project and it worked fine but I havent done pause menu and audio yet.
November 20, 2024 at 12:34 pm #16453::If you are still working on the 9.5 files, try changing the
Start()
toAwake()
inSceneFader
and see if it fixes the issue. More information here: https://blog.terresquall.com/community/topic/part-5-article-changes-common-issues-bugfixes/November 20, 2024 at 12:47 pm #16455::Here is the SceneFader.cs. It already changed to Awake when i downloaded it.
<code>using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class SceneFader : MonoBehaviour { public float fadeTime; private Image fadeOutUIImage; public enum FadeDirection { In, Out } // Start is called before the first frame update void Awake() { fadeOutUIImage = GetComponent<Image>(); } // Update is called once per frame void Update() { } public void CallFadeAndLoadScene(string _sceneToLoad) { StartCoroutine(FadeAndLoadScene(FadeDirection.In, _sceneToLoad)); } public IEnumerator Fade(FadeDirection _fadeDirection) { float _alpha = _fadeDirection == FadeDirection.Out ? 1 : 0; float _fadeEndValue = _fadeDirection == FadeDirection.Out ? 0 : 1; if(_fadeDirection == FadeDirection.Out) { while(_alpha >= _fadeEndValue) { SetColorImage(ref _alpha, _fadeDirection); yield return null; } fadeOutUIImage.enabled = false; } else { fadeOutUIImage.enabled = true; while (_alpha <= _fadeEndValue) { SetColorImage(ref _alpha, _fadeDirection); yield return null; } } } public IEnumerator FadeAndLoadScene(FadeDirection _fadeDirection, string _sceneToLoad) { fadeOutUIImage.enabled = true; yield return Fade(_fadeDirection); SceneManager.LoadScene(_sceneToLoad); } void SetColorImage(ref float _alpha, FadeDirection _fadeDirection) { fadeOutUIImage.color = new Color(fadeOutUIImage.color.r, fadeOutUIImage.color.g, fadeOutUIImage.color.b, _alpha); _alpha += 0.02f * (_fadeDirection == FadeDirection.Out ? -1 : 1); } } </code>
November 20, 2024 at 10:49 pm #16466::Try adding this line to
SceneTransition
. That should fix it:private void OnTriggerEnter2D(Collider2D _other) { if (_other.CompareTag("Player")) { GameManager.Instance.transitionedFromScene = SceneManager.GetActiveScene().name; PlayerController.Instance.pState.cutscene = true; PlayerController.Instance.pState.invincible = true; if(UIManager.Instance.sceneFader == null) UIManager.Instance.sceneFader = UIManager.Instance.GetComponentInChildren<SceneFader>(); StartCoroutine(UIManager.Instance.sceneFader.FadeAndLoadScene(SceneFader.FadeDirection.In, transitionTo)); } }
The problem is likely that
UIManager
loads afterSceneTransition
, causingUIManager.Instance.sceneFader
to be null and breaking the sceneFader transition.November 21, 2024 at 12:05 pm #16470November 21, 2024 at 3:09 pm #16472November 22, 2024 at 4:30 pm #16485::I found the issue Tai. Check your Pause Menu’s Quit to Main Menu button and make sure you unpause the game when the button is clicked. Otherwise, the game remains paused when you quit and return to the level, causing the screen to remain black.
November 24, 2024 at 12:56 pm #16510November 24, 2024 at 3:06 pm #16514November 24, 2024 at 4:57 pm #16521 -
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: