Forum begins after the advertisement:
[Part 5] My SceneFader cannot function
Home › Forums › Video Game Tutorial Series › Creating a Metroidvania in Unity › [Part 5] My SceneFader cannot function
- This topic has 22 replies, 3 voices, and was last updated 9 months, 2 weeks ago by Elvin Sim.
-
AuthorPosts
-
April 1, 2024 at 1:04 am #13665April 1, 2024 at 11:23 am #13666::
Hi Ethan, you need to change the
SceneFader
script’sStart()
function toAwake()
:using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class SceneFader : MonoBehaviour { [SerializeField] private float fadeTime; private Image fadeOutUIImage; public enum FadeDirection { In, Out } // Start is called before the first frame update void
Start()Awake() { fadeOutUIImage = GetComponent<Image>(); } ...April 1, 2024 at 11:50 am #13667April 1, 2024 at 11:50 am #13668April 1, 2024 at 4:05 pm #13673April 1, 2024 at 4:30 pm #13676::using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIManager : MonoBehaviour { public static UIManager Instance; private void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); } else { Instance = this; } DontDestroyOnLoad(gameObject); } public SceneFader sceneFader; private void Start() { sceneFader = GetComponentInChildren<SceneFader>(); } }
April 1, 2024 at 9:55 pm #13678::Can you add this above line 25 of your
SceneTransition
as well? I’m checking if eitherUIManager.Instance
orUIManager.Instance.sceneFader
is the null value.print(UIManager.Instance); print(UIManager.Instance.sceneFader);
Show me the output on the Console after that.
April 1, 2024 at 11:53 pm #13679April 1, 2024 at 11:59 pm #13680April 2, 2024 at 11:48 am #13683::Try moving the
sceneFader
up toAwake()
:using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIManager : MonoBehaviour { public static UIManager Instance; private void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); } else { Instance = this; } DontDestroyOnLoad(gameObject); sceneFader = GetComponentInChildren<SceneFader>(); } public SceneFader sceneFader; private void Start() {
sceneFader = GetComponentInChildren<SceneFader>();} }April 2, 2024 at 1:03 pm #13685April 2, 2024 at 1:05 pm #13686April 2, 2024 at 1:09 pm #13687April 2, 2024 at 1:16 pm #13688::and also When I am in the part4 tutorial, after my character healing finish, it will cast the fireball at the same time
April 2, 2024 at 1:21 pm #13689 -
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: