C# Invert Gravity (Test if number is 0 or 1)

Hey can you help me i am trying to fix my script can yall help? What i am trying to do
One:Get the value working so when the value is at 1 it inverts gravity in my levels (i am going to add this to my game managers on the levels so when the value is it at 1 it activates the inverted gravity is activated and at 0 it isn’t)and when the value is at 0 it isnt inverted. Two: When i click my button for the first time it sets the value to 1 if i click it again it resets it to 0.

My script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;

public class InvertGravity : MonoBehaviour {

    public Button yourButton;
    public Button[] yourButton2;

    void Start()
    {
        Button btn = yourButton.GetComponent<Button>();
        btn.onClick.AddListener(TaskOnClick);

        for (int i = 0; i < yourButton2.Length; i++)
        {
            if (i >= 1)
                Debug.Log("1");
            else if (i >= 0)
                Debug.Log("0");
        }
    }

    void TaskOnClick()
    {

    }

    // Update is called once per frame
    void Update () {
		
	}
}

P.S. if you cant see im in C#

Ok in that case I wouldn’t use numbers, if its a simple on/off thing, i’d use a toggle instead. So the scripts from the scene can check if the toggle’s value and determine whether or not to be inverted.

So something like this.

public class InvertGravity : MonoBehaviour 
{
    public Toggle invertToggle;
    public static bool isInverted;

    void Start()
    {
        invertToggle.onValueChanged.AddListener(TaskOnClick);
    }

    void TaskOnClick(bool isOn)
    {
        isInverted = isOn;
    }
}

Then from the scene scripts, you can check if the invert script is on/off like:

public class SceneScript : MonoBehaviour 
{  
    void Start()
    {
        if(InvertGravity .isInverted)
            Debug.Log("Invert gravity");
        else
            Debug.Log("Normal gravity");
    }
}

but there are many ways you could go about this, and doing it this way is a little clunky. but it will get you started