Help… how to use if statement in ui buttons… inside of private void update…
Im trying to make a ui buttons inside of the if statement… but is always show in the console edit - projects settings - inputmanage blahblah… but i already made my own function when i hit the button… in the void start i create some onclick listener and when the player hit the button i made my function to and that’s is void pickUpdown and placeDown. or there’s even wrong with GetButtonDown?
If you dont understand… try my other question.
I made my ui buttons and my platform is android. This is what i want when the raycast hit in certain distance… then the ui buttons can do his function that i made and that’s is (void pickUpDown) and (void placeDown) and how do i do that with if statement. I already add some onClick and add listener in void start.
So i hope you understand sorry…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class rayCastCSHARP : MonoBehaviour
{
public GameObject _parent;
public GameObject _testObj;
public GameObject _parent1;
public Button pickUp;
public Button place;
void Start () {
pickUp.onClick.AddListener(pickUpDown);
place.onClick.AddListener(placeDown);
}
private void Update()
{
var fwd = transform.TransformDirection(Vector3.forward);
var hit = new RaycastHit();
if (Physics.Raycast(transform.position, fwd, out hit))
{
if (hit.distance <= 1 && hit.collider.gameObject.tag == "pickup")
{
if(Input.GetButtonDown("pickUp")) {
pickUpDown();
}
}
}
if (Input.GetKeyDown("space"))
{
_testObj.transform.parent = _parent1.transform;
print("please lord");
}
}
void pickUpDown () {
}
void placeDown () {
}
}