Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 SpookyCat · Mar 11, 2010 at 09:22 AM · animationimportfbxanimationclipassetpostprocessor

How do you add AnimClips at import time correctly?

Hello Iam slowly making progress on getting my animations into unity but I have an issue that I have to reimport the fbx file for my created clips to show up. For example in this grab you can see the project shows two anim clips but on the right in the inspector the correct 4 clips are shown: alt text But if I then reimport the asset the project shows the correct set of clips alt text Iam making and adding the clips at import time through the AssestPostProcessor class thus:

void OnPostprocessModel(GameObject go) { Debug.Log("PostProcess " + go.name);

BaseData[] data = go.GetComponentsInChildren<BaseData>(true);

for ( int i = 0; i < data.Length; i++ ) data[i].PostLoad(go);

// Deal with anims ModelImporter modelimporter = assetImporter as ModelImporter;

modelimporter.clipAnimations = new ModelImporterClipAnimation[0];

for ( int j = 0; j < data.Length; j++) { if ( data[j].GetType() == typeof(AnimationControl) ) { AnimationControl acon = (AnimationControl)data[j];

     ModelImporterClipAnimation[] anims = modelimporter.clipAnimations;

     ModelImporterClipAnimation[] newanims = new ModelImporterClipAnimation[anims.Length + acon.clips.Count];

     anims.CopyTo(newanims, 0);

     for ( int a = 0; a &lt; acon.clips.Count; a++ )
     {
         ModelImporterClipAnimation clip = new ModelImporterClipAnimation();
         clip.firstFrame = acon.clips[a].StartFrame;
         clip.lastFrame  = acon.clips[a].EndFrame;
         clip.loop   = acon.clips[a].Loop;
         clip.wrapMode   = acon.clips[a].Wrap;
         clip.name   = acon.clips[a].Name;
         newanims[anims.Length + a] = clip;
     }

     modelimporter.clipAnimations = newanims;
     acon.SortAnimsOut();
 }

}

}

So can anyone help into why I have to reimport for the clips to show up correctly, there must be a step Iam missing somewhere. Thanks Chris

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
1
Best Answer

Answer by Murcho · Mar 12, 2010 at 11:47 PM

I posted a script we used in a previous project to perform the animation splits on import here.

Reading through your code, there are a few things I'm not sure of as they are referencing custom classes that haven't been provided (eg AnimationControl), so I can't really comment on what is exactly happening there, however I can say that my script worked reliably so it might be worth looking at to try and fix your issue.

One thing that did stick out however is you are using OnPostprocessModel(), and I am using OnPreprocessModel(). Possibly the editor doesn't see or save the changes until the second import as they are happening after the import, not prior to the import.

Comment
Add comment · Show 2 · 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 SpookyCat · Mar 13, 2010 at 10:24 AM 0
Share

Thank you for the help, yeah your code looks very similar problem is I need to do this on post process as Iam using custom $$anonymous$$ax plugins that export the data to the fbx for the various anim clips and that data is passed in the user properties. I shall have a go today so see if adding some test clips prior to OnPostProcess gives me what I need and if so I guess Ill have to have a slight rethink on maybe storing the data in a anim file or something. Thank you again.

avatar image SpookyCat · Mar 13, 2010 at 08:05 PM 1
Share

Sure enough the code works fine in OnPreprocess$$anonymous$$odel, so a slight massaging of my system and all should be ok, thankyou for your help again. Chris

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

No one has followed this question yet.

Related Questions

Manually Animating Bones then blending with existing animations or saving importing as fbx 3 Answers

How to add UserData to FBX 3 Answers

Motionbuilder->Fbx->Unity. Loads up fine, but animation won't run 0 Answers

Unity reading animations incorrect when constraints used 0 Answers

Model Animation Corruption in FPS Assets? 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