What would be the best way to use a 3D object in my scene to open UI Windows?
I’ve tried scanning the forums but a lot of the posts I’ve found don’t seem to be working.
I tried this thinking it would act as a normal UI window but it doesn’t.
using UnityEngine;
using UnityEngine.EventSystems;
public class GildHallUI : MonoBehaviour
{
public GameObject openWindow;
public void OpenWindow()
{
if (Input.GetMouseButtonDown(0))
{
openWindow.SetActive(true);
}
}
}
When you check for Input, you need to do that in Update().
Otherwise, it’s difficult to know your setup. If it’s like an FPS, usually you have a raycast that determines if you are close to the button and can trigger it with a mouse click or hitting “E” or whatever. If it’s VR, then it’s usually a collider that you touch. If it’s mobile and you’re tapping, then again, a raycast would probably be the option.
If you just want to test for mouseClick in Update, then it’s going to trigger when you hit the mouse as you don’t currently have a way of knowing if you’re close to the button or not in your code.