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#