How to add a background to this tooltip text script ?

This tooltip text script works perfectly fine, i want to add a background to it, can any 1 guide me what to do ? plz explain step by step and in simple language…

thanks a lot in advance for ur time

If I understand this code snippet well, one label is drawn on the top of the other in order to provide a shadow effect or to gain contrast with what’s behind the tooltip message. Well.

I would suggest you this:

  1. Add the following line at the top of your script. It enables you to select your background image from the editor (background image, was it what you have meant?).
var backgroundTexture : Texture2D;
  1. In the Start function, add the following line. The background image is now part of the style of the label that will be drawn (foreground label).
guiStyleFore.normal.background = backgroundTexture;

One more thing: make sure the dimension of your background image is 300px width and 60px height, which is the dimension of your tooltip label(s).

i did as u said , but got this error

NullReferenceException: Object reference not set to an instance of an object
mouseOver.Start () (at Assets/mouseOver.js:14)

and

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.GUI.Label (Rect position, UnityEngine.GUIContent content, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/GUI.cs:91)
UnityEngine.GUI.Label (Rect position, System.String text, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/GUI.cs:85)
mouseOver.OnGUI () (at Assets/mouseOver.js:62)

Have you set the background image from the editor/inspector ?

I need the full script to tell you exactly what’s wrong.

yes i added it

see here -
http://www.image-share.com/ijpg-741-131.html

full script below…simple add a cube and assign ur script to it

In the Start function you attempt to update the guiStyleFore object before initializing it. Replace the first and the second line of the function with (mere inversion):

guiStyleFore = new GUIStyle();
guiStyleFore.normal.background = backgroundTexture;

Does it solve your problem?