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 diccy · Mar 03, 2016 at 12:08 AM · animatoranimator controlleranimation clip

Make a simple animation viewer

Hi guys !

I'm quite new to Unity and quite bad in english, i'll try to do my best.

I'm trying to make an animation viewer in Unity. I use generic avatars, and I got some troubles to view my animations on Unity viewer builtin. The situation is: all my friends don't get 3D software to check my animations, so I would like to build an Unity scene so they can play randomly animations on a given character. It can be useful for me too, to check if they are well set at the import, before putting them in the gameplay logic.

I began to script it (C#) but i got some troubles. First I wanted to just give to the script, by the Inspector, a character Prefab and a directory where I store animation files (with animation clip inside). But I couldn't manage to give a directory as variable in the Inspector. Is there a way to do it? Or should I put it as string variable written by hand?

Then, with my animation clip list, how could I play them on my character? Is it possible to randomly chose one and play it, by the Animator Component? It's like the animation system does not really allow it. Is there some trick to do it, without building an Animation Controller state machine?

I'm here to find more advices than solutions. If you think i'm on the wrong way, and there is better ones, please tell me.

Thanks!

Comment
Add comment · Show 4
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 Cherno · Mar 03, 2016 at 02:09 AM 0
Share

To access files outside your Assets folder, you need to use System.IO (Check the $$anonymous$$SDN database). You'd have to find a way to import animation files files into Unity at runtime... I don't think it's possible, though. After all, snimations are only created once the start and end frames of a clip are set in the Inspector of a model file. These things have to be done in the Editor. It might be possible to write your own importer, but it's probably better if you find another way.

avatar image diccy Cherno · Mar 03, 2016 at 02:51 PM 0
Share

No it's not the point. Animations are properly imported, by hand, from .fbx files put in the Assets folder, to generate animation clips. I just want to access the animation clips, and play them (one by one of course) on a given character. The question was, is it possible to do it without building before an AnimationController? Or maybe by building an AnimationController at runtime?

avatar image Cherno diccy · Mar 03, 2016 at 05:18 PM 0
Share

You can use the Animation component, which is the legacy animation system. It is simpler than the new Animator system. You can just put one or more clips into it and play them with the Play(clilpName) function.

Animation

avatar image diccy · Mar 04, 2016 at 01:11 PM 0
Share

But the Animation component requires legacy animation clips isn't it?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Theinsanekiller · Mar 04, 2016 at 06:51 AM

For your answer Lets go step by step, First thing you asked is, Is there are way to create an animation viewer? And the answer is Yes, and the way i am able to think is to create an app and play animations randomly so that your friends will be able to play.

Second question was: You can do with directory but the thing is you will have to provide the path where the animations are stored and its bit confusing to do it. There is a lengthy process for doing it.

Third part was: You can do with animation component but it will be far easy if you create an animation controller and create an integer variable and you assign a value for every animation and then by script you will have to get a random no. and assign it to animator and it will play a random animation.

hope this helps. @Diccy

Comment
Add comment · 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 diccy · Mar 06, 2016 at 11:27 AM 0
Share

Oh i choosed very bad words :D ! When I said "play random animation", I meant like "random access". Play any animation I want, without worrying about the states of Animation Controller.

I'm making my way to it:

in Editor only (no pb for me), I found the AssetDatabase class, to get AnimationClips of given directories (it needs an array of pathes), something like this:

     List<AnimationClip> animationList;
     string[] guids = AssetDatabase.FindAssets("t:AnimationClip", animationFolderPathes);
     foreach (string guid in guids)
     {
         string path = AssetDatabase.GUIDToAssetPath(guid);
         animationList.Add(AssetDatabase.LoadAssetAtPath<AnimationClip>(path));
     }

And I'm looking around AnimationControllerOverride to play animation. With one unique (dummy-)state in the Controller, and changing on runtime the AnimationClip referenced in the Override. I'll test it today.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get Animation Clip timeline values from code 1 Answer

[Solved] How to animate multiple objects once I click on one of them 1 Answer

How to auto add animation clips 0 Answers

blend tree animation through script? 0 Answers

Are animation clips tied to game objects? 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