Hi
I’m trying to disable and enable gameObjects when a button is pressed, the gameobjects are children of my main character. At the moment when i run the game the gameobjects dont do anything when i click the button.
using UnityEngine;
using System.Collections;
public class Shop : MonoBehaviour {
// Use this for initialization
private bool PopUp;
public string Info;
public GameObject script;
public GameObject weaponScript;
void Start(){
script.SetActive(false);
weaponScript.SetActive(true);
}
void OnMouseDown()
{
PopUp = true;
}
void DrawInfo()
{
Rect rect = new Rect (300,20, 300, 200);
Rect close = new Rect (600,20,20,20);
if (PopUp)
{
GUI.Box(rect, Info);
if (GUI.Button(close,"X"))
{
PopUp = false;
}
if (GUI.Button (new Rect (300, 70, 50, 30), "Click")) {
script.SetActive(true);
weaponScript.SetActive(false);
}
}
}
void OnGUI()
{
DrawInfo();
}
}