thanks for your time. i’m new to c# & trying to figure out how GetButtonDown / GetButtonUp is used,
asking why the following code does not work. don’t get errors to display i’m doing anything wrong. i’ve also already have the tag added to my input.
using UnityEngine;
using System.Collections;
public class ChargingLogic : MonoBehaviour
{
public bool isCharging = false;
public string textToDisplay = "Click";
//
void Update ()
{
if (Input.GetButtonDown (textToDisplay) && !isCharging)
Debug.Log ("GetButtonDown textToDisplay");
isCharging = true;
if (Input.GetButtonUp (textToDisplay))
Debug.Log ("GetButtonUp textToDisplay");
isCharging = false;
}
void OnGUI ()
{
if (GUI.Button(new Rect(10,70,50,30),textToDisplay))
Debug.Log("Clicked the GUI button");
}
void Charge ()
{
if (isCharging) {
Debug.Log ("Charging");
} else {
Debug.Log ("Not Charging");
}
}
}