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
0
Question by rmccabe82 · Feb 13, 2015 at 09:03 AM · assetbundleanimationclipassetdatabasehumanoid

Set animation clip humanoid

Hi,

I am creating an asset bundle on the fly by importing assets from a given folder. One of the assets is an fbx file, which contains an animation clip. I need to set the IsHumanMotion flag to try, so I use the AnimationUtility.SetAnimationType function to do this. All works great! I try to save using EditorApplication.SaveAssets etc. But when I reload the asset, it tells me IsHumanMotion = false. What am I doing wrong. Here's a code snippet:

 // If this is an fbx asset, do the following
 if (lowerfn.Contains(".fbx"))
                 {
                     // SET HUMAN ON FBX AND COMMIT!
                     var importer = (ModelImporter)ModelImporter.GetAtPath(localPath); // e.g "Assets/Body.fbx"
                     importer.animationType = ModelImporterAnimationType.Human;
                     EditorUtility.SetDirty(importer);
                     EditorApplication.SaveAssets(); // this does save the change to the fbx itself, but I need it commited on the clip.
                 Log("Set model to humanoid via the model importer and saved");

                 // Load the asset.
                 Object[] tObjects = AssetDatabase.LoadAllAssetsAtPath(localPath);

                 // Animation clip object to be searched for in the fbx file.
                 Object animClip = null;
                 
                 // Search the objects within the fbx file for the clip (named the same name as the bundle id).
                 foreach (var item in tObjects)
                 {
                     Log("Searching for clip - this object name = " + item.name);

                     // We know the animation clip has the same name as the bundle id.  So pick it out using that match.
                     if (item.name == bundleid)
                     {
                         Log("Found animation clip! Setting to humanoid");
                         animClip = item;

                         // Set the clip to humanoid.
                         AnimationUtility.SetAnimationType((UnityEngine.AnimationClip)animClip, ModelImporterAnimationType.Human);
                         Log("Clip set to humanoid: " + ((UnityEngine.AnimationClip)animClip).isHumanMotion);

                         
                         EditorUtility.SetDirty(animClip);
                         EditorApplication.SaveAssets();                            
                         AssetDatabase.SaveAssets();
                         AssetDatabase.Refresh();

 // At this point, if I reloaded the asset and got the clip, is human motion would be false again!
                         // Stop the for loop.
                         break;
                     }
                 }

                 // Set T = to animation clip, so it is then added to the list.
                 if (animClip != null)
                     t = animClip;
             }
             else
             {
                 // Load the asset.
                 Object tObjects = Resources.LoadAssetAtPath(localPath, typeof(T));

                 if (tObjects != null)
                     t = tObjects;
             }






Thanks for help in advance!!

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

0 Replies

· Add your reply
  • Sort: 

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

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

How to load Assets as GameObjects? 1 Answer

apply animation to another character Model 1 Answer

AnimationClip in AssetBundle can't load correctly 0 Answers

How to use asset bundle as database instead of PlayerPrefs 0 Answers

How to Load a scene from addressable on the preloading scene without changing scenes?,How do I preload an addressable scene without changing the scene? 2 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