I am making a unity project. The situation is that I have two toggle buttons (actually more than two) toggle1 and toggle2 and two gameobjects cube1 and cube2. On start both the toggles are unchecked and gameobjects are SetActive(false). What I want is if both buttons toggle1.isOn && toggle2.isOn then cube1 SetActive and if toggle2.isOn && toggle1.isOn then cube2 SetActive according to toggle orders i.e. which toggle is selected first. Now the problem is that When I Checked toggle1 then toggle2 in order both cubes appears and when I Checked toggle2 then toggle1 then again both cubes appears.
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class ToggleToggle : MonoBehaviour {
public Toggle toggle1;
public Toggle toggle2;
public GameObject cube;
public GameObject cube2;
// Use this for initialization
void Start () {
cube.SetActive (false);
cube2.SetActive (false);
}
// Update is called once per frame
void Update () {
// Toggle1 Selected First then Toggle2
if (toggle1.isOn && toggle2.isOn) {
cube.SetActive (true);
}
// Toggle2 Selected First then Toggle1
if (toggle2.isOn && toggle1.isOn) {
cube2.SetActive (true);
}
}
}