So I’m trying to use OnClick to show my inventory when the button is clicked and it’s not showing and to not show it if it’s clicked and it already is shown. Here is my code:
using UnityEngine;
using System.Collections;
public class ShopShow : MonoBehaviour
{
public GameObject shopButton;
public Vector3 newPos;
bool isShown = false;
public void Start ()
{
newPos = new Vector3(1150, 350, 0);
}
public void ShowShop ()
{
if (!isShown)
{
shopButton.transform.position = newPos;
}
isShown = true;
}
public void CloseShop ()
{
if (isShown)
{
shopButton.transform.position = new Vector3(1150, 5, 0);
}
isShown = false;
}
}
So unless I’m missing something, this should work right?