How to get the gameobject from raycast hit

Hi all,

am very new to Unity and have only very basic knowledge in programing - so have mercy with me if I ask stupid questions :-(.
me together with a few others are working currently on a school project, where an app is to build, which is used for labelling gameobjects.

I came so far that by clicking on a button “Add label” a panel is opening, where a user can enter a label for a gameobject.
I would like to store now the entered label in a string list together with the corresponding gameObject.
As the latter is always different - my question - how can I get the gameobject from a raycast hit (as a label will be proved for the gameobject hit by raycast always).

Would be so grateful, if someone could help me with step by step instructions :slight_smile:

There you go:

thank you :slight_smile: