- Home /
How to create a pop out interface after selecting a map marker?
Hi I'm fairly new to unity and I'm currently working on a project where I need an interface to open after a prefab has been clicked on. It's an interactive map, so I need information to appear once the user has clicked on a map marker.
At the moment, I have a script in place that turns the sphere (prefab) from white to green. Here's the first part of it:
public class Click : MonoBehaviour {
[SerializeField]
private LayerMask clickablesLayer;
void Update() {
if (Input.GetMouseButtonDown(0))
{
RaycastHit rayHit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out rayHit, Mathf.Infinity, clickablesLayer))
{
rayHit.collider.GetComponent<ClickOn>().ClickMe();
{
}
(There are more closed brackets at the end, just saving space)
And here's the second part:
public class ClickOn : MonoBehaviour
{
[SerializeField]
private Material white;
[SerializeField]
private Material green;
private MeshRenderer myRend;
void Start()
{
myRend = GetComponent<MeshRenderer>();
}
public void ClickMe()
{
myRend.material = green;
}
}
I'm sure there's a way to make it so that the icon not only turns green, but also creates an interface, but I'm new to unity and am unsure of what exactly to add to these scripts. FYI, I'm not looking for message to appear and fill the screen, ideally it'd appear next to the selected icon. I'd also need a function that closes the pop-up interface when an exit button is selected and when a user has clicked on another marker.
Cheers in advance.
Your answer
Follow this Question
Related Questions
How do I make an interactive map on Unity? 0 Answers
Apply shader to terrain 0 Answers
Building Unity map best practises 0 Answers