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

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #13665
    #13666
    Terence
    Keymaster

    Hi Ethan, you need to change the SceneFader script’s Start() function to Awake():

    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>();
        }
    
        ...
    
    #13667
    #13668
    Elvin Sim
    Participant

    Still Cannot

    #13673
    Terence
    Keymaster

    Can you show me your UIManager script? If you can show this in text, it will be great.

    #13676
    Elvin Sim
    Participant
    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>();
        }
    }
    #13678
    Terence
    Keymaster

    Can you add this above line 25 of your SceneTransition as well? I’m checking if either UIManager.Instance or UIManager.Instance.sceneFader is the null value.

    print(UIManager.Instance);
    print(UIManager.Instance.sceneFader);

    Show me the output on the Console after that.

    #13679
    Elvin Sim
    Participant

    okok

    #13680
    #13683
    Terence
    Keymaster

    Try moving the sceneFader up to Awake():

    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>();
        }
    }
    #13685
    Elvin Sim
    Participant

    thank you it function now

    #13686
    Elvin Sim
    Participant

    but now when my character healing, it will always stuck at the player_heal animation

    #13687
    #13688
    Elvin Sim
    Participant

    and also When I am in the part4 tutorial, after my character healing finish, it will cast the fireball at the same time

    #13689
    Elvin Sim
    Participant

    and also when the player is transitioned to another scene the mana UI is being filled

Viewing 15 posts - 1 through 15 (of 23 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: