I am making a 2D flashcard game where you are shown a word and you can press buttons to change it to a different language. Each button (there are three) toggles on and off a word but these words occupy the same space and overlap each other. What i want to happen is when i click on one button to toggle on a word the other words are toggled off.
This is what i have so far. I have this script attached to each button.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WordOpener : MonoBehaviour
{
public GameObject haochin;
public GameObject haopin;
public GameObject good;
public void OpenHaochin()
{
if (haochin != null)
{
bool isActive = haochin.activeSelf;
haochin.SetActive(!isActive);
}
}
public void OpenHaopin()
{
if (haopin != null)
{
bool isActive = haopin.activeSelf;
haopin.SetActive(!isActive);
}
}
public void OpenGood()
{
if (good != null)
{
bool isActive = good.activeSelf;
good.SetActive(!isActive);
}
}
}
I haven’t found anything online that i could get to work. Any ideas?