create menu when clicking

Hello everyone.
I am making a card game, and I want my cards to do some actions. I’d like to choose the action they do on a menu that appears when you click on a card.

I tried that. But the menu doesn’t appear when I click on a card.
I did some test and I’m sure that unity knows when I click on a card, but the menu doesn’t appear.

void update
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(hit.collider.gameObject.name == name_of_the_card)
{
action_menu = true;
}
}

void actionmenu()
{
if(action_menu)
{
if(GUI.Button(new Rect(100, 200, Screen.width / 2 - 150, Screen.height - 300), “Attack”))
{
}
if(GUI.Button(new Rect(100, 200, Screen.width / 2 - 150, Screen.height - 300), “Close”))
{
action_menu = false;
}
}
}

You are using the old GUI system, the functions of which only operate from within the void OnGUI() method of a monobehavior, not from within any other function such as actionmenu(), unless you call that function from within an OnGUI() function.

I suggest you take a look at the new Unity GUI tutorials and use that instead. It does not use the GUI class at all and instead contains a series of monobehaviors inside of the UnityEngine.UI namespace.

Also, please review the guidelines on including code in your posts here so the formatting comes out nice and tidy, like so:

void Update()
{
    // do some more code
}

As an addendum, please note that the void Update() function MUST be capitalized precisely the way I just did it, otherwise Unity will not be calling it. Your code has it listed lowercase.