How to link UI elements to gameobject in game?

Hello guys!

I’m trying to make a simple TBS game with hex grid, and i wanna add a simple command menu over all my units on battlefield (something like a simple buttons group - attack, move, special attack):

Whats the right way to do this? Iam trying a lot with simple Unity UI elements, and with UI Builder, but still cant solve this problem.

Actually, I would say to not use UI buttons, but instead, have an object with a tiny trigger follow the mouse, then have the “buttons” do something if they are touching the collider and the player clicked the mouse. That or go on distance to the mouse. The different things the button can do can be marked via a public variable and this way you don’t have to deal with having a canvas follow a gameObject and getting the buttons to do what you want via an outside thing and so on. Though I want to point out this A way to do this, not THE way. This is just the easiest one I can think of.