• 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
Question by Dan Jimenez · Aug 17, 2010 at 07:18 PM · animationguibuttonassignclips

I Need help assigning animation clips to GUI buttons

I have exported a FBX of a character from maya into Unity. i am trying to assign the animation clips to some GUI buttons I have created. so when one button is pressed a short animation will play

I have broken down the animation clips.

-1st is called idle frames 1-2 (where i would want the action to start and remain until GUI buttons are pressed) -2nd is called raise arm frames (15-33)
-2nd is called raise neck frames (44-78)

i am trying to assign theses animations to this GUI control script for the buttons. The script i have for the GUI buttons is

function OnGUI () { //background box GUI.Box (Rect (10,130,100,90), "Controls");

//Make first button if (GUI.Button (Rect(20,160,80,20), "Arm")){

}

//Make second button if (GUI.Button (Rect(20,190,80,20), "Neck")){

}

}

This is as far as I have gotten. i am new to Java and am not sure how to assign the animations to the GUI buttons. So when each button is pressed it plays the animation clip once. Any help would be greatly appreciated. Thanks.

Comment

People who like this

0 Show 0
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 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by spinaljack · Aug 17, 2010 at 07:31 PM

var model : GameObject;

function OnGUI () {

//background box GUI.Box (Rect (10,130,100,90), "Controls");

//Make first button if (GUI.Button (Rect(20,160,80,20), "Arm")){ model.animation.Play("raise arms", PlayMode.StopAll); }

//Make second button if (GUI.Button (Rect(20,190,80,20), "Neck")){ model.animation.Play("raise neck", PlayMode.StopAll); } }

Drag the model game object into the model slot in the inspector.

Make sure that the animation clips are set up and named correctly in the import asset options.

Make sure that the animations are set to default and not loop so that they play only once.

Comment
Dan Jimenez
LANDO

People who like this

2 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 Dan Jimenez · Aug 17, 2010 at 08:24 PM 0
Share

Thank you so much!! this worked perfect.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to hook up the particle system to jump animation? 1 Answer

GUI Button Animation Cue 1 Answer

Assign a hotkey to a GUI button? 3 Answers

Unity 5 GUI system 1 Answer

How to give animation to the on gui button? 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