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 /
  • Help Room /
avatar image
0
Question by Niknokc · Jan 12, 2017 at 09:19 AM · animationscripting problemassetdatabase

AnimationClips from an fbx file to script

Hello!

I have a problem with pulling actual references of AnimationClips from an .fbx file via script.

Workflow: I'm importing .fbx and cutting animation via script in multiple animations during preprocessing, and then through editor window i input it into Animator and database.

But the only way of getting actual reference of animationClip i found was to get it through LoadAssetAtPath(), and this gets only first one of them( i have 3+ animations in each fbx).

Other way is to instantiate an object, and then i get a copies, but i need references to actual ACs in fbx. Is there any way around this two? Maybe some method like LoadAssetAtPath which lets to get multiple objects of certain type from AssetDatabase?

My project has tons of animations and i want to automatize work with database and animator as much as possible. Of course i can just drag and drop this animations to animator, but where is fun in that(and animator is laggy af after 300+ animations)

Help much appreciated asap. Thank you!

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

Answer by Niknokc · Jan 12, 2017 at 09:55 AM

Well... I've never believed that legends about finding answer right after asking question were true, but, well this is the case.

I found a solution:

 UnityEngine.Object[] data;
 data = AssetDatabase.LoadAllAssetRepresentationsAtPath(myPath);
 clips = new AnimationClip[numOfClips];
 int t = 0;
 for (int i = 0; i < data.Length; ++i) {
     if (data[i].GetType() == typeof(AnimationClip) &&t<clips.Length) {
         clips [t] = data [i] as AnimationClip;
         ++t;
     }
 }
 

It is fairly simple. I'm parsing all assets in fbx file, knowing number of animations that i need(numOfClips). And then adding found animationClip Objects to clips array "as AnimationClip"

Good luck.

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 yaakovyitzchakbenmoshe · Feb 01, 2019 at 02:55 AM 0
Share

Hi I tried this also but apparently AssetDatabase is part of the unity editor namespace, which doesn't work when built, so do you know another way>?

avatar image Niknokc yaakovyitzchakbenmoshe · Feb 04, 2019 at 10:32 AM 0
Share

Hey, @yaakovyitzchakbenmoshe Generally you don't have fbx files in built version. You should preprocess all models beforehand. This question was generally work on smarter version of imputting a lot of animation files without need to set required settings manually. Why do you need to parse through fbx file when app is already built?

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

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

Related Questions

skip a bit forward in current animation? 0 Answers

2D Spine Animation not playing 0 Answers

Unity animator always running only one animation...... 1 Answer

How can I improve this code? 1 Answer

Always wondered how to sync animations with attack effects 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