• 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
3
Question by mlepage · Apr 07, 2015 at 02:53 AM · animationclip

Storing Animation Clip in Animator Controller

Using uGUI, a button can generate an animator controller for transitions (normal, highlighted, pressed, disabled). In the project view, this controller has an arrow which, if expanded, shows the animation clips it contains.

My question is, if I create my own animator controllers, how can I create animation clips such that they are stored in the controller, just like the generated ones?

Comment
Add comment
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
2
Best Answer

Answer by DoTA_KAMIKADzE · Apr 08, 2015 at 12:16 AM

If I understood your question right, here are the steps:

Step 1) Select your GameObject that contains your "Animator controller" component in a Hierarchy view

Step 2 v1) If you already have animation clip => go to Animator view => right click (RMB) on the grid => create state => empty => select "New State" => add clip to the Motion

Step 2 v2) If you don't have animation clip => go to Animation view => click here alt text => press "Create New Clip" name and save it somewhere within assets folders => press the red "record button" and start changing values in your object (read more detailed here) => now go to Animator view and it should already contain your new animation node

Step 3) Now assign transition from your new state node to the other ones by clicking on it and pressing right mouse (RMB) => Make Transition => select the other node to which you want to make transition.

P.S. Here is an updated answer to your question update:

Unfortunately as of now you can do that only via code and preferably in Editor or using [ExecuteInEditMode].

Without further hesitation here is the example code:

         // Get controller
         Object anim = AssetDatabase.LoadAssetAtPath("Assets/Something/SomeAnimator.controller", (typeof(Object)));
         // Add an animation clip to it
         AnimationClip animationClip = new AnimationClip();
         animationClip.name = "SomeClip";
         AssetDatabase.AddObjectToAsset(animationClip, anim);
         // Reimport the asset after adding an object.
         // Otherwise the change only shows up when saving the project
         AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(animationClip));

Comment
Add comment · Show 5 · 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 mlepage · Apr 08, 2015 at 12:53 PM 2
Share

I think you are explaining how to create new clips and save them in the assets folder, and use them. I can do that. I am specifically asking how to save the clips so they appear within the controller itself, in the project view.

avatar image DoTA_KAMIKADzE · Apr 08, 2015 at 03:39 PM 1
Share

Well then you should have specified that part about project view in your question.

Will update my answer to your "updated" question in a while.

avatar image mlepage · Apr 08, 2015 at 08:32 PM 0
Share

Yes I will make it clearer. Those clips are used by the controller but not stored in the controller. It's the latter I am interested in.

avatar image DoTA_KAMIKADzE · Apr 08, 2015 at 09:28 PM 2
Share

-_- I've already understood that and already updated my answer 5 hours ago (check the P.S. section of my answer), the part of the previous comment about "project view" was just sort of an "old man $$anonymous$$ching" for the future :D

avatar image mlepage · Apr 08, 2015 at 09:58 PM 1
Share

Alright I see it. I did not know it can only be done in code, although that does suit me fine for this purpose. I will try it. Thank you very much!

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

19 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Play Animation File 3 Answers

AnimationClip must be marked as Legacy 2 Answers

Door with Key script ... animation will not play 0 Answers

Why have newly added character animations made in blender stopped appearing in unity. 0 Answers

How do I access the current playing animation clip of a gameObject? 0 Answers


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