Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
2
Question by $$anonymous$$ · Feb 19, 2012 at 01:16 AM · animationcopyclip

Copying Animation Clips from Imported FBX

I've been reading several posts on this forum that explain how it isn't possible to edit animation clips on a model imported as an FBX (in my case, from Blender), because it's read-only, and that it's necessary to duplicate the animation clip first, and then copy the curves across with an editor script (see here: http://answers.unity3d.com/questions/8172/how-to-add-new-curves-or-animation-events-to-an-im.html)

My problem is that while I can indeed duplicate the clip in question, it insists on placing itself in the Hierarchy folder containing the imported model, but refuses to sit within the imported model. OK, you say - not surprising, because it too is Read Only. Well, the problem I have is that unless it is part of this model, Unity fails to find it if I try to ask the model to play it. I cannot view the new copy in the Animation window either, because it is not part of an object.

Interestingly, I found that at runtime I can call AddClip to add the copied clip to the model, and this actually animates - which is cool, but I still cannot edit the copy in the Animation window because Unity is currently in Play mode. As soon as I go back out of Play mode, I'm back to square one.

I cannot for the life of me find the answer anywhere on the internet, and I'm tearing my hair out now. Can anyone put me out my misery please? I am using Unity 3.5 (basic). I wonder perhaps if something has changed since the article I reference above was written?

I have thought about trying to duplicate all the clips on model-import, but haven't had any success. And, frankly, I can't believe it's really that ugly to achieve what I need here? I've also tried duplicating the imported (FBX) model, with cmd(ctrl)-D, but its animation pane is greyed-out like the original, preventing any changes, so this is a dead-end too (all it's done is duplicate the FBX file on disk - whereas what I hoped for was an editable duplication of the model and its animation data within Unity)

I must have missed something really obvious here? All I want to do is trigger a script to occur at a certain stage of the animation - that is all.

Thanks in advance. Borrus

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 $$anonymous$$ · Feb 19, 2012 at 07:56 PM 0
Share

Update: Just found this: http://answers.unity3d.com/questions/187907/how-to-add-keyframes-on-imported-read-only-animati.html. This suggests I should be able to drag my newly-copied animation clip onto a prefab of my model and edit the clip in the animation window. Unfortunately this doesn't work for me either - it's still read-only. And yes, I have copied the curves over to it.

avatar image $$anonymous$$ · Feb 19, 2012 at 08:14 PM 0
Share

Hmm. The prefab for my model is a placeholder game object which references the $$anonymous$$odel Object from the FBX and instantiates it at runtime. This is as recommended elsewhere on this site, so that re-importing the FBX does not result in having to set everything up again in Unity every time.

Perhaps the simple truth is that this approach is incompatible with the need to modify the model's animation curves? I'd love to know how other people have things set up - I'm in a right ol' mess here...

avatar image $$anonymous$$ · Feb 19, 2012 at 09:11 PM 0
Share

O$$anonymous$$, I believe I have a solution to this, which I'll describe in case anyone else has similar problems. Following my previous comment, I realised that if I simply drag my FBX-imported model onto the scene, I could then finally edit my animation clips. Woo... Also, if I then made it a prefab, I could still do so. This lead me to look at writing an import (i.e. Editor) script that instantiates each new FBX (adding it to the scene), makes a prefab out of it and then destroys the instantiated object:

using UnityEngine; using UnityEditor;

public class Import$$anonymous$$odel : AssetPostprocessor { public void OnPostprocess$$anonymous$$odel(GameObject root) { $$anonymous$$odelImporter modelImporter = ($$anonymous$$odelImporter) assetImporter;

     // Instantiate object in scene
     GameObject inst = (GameObject)GameObject.Instantiate(root, Vector3.zero, Quaternion.identity);

     // Create prefab for it
     Object prefab = EditorUtility.CreateEmptyPrefab("Assets/$$anonymous$$odels/" + root.name + ".prefab");

     // Replace the empty prefab with the newly instantiated model object
     EditorUtility.ReplacePrefab(root, prefab, ReplacePrefabOptions.ConnectToPrefab);

     // Destroy the object we added to the scene
     GameObject.DestroyImmediate(inst);
 }   

}

(apologies for formatting issues - I think this is a line-ending issue with this site)

Once the models are imported via this script, they can then be referenced by the 'empty' that instantiates them at runtime (so that there is no work setting things up again when the model is re-imported).

This just leaves the animation clips. The solution here is to duplicate them - but now, they can be added to this new prefab generated by the editor script above, and they are also then editable. Solution! I'm going to add that to the script above, but haven't got that far yet. I'm sure it's achievable though.

So it looks like I answered my own question here. If anyone's got a better solution, please do speak up though :)

Cheers Borrus

avatar image $$anonymous$$ · Feb 20, 2012 at 07:56 PM 0
Share

Update: O$$anonymous$$, Seems the solution I posted above does not work, so converting it back to a comment, rather than an answer.

First, it is not possible to duplicate animation clips in the editor, it transpires. Second, even if it were possible, how would you then manage the conflict between inco$$anonymous$$g changes to the imported clips and changes made within Unity?

I came up with a solution where I manually create copies of the FBX's clips, and integrate Rune's curve-copying script so this happens for each model during import. This worked wonderfully. If you then drag the copy of the model to the scene, you can edit the curves of the copied clip. However, if like me you have a prefab object which references the model object, in order to avoid having to recreate the GameObject and all its components every time you re-import, and this is what you drag to the scene (and not the copied model), you are stuck: if you click on a model form the Project pane (not the Hierarchy pane) and view its animations, you still cannot edit copied clips, even though they are read/write: the record/play buttons are simply greyed-out :/

I do realise this is probably getting very difficult to follow due to complexity. Perhaps I should call it a day updating my findings here, unless anyone out there is finding it useful.

1 Reply

· Add your reply
  • Sort: 
avatar image
17

Answer by demented_hedgehog · Jan 25, 2015 at 09:41 PM

Select the animation in the fbx and press Ctrl-D... that does what I thik you want? http://forum.unity3d.com/threads/extract-1-animation-from-an-fbx.164509/

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 PhuongND · Sep 21, 2016 at 10:31 AM 1
Share

$$anonymous$$an, you saved my life. Thank you!

avatar image Ransku · Nov 08, 2020 at 06:23 PM 0
Share

You just saved my life also. I just cannot wrap my head around that you cannot ctrl+c / ctrl+v it...

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Transferring animation clips 0 Answers

Animation layers: Am i limited to only one layer per animation? 0 Answers

Animated FBX: Model Rest Position 0 Answers

Extract keyframe info from animation clips 2 Answers

FPS Weapon and animation 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