Please see the gif below to better understand what's going on.
On first click they all work normally but after first click I have to double click them to select them. I'm not a advanced developer so I've been trying to figure this out for straight 2 hours and last choice I wanted to ask you guys.
I declared select effect here. (White circle) And added an Array to get all select effects.
public GameObject selectEffect;
private bool isSelected = false;
public GameObject[] selectEffectArray;
I put them inside the Array.
private void Awake()
{
selectEffectArray = GameObject.FindGameObjectsWithTag("planetSelected");
selectEffect = transform.Find("selectEffect").gameObject;
}
I deactivate all select effects on start.
void Start()
{
Deactivate();
}
Here's Deactivate code.
void Deactivate()
{
foreach (GameObject effect in selectEffectArray)
{
effect.SetActive(false);
}
}
When I click one of the planets these happens. (I'm a little confused so I hope you can understand it.)
void OnMouseUp()
{
if (isSelected)
{
selectEffect.SetActive(false);
travelbutton.SetActive(false);
isSelected = false;
}
else
{
Deactivate();
planetName_text.text = planet.name;
requiredFuel_text.text = planet.requiredFuel.ToString();
travelbutton.SetActive(true);
selectEffect.SetActive(true);
isSelected = true;
}
}
I don't want to double click a planet to select it.
