vvnub
vvnub

Reputation: 33

Unity C# - Hide / Unhide a Button in a different scene

I'm exploring a bit in Unity and C#, I searched everywhere for a solution without luck.

Problem:

How can I achieve this, if possible of course?

Thank you.

EDIT 1:
I tried the following:

I will keep doing my best, but my knowledge is very limited. I'll be back with more feedback if I make progress.

EDIT 2:

Upvotes: 2

Views: 550

Answers (1)

Yuris
Yuris

Reputation: 196

You can make the button a prefab and assign it on a script in the Scene B, and then when you load scene A again, it will be active.

Remember that if you use that prefab anywhere else, it will be active there too.

Example:

Project Inspector Hierarchy

Example.cs:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Example : MonoBehaviour
{
    public GameObject button;

    // Start is called before the first frame update
    void Awake()
    {
        button.SetActive(true);
    }
}

Upvotes: 1

Related Questions