I am working on a Game and am having a bit of an issue with some NGUI buttons. When my game starts I want it to show only one button, that, when the user clicks on it the button goes away and then more buttons show up on the screen. The issue is that when I click on the button, it disappears like it should but it spams an error message saying: game object not set to an instance of an object.
Can anyone help me figure what do I need to do in order to get my buttons showing up correctly? Many thanks in advance!
This is the code I have so far:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class CameraNavigationManager : MonoBehaviour {
enum navigationStates { none, translation, rotation, exitNavigation }
navigationStates currentNavigationState = navigationStates.none;
private float speed = 1.5f;
private float direction = 1;
private float camerDirection = 0;
void Start()
{
GameObject.FindGameObjectWithTag("ExitNavigation").SetActive(false);
GameObject.FindGameObjectWithTag("EnterRotation").SetActive(false);
GameObject.FindGameObjectWithTag("EnterTranslation").SetActive(false);
foreach (var x in GameObject.FindGameObjectsWithTag("ZoomInOut"))
{
x.SetActive(false);
}
foreach (var x in GameObject.FindGameObjectsWithTag("Rotation"))
{
x.SetActive(false);
}
foreach (var x in GameObject.FindGameObjectsWithTag("Translation"))
{
x.SetActive(false);
}
}
void OnGUI()
{
switch (currentNavigationState)
{
case navigationStates.translation:
break;
case navigationStates.rotation:
DisplayButtons();
break;
case navigationStates.exitNavigation:
break;
case navigationStates.none:
break;
}
}
public void ClickEnterNavigationButton()
{
currentNavigationState = navigationStates.rotation;
}
public void DisplayButtons()
{
GameObject.FindGameObjectWithTag("EnterNavigation").SetActive(false);
GameObject.FindGameObjectWithTag("EnterTranslation").SetActive(true);
foreach (var x in GameObject.FindGameObjectsWithTag("ZoomInOut"))
{
x.SetActive(true);
}
foreach (var x in GameObject.FindGameObjectsWithTag("Rotation"))
{
x.SetActive(true);
}
foreach (var x in GameObject.FindGameObjectsWithTag("Translation"))
{
x.SetActive(true);
}
}
}