How to best create GUI buttons with OnMouseEnter events?

I’m trying to create a game with a 2D user interface. It’s possible I might use some 3d-models but for now I’m trying to make it completely in 2D.

I’ve been trying to create buttons for my GUI that pass OnMouseOver events to my script. Since GUI.Buttons don’t seem to support OnMouseOver directly, I’ve been trying to create buttons using GuiTextures. This has created two problems for me:

  1. GuiTextures keep changing their size when I resize my game viewport. How can I tell them not to scale with the window?

  2. The measurement unit of GuiTexture seems to be in scale of 0-1 or % of viewport. However Gui.Buttons can be positioned measuring in pixels. How can I

I might be missing something vital, such as common sense. Please tell me right away if I’m going completely in the wrong direction.

You should just have the event turn a boolean for the buttons to true and have code like this for making the button:

function OnGUI()
{
   if (myBoolean == true) {
      if (GUI.Button(Rect, Content)) {
         // button code
      }
   }
}

It seems that the hit area for the graphics is always rectangular, even if my graphics are asymmetric. How can I make the mouse collision ignore parts of graphic that is transparent?

Edit: After some searching I came to the conclusion that 2d pixel collision is not natively supported :frowning: