Question by
zouzounof · Jun 22, 2020 at 02:54 PM ·
scripting problembuttoninteractable
button.interactable = false; not working ,Button.interectable = false; doesnt work
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI;
public class MenusManager : MonoBehaviour { public Button button2;
public Button button3;
public Button button4;
private EndScene endscene;
private SpriteRenderer questionimage;
public Button bossbutton;
private void Awake()
{
button2 = GameObject.FindGameObjectWithTag("lev2").GetComponent<Button>();
button3 = GameObject.FindGameObjectWithTag("lev3").GetComponent<Button>();
button4 = GameObject.FindGameObjectWithTag("lev4").GetComponent<Button>();
questionimage = GameObject.FindGameObjectWithTag("secret").GetComponent<SpriteRenderer>();
bossbutton = GameObject.FindGameObjectWithTag("bossbutton").GetComponent<Button>();
if (EndScene.level2)
{
button2.interactable = true;
}
if (EndScene1.level3)
{
button3.interactable = true;
}
if (EndScene2.level4)
{
button4.interactable = true;
}
if (EndScene3.level5)
{
}
}
public void GoToLevelSelect()
{
SceneManager.LoadScene("Level Select");
}
public void GoToLevel()
{
SceneManager.LoadScene("Lev1");
}
public void GoToLevel2()
{
SceneManager.LoadScene("Lev2");
}
public void GoToLevel3()
{
SceneManager.LoadScene("Lev3");
}
public void GoToLevel4()
{
SceneManager.LoadScene("Lev4");
}
public void GoToabout()
{
SceneManager.LoadScene("about");
}
public void GoToMenu()
{
SceneManager.LoadScene("Main Menu");
}
public void GoToAppearance()
{
SceneManager.LoadScene("Appearances");
}
}
Comment
The if statements appear to be good (EndScene.level2 is actually true) and the button are assigned and i can see them in the inspector.
The problem is that the buttons dont become interectable . Any suggestions?