I’m making a checklist application.
The operation is very simple. When you click in first Toggle, it’ll be disabled. When you click in second Toggle, it’ll be disabled, and so on…
Like this:
Now, I’ve it:
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class AtivaBotao : MonoBehaviour{
public Toggle checklist_toggle;
public bool playersReady;
public void Start(){
checklist_toggle = GameObject.Find("toggle1").GetComponent<Toggle>();
}
public void EnableDisable(){
if (checklist_toggle.interactable == true){
checklist_toggle.interactable = false;
}
}
}
This code works with unique toggle, but I want to scale this. I want scale it for 3, 10, 50, 100 Toggles!
How I can made it?
I think refer the own Toggle, something like that: “this.GetComponent();”.
When I click in Toggle, the code will understand that I am clicking ONLY ON IT.
I tried use the “this” but without successful.
Resume:
→ When I click in first toogle, it’ll be disabled
→ When I click in second toogle, it’ll be disabled
→ and so on…
Anyone can help me? How I can update my code to make it?