Hello… Im trying to make buttons hide and show when collisions i use SetActive but doesnt even work why?? Here’s my script…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class rayCastCSHARP1 : MonoBehaviour
{
public GameObject _parent;
public GameObject _testObj;
public GameObject _parent1;
public Button btnPickUp;
public Button btnPlace;
public Canvas myCanvas;
void Start () {
btnPickUp.gameObject.SetActive(false);
}
void OnGUI ()
{
if(btnPickUp.SetActive(true))
{
pickUpDown();
}
}
void OnCollisionStay (Collision col) {
if(col.gameObject.tag == "pickup") {
btnPickUp.SetActive(true);
}
}
void OnCollisionExit (Collision col) {
btnPickUp.SetActive(false);
}
void pickUpDown () {
_testObj.transform.parent = _parent.transform;
}
void placeDown () {
_testObj.transform.parent = _parent1.transform;
}
}