Answers for "unity set toggle in code"

C#
0

how to save toggle values unity

public Toggle Toggle;

    private void Start() {
        if ((PlayerPrefs.GetInt("ToggleBool") == 1)) {
            Toggle.isOn = true
        }
        else {
            Toggle.isOn = false;
        }
    }

    private void Update() {
        if (Toggle.isOn == true) {
            PlayerPrefs.SetInt("ToggleBool", 1);
        }
        else {
            PlayerPrefs.SetInt("ToggleBool", 0);
        }
Posted by: Guest on October-30-2020
1

toggle unity c#

private bool togl;//this is either true or false

        if (Input.GetKey(KeyCode.A)) //can have whatever statment you want here
        {							 
            togl = !togl; //this is what changes the bool
        }
Posted by: Guest on May-23-2020
0

unity change toggle with script

toggle.isOn = true
Posted by: Guest on September-19-2021

C# Answers by Framework

Browse Popular Code Answers by Language