Does enabling and disabling an AudioSource cause the sound to play, if playOnAwake is enabled?

I’m trying to sync up a sound to an animation, and so want to play one instance of the sound as the animation loops. It’s an alarm clock. So I have playOnAwake enabled, and I keep enabling and disabling the component using the AudioSource animation triggers. It plays the sound like I would like, so it works perfectly.

I’m really just trying to understand if this is the intended functionality of playOnAwake. Is this “awake” when the component is awoken in this case?

I was under the impression it was when the game object itself was woken up.

Does this extend to scripts? If a script is enabled and disabled, is Awake ran once again?

When you make a gameObject active, it wakes up all children whether they are nested GameObjects or components.

Start() only runs when GameObjects are instantiated. Either when a scene loads (if they are stored in the scene) or instantiated at run time.

You can test that pretty easily, but no, Awake is not called every time you enable a component.

AudioSource.playOnAwake might be a bad name for it, it should probably be called “playOnEnable” since OnEnable is the method that gets called every time you enable a component.