Hello, I’m new to unity and am currently trying to figure some things out. As of now, I kind of have movement down. Now, that out of the way. I have a game object that I call a Terminal, and with this Terminal I wish to open a menu from it, like a chest or skill tree. I’ve done some searching around and have some ideas but none have worked thus far. If anyone has any ideas or can provide any help that would be most appreciated!
(This is the code I currently have. There’s more above but I can’t seem to fit it in the box below)
//Entering Trigger
void OnTriggerEnter(Collider other)
{
//Terminal lights up
Renderer render = GetComponent<Renderer>();
render.material.color = Color.blue;
}
//This is where the Menu would be opened up at
void OnTriggerStay(collider other)
{
if (Input.GetKeyUp("e"))
{
}
}
//Exiting Trigger
void OnTriggerExit(Collider other)
{
//Terminal turns off
Renderer render = GetComponent<Renderer>();
render.material.color = Color.black;
}
You’re probably going to have to search around for exactly what you want. There are a TON of videos on YouTube as well… but you typically go to the heirarchy, right click> UI> panel to get a large panel that holds an image. What I usually do is have one big panel that other components are children of and then write my code around that. You can treat ui objects in the hierarchy like any other game object, so building functions to toggle them on and off with SetActive() is fairly easy but here is the docs for UI Unity UI: Unity User Interface | Unity UI | 1.0.0 . **Most of the “making things show on screen” part is done in the hierarchy ** not through code. At least until you get a better understanding on how to access everything with code but that’s really just trial and error. Hope that helped!
@ComedicSoldier I have a craft menu in my game, it works based on a drop-down list. I’ll see if I can explain it’s been a week since I got into my project. It really basically is all text based in my project, however you make a drop-down menu and when you select something the second time it tries to make it.
@jmfp92 thanks for the feedback, I’ll look into it for sure! And as of now, I’m just trying to get something to happen when I click E while in the trigger. I’m pretty sure I could figure out how to make on object change color when I click it, but Have not a single clue as to how I’d get a UI menu to pop up, not to mention to then close it.