Hi, everyone! Have new Year! I have used the unity for a while and i also attended the training session before.
In my project, I wrote a script “PlayAudioForMouseEnter”, I use the function “OnMouseEnter”.
In the scene,this script attached to objectA.
In play mode, When the mouse enter the ObjectA, the script can work and also play the audio once.
But when i “hold down a key” and “the mouse enter the objectA” , the audio will play again and again.
And I also find out that if i close the script that use “OnGUI” in my scene, the problem is gone.
Do anyone know how to let the audio play once when i “hold down a key” and “the mouse enter the objectA” , and i still can use the script contains the “OnGUI” funciton?
Thanks a lot!! 
if there is some solution in the unity forums, please let me know~
check if the sound is playing, if not play it
Thank you, dreamora.
I really sure that the audio is played onec time.
The “Loop” of audio source is not enabled.
When i hold down the key and the mouse enter at the same time, the audio play again and again.
But when the script ,that contains “OnGUI” function, is not enabled, the problem is gone.
When i hold down the key, the “OnMouseEnter” will reload again and again. How to fix that?

I guess seeing your code would help. You may call it twice or something like this.
The script of “PlayAudioForMouseEnter”
var impact : AudioClip;
function OnMouseEnter () {
audio.PlayOneShot(impact);
}
The script that has OnGUI function “Interface”
function OnGUI () {
GUI.Box (Rect (10,30,230,120), "All Steps");
if (GUI.Button (Rect (60,55,100,20), "Step 1")) {
}
if (GUI.Button (Rect (60,85,100,20), "Step 2")) {
}
if (GUI.Button (Rect (60,115,100,20), "Step 3")) {
}
}
When this script ,“Interface”, is not enabled, the problem is gone.
when “Interface” is enabled,I hold down any key with the mouse enter the object,the “PlayAudioForMouseEnter” reload again and again. And the audio is played again and again.
Do anyone know my question? Did I express clearly ? :shock:
Try putting a print statement in the OnMouseEnter function - this will help you see if the function is incorrectly being called many times. If not, there may be something else wrong with the sound playback.
This problem is still present in Unity 3. Try adding a simple box to your scene with the following script on it:
public class Test : MonoBehaviour
{
// Comment out this function and OnMouseEnter/OnMouseExit will be called at correct times.
void OnGUI() {}
void OnMouseEnter()
{
Debug.Log("Enter: " + Time.time);
}
void OnMouseExit()
{
Debug.Log("Exit: " + Time.time);
}
}
Hold the mouse button down on the box and move the mouse around without actually leaving the box’s area. Debug.Log will be called repeatedly.
Now comment out OnGUI and try again – the problem goes away, and “Enter” is called, but “Exit” is not called until the mouse actually leaves the box.
I’ve submitted a bug about it: http://intra.unity3d.com/fogbugz/default.asp?387913_p3hfhggj
I ran into the same issue back in February 2010. I reported it along with a simple test project that made it easy to reproduce. The bug was closed with no explanation as to why. Here is my own report:
http://intra.unity3d.com/fogbugz/default.asp?332741_tat0mml1
As you noticed, I also found an empty OnGui function is all that is needed to trigger the bug and commenting it out will stop it from occurring.
Bug 332741 got closed as a duplicate of 312053.
Bug 312053 is marked as a bug in 2.x and has not been looked into for 3.x.
Bug 387913 is in a queue of bugs waiting to be looked at. (I have pushed for this to be looked into in the next day or so.)
Thanks for the quick response 
Thanks for that update Dendrophile, its hugely appreciated!