Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by DaveA · Oct 18, 2010 at 07:35 PM · animationeditorsoundevent

Can't select function in Animation Event

I just want to play a sound (would be nice if the Audio thing had a Play event), anyway I made a little script, added it to my object. I can see the script and all in the Animation editor ok. I add an Animation Event where I want the sound to play. Note I have no compiler errors.

So it brings up the 'Edit Animation Event' dialog, but there are no functions to select! The only 'choice' I have is (no function selected). My script looks a lot like the one in the manual's example. It's JS:

private var sound : AudioSource;

function Start() { sound = GetComponent (AudioSource); }

function Play () { sound.Play(); }

What am I doing wrong, or is this a bug?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gsmetzer · May 29, 2014 at 01:58 AM 0
Share

Happening to me too but nothing I do brings the selections back....Using 4.5.

avatar image meat5000 ♦ · May 29, 2014 at 02:03 AM 0
Share

This is out of Date for bug finding. Submit a fresh question, perhaps in the forum.

9 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by skovacs1 · Oct 18, 2010 at 09:09 PM

I tested what you describe and it worked perfectly fine. I cannot guess at what you have done wrong, but something about your description of your setup is missing. Maybe try a fresh scene and test what exactly you're doing. I created a cube, added a sound and attached the script "function Play(){audio.Play();}" I created an animation in the Animation window that went from position x = 0 at frame 0 to position x = 200 at frame 40. I added an AnimationEvent at frame 20 and I was able to set the function for the Event in the dialog to Play().

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DaveA · Oct 18, 2010 at 10:15 PM 0
Share

Creating a test worked ok, so I know it's not too broken. I deleted my object and recreated, that seemed to fix it. $$anonymous$$aybe I had wrong parenting or something. In any case, not an issue. Thanks.

avatar image
4

Answer by Sylvanas · May 29, 2014 at 04:05 AM

I guess you maybe attached the script to the wrong place which should be attached to where the Animation component exists.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Glicknork · Mar 04, 2018 at 10:49 PM 0
Share

I had the same problem and this was the correct answer. The script needs to be attached to the object the animator component is on.

avatar image
1

Answer by gsmetzer · May 29, 2014 at 01:58 AM

Happening to me too but nothing I do brings the selections back....Using 4.5.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image smoggach · Oct 01, 2014 at 09:27 PM 0
Share

This is happening to me too. I can see all the functions on that script in the list EXCEPT the one I want. However if I make a new object and animation the function is there.

avatar image
1

Answer by Dream-Baked · Jul 16, 2014 at 09:57 PM

If there is an error in the Script file that holds the functions you are trying to call they wont show up.

Play your scene and if it fails to run because of errors, fix them. After that the functions will hopefully appear in the AnimatorEvent drop-down.

If your scene plays fine you probably haven't attached the script file to the GameObject you are animating.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Tony · Feb 05, 2011 at 01:39 AM

This appears to be a bug. Re-opening the scene solved this issue for me.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how do u add sound clips to an animation using animation events? 1 Answer

Play sound on animation event? 3 Answers

Animation events play for all animations when blending? 1 Answer

multiple Animation Events in an Animation 0 Answers

sound not working 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges