- Home /
How To Put 2 Panel in 1 scene?
I make a menu 1.Panel Menu with start,about,exit (for main camera) 2.Panel Menu with About description (beside the first one ) in 1 scene So the problem I don't know script C# i put on About Button,to take panel about description in 1 scene???Can Help Me Please
Did I got that right: You want to switch to second panel if a button in the first panel is pushed?
Answer by Haerius · May 16, 2016 at 11:47 AM
The easiest way is to have a script, that has references to all your panels, to switch them on/off
using UnityEngine;
public class MenuNavigation : MonoBehaviour {
public GameObject Panel1;
public GameObject Panel2;
public void showPanel1()
{
Panel2.SetActive(false);
Panel1.SetActive(true);
}
public void showPanel2()
{
Panel1.SetActive(false);
Panel2.SetActive(true);
}
}
Just don't forget to assign your two panels to this script. To link your buttons to the script, just click on the "+" symbol inside the On Click() section of your button, drag and drop the gameobject your have set this script to and choose in the dropdownmenu: MenuNavigation -> showPanel1 or showPanel2
One could make this more generic with an GameObject Array, but I think in your case this is the more appropriate answer.