Creating speech bubbles with arrow

I’m doing a top down point and click style game and when characters speak they should have a speech bubble that shows what they are saying, something like this:

I managed to do the dynamic speech ballon by using the GUILayout and it works very well:

GUILayout.Box ("This is a string. I've no idea how long it actually is");

But now I would like to have a little triangle connecting the speech ballon to the head of the player that is actually speaking and I have no idea how I could go about doing it…

Any help very appreciated!

Considering a “triangle” stays in the same place and at the same angle:

You should make a box style containing your bubble image as a background.

  • background image should be a scale-9 image, containing all the rounded corners, and one corner should contain the “triangle”
  • attach this image to your skin as box.background
  • attach the skin to your script and render your box using it
  • then, fiddle the padding until you got the right effect

2 things:

  • you should calculate your bubble coordinates converting 3-D coordinates of your game object to screen coordinates + offsetting it
  • if wanting the bubble size to vary with amount of text, you could use GUIStyle.CalcSize() or similar methods of GUIStyle