How to hide a button when a certain scene is not active?

Is it possible to update my buttons animation when a certain scene is active?
I have an event trigger setup to hide the button
130011-agfgaga.png

You could create a mini script you put on the button to disable on awake. (Since awake will be called each time the scene changes). We just check what the current scene is


    using UnityEngine;
    using UnityEngine.SceneManagement;


	public class ButtonHider : MonoBehaviour
	{
        [SerializeField] string hideWithScene;
        //[SerializeField] int hideWithIndex;    // If you wanted to do index

        void Awake()
        {
            Scene currentScene = SceneManager.GetActiveScene();
            if (currentScene.name == hideWithScene)
            {
                // HIDE BUTTON;
            }

            //// You could do index instead if you wish
            //if (currentScene.buildIndex == hideWithIndex)
            //{
            //    // HIDE BUTTON
            //}
        }
    }

Thanks, I’m using

navButtonBack.gameObject.SetActive(true);

But whenever I set it false, It gives me the following error, I can’t seem to find another way to hide the button.

NullReferenceException: Object reference not set to an instance of an object
SceneTransition.Awake () (at Assets/SceneTransition.cs:46)