Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Blender 2.8 animations not importing in Beta 2019.3.0b4

Discussion in '2019.3 Beta' started by korimako, Sep 23, 2019.

  1. korimako

    korimako

    Joined:
    Aug 10, 2013
    Posts:
    40
    Description:
    A blender 2.8 .blend file created with several animations attached used to import into 2019.3 alpha versions (latest 08?) now the only animation listed on the model's animations after import is "scene"

    To Reproduce:
    Have Blender 2.8 installed (on Mac)
    Start a new unity 3d Android/IOS project with 2019.3.0b4
    Import a .blend file with animations

    Result:
    The animations are not visible under the animation tab of the model in the inspector.

    I have attached a .blend file with animations.

    Unity Bug Report Case 1186253
     

    Attached Files:

    Last edited: Sep 23, 2019
    akuno, ilmario, Bip901 and 1 other person like this.
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,622
    Please submit a bug-report as described in this document:
    https://unity3d.com/unity/qa/bug-reporting

    It's important that you report these issues together with a reproduction project if you want them to get fixed. If you don't do it, it might be a long time until someone else reports them or until Unity Technologies find them.

    After you submitted the bug-report, you receive a confirmation email with a bug-report Case number. Please post the Case number (number only, not the link) in this forum thread for Unity staff to pick up.
     
    MegamaDev, phobos2077 and korimako like this.
  3. korimako

    korimako

    Joined:
    Aug 10, 2013
    Posts:
    40
    Thanks Peter,

    here is the case number: Case 1186253

     
    Peter77 likes this.
  4. jotapeh_

    jotapeh_

    Joined:
    Nov 16, 2012
    Posts:
    45
    I submitted the same issue 4 days ago
    Case 1185489

    You can mark them as duplicate or merge them as you wish.
     
    korimako and Peter77 like this.
  5. jotapeh_

    jotapeh_

    Joined:
    Nov 16, 2012
    Posts:
    45
    EDIT: FUNCTIONING WORKAROUND BELOW

    Haven't had time to test this yet, but I'm betting the culprit is once again in the changes to Unity-BlenderToFBX.py

    A quick check shows that some import options are now added:
    Code (csharp):
    1.  
    2.         bake_anim_use_nla_strips=False,
    3.         bake_anim_use_all_actions=False,
    4.  
    Which um, look pretttttty guilty to me.

    edit: for a bit more context, see my tweet here: https://twitter.com/jotapeh/status/1176627959618330626

    Edit #2: As per the follow up to my tweet, this is definitely at least part of the issue, and you can get the source takes pulldown by modifying the file as shown
     
    Last edited: Sep 24, 2019
  6. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    651
    Ok I think I have a solution, I had the problem that for one .blend file no animations where imported at all (empty selection in the animation tab in the import settings) and for another .blend file just some animations where not imported.
    In blender you can just copy and paste animations as you like, from one file to another and so on.
    So I made a duplicate of the .blend and it seems that some animations where corrupted, but the data (rot, loc, scale) was ok.
    So I created a new animation and it was imported. Then I copied the action (like you usually create new actions in blender) and copy-pasted the data from the animation I wanted. I gave it a new name and did this for all animations.
    Now I have the data in non corrupted blender-actions and unity imports them.

    So again, step by step:
    1) Create a duplicate of your animated character .blend file
    2) Create a new empty animation and see if this gets imported in unity
    3) If so, open the new .blend file
    4) Create as many actions in your new file as animations you have (while keeping the old corrupted animations)
    5) Selct the old animation-action in the animation tab (Action editor) and press CRTL+C
    6) Select a new animation-action the animation tab (Action editor) and press CRTL+V
    7) Now all animations should be imported correctly, you may have to assign them in the inspector
    8) (optional) Cleanup: Delete old animations in your new file by clicking the X on the action while holding Shift, next time you open the file, those animations won't show up (as they have no "users" and won't get saved in the .blend file)

    I hope this helps someone, took me 3 days to figure out a solution..
     
    russellpbrowning likes this.
  7. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    This issue was closed as "Won't Fix" with the following explanation: "The issue is caused by the 'export all actions' setting set to false in the blender-to-FBX conversion script. This was done to fix the case 1117999 but causes an issue with this particular rig/animation setup. Reverting the change made earlier fixes the issue. We won't fix this because it's basically a matter of preference, this setting should be turned on or of depending on the imported file content. There's two easy workarounds :
    1) Export to FBX with the 'export all actions' setting turned on. Exporting to .FBX is recommended over direct .blend import in the documentation for this reason but also because of collaborative workflow issues.
    2) Go to the Unity installation folder and locate the Unity-BlenderToFBX.py file in Data/Tools/,
    replace line 43 by bake_anim_use_all_actions=True
    Blender file import actually just runs Blender in background and exports the file to FBX then imports it. The FBX exports settings can be changed in this file."
    https://issuetracker.unity3d.com/product/unity/issues/guid/1186253/
     
  8. jotapeh_

    jotapeh_

    Joined:
    Nov 16, 2012
    Posts:
    45
    I feel like breaking the existing workflow that's been around for years and then saying "Won't fix because it's a matter of preference" is unfair.

    Many of us set up our workflows to adjust to the quirks of Unity/Blender import, and this made it unnecessarily more difficult, for the convenience of a somewhat nebulous other workflow.

    Could you perhaps at least give us more insight into what exactly Issue 1117999 is? The information available is extremely thin: https://issuetracker.unity3d.com/issues/import-errors-when-converting-from-blend-to-fbx

    If this is the "preferred" Unity/Blender setup, can you document it? We would at least like to know how to avoid being caught by this snag in the future.
     
    Last edited: Oct 3, 2019
    Sirius64, akuno, CoughE and 5 others like this.
  9. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    I shudder at any Unity project that has .blend files in. FBX round-tripping is quite common and we adjusted our Blender workflow to improve the iteration time over FBX exports which was far easier than changing the way Unity does it (thank goodness for Python scripting). Sorry if I can't say much that is useful here but I would recommend finding a way to work through FBX exports over having your .blend files in the project, for future compatibility at least.
     
    MadeFromPolygons and Peter77 like this.
  10. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
    Yeah I am not sure of any studio that would use blend files, we also FBX roundtrip and its in general far better when you have other DCC apps in your chain. This way we can have unity open with the asset in view, our modelling DCC app (maya and blender for us), our painting DCC apps (substance) and preview the changes in unity the moment we export and overwrite the previous file. We also leverage python scripting to make the process a one or two button operation.

    I certainly wouldnt be trying to use a .blend file in a beta version of unity, I cant imagine how that would do anything but cause issues.
     
  11. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    I would actually love it if I could prevent Unity from trying to import .blend files. It's often hard to match the .blend work file with the .fbx asset file - if they could be next to each other, and Unity just didn't do any importing for the .blend, we'd have a much easier workflow.

    We have made a game with .blend files because it seemed easier, but I shudder to think how much time that cost us.
     
  12. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    You can probably do something with the asset pre-import (pre-processor) via an editor script to make it ignore the files?
     
  13. korimako

    korimako

    Joined:
    Aug 10, 2013
    Posts:
    40
    Given that I do have a mature project which has around 60 .blend files with animations. Can anyone suggest a way to convert those original files to FBX. When I bring in an FBX file to replace the .blend file - is there an efficient way to point the animation states, the avatar a masks etc to the new assets animations? When I realized that FBX files were the way to go (around a year ago) I tried to update my assets but was embroiled in a dependency and reference disaster. When I started the project the advice to use FBX was not as clear - or at least I didn't heed it :( It was four years ago. Now I have an app in the store with a file using .blend files. I would like to switch my files to FBX - but I don't see an easy path.
     
  14. korimako

    korimako

    Joined:
    Aug 10, 2013
    Posts:
    40
    Thanks LeonhardP,

    I appreciate the explanations.

    Two thoughts here:
    1) Bummer. Now I have to remember to change a flag in a file for each new Unity install. Can this flag be exposed in the import screen in the editor - much like the import blend shapes etc?

    2) What is the OTHER method of attaching animations? I have a list of actions in a dope sheet. Can I convert my blend files to use another way so they will import without having to change the import script?
     
    zackblack likes this.
  15. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    You'll need two tools, and one technique:
    Tool 1: utility to find what files depend on your blend files - or assets in general. You need this to figure out which animator controllers use your .blend file's animation clips, and which prefabs and scenes use your .blend file's meshes, avatar, etc.
    If you know exactly where a specific blend file is used, you don't need this.
    We use git for version control, and git grep to search through files that reference the asset's guid;
    git grep 'guid' -- *.prefab *.unity *.controller

    you can do this with just normal grep, or any tool that can search all the files in your project for text. Look for the asset's guid in the meta file.
    There's free and paid assets out there that solve this problem

    Tool 2: Utiltiy to mass-replace clips in an animator controller asset.
    You'll have to write this, as it depends on your game. We created one a while back for handling version changes. Essentially, it's an editor window where you slot in the .blend file, the .fbx file, and the animator controller. Have a button that loops though all the states in the controller, find the clips, and if they're from the .blend file, replace them with a similarly named file in the .fbx file.

    Technique: Don't actually do this to all your files at once, because it'll explode and you'll give up. Instead, whenever you're working with a specific model, do the replacement for that model. Let the other ones stay as .blend files.

    This of course assumes that you don't have to upgrade for a while, so you can postpone dealing with this issue.
     
    korimako and LeonhardP like this.
  16. korimako

    korimako

    Joined:
    Aug 10, 2013
    Posts:
    40
    Thanks!

    This sounds like a worthy task. You don't happen to have an example of a similar sort of editor tool that I can use a starting point do you? I haven't written one of those before! If not NP - this is a really great pointer - thanks again.
     
  17. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    I don't have an example at hand right now, but there's some in the docs.
    The entry point is to create an EditorWindow.
    You'll mostly use the EditorGUILayout and GUILayout API's to draw it.
    You edit AnimatorControllers through it's API, note that every single getter in that API returns a copy, so you have to set everything back.
    To get clips from an fbx file, you'll need to get the file's ModelImporter through AssetImporter.GetAtPath. Note that it has two arrays of clips - clipAnimations and defaultClipAnimations. If you haven't edited any of the imported animations, the first is empty.

    Feel free to ask if you have any questions!
     
    korimako likes this.
  18. jotapeh_

    jotapeh_

    Joined:
    Nov 16, 2012
    Posts:
    45
    To everyone here to say how bad it is to use .blend with Unity:

    Blender / Unity integration actually got to quite a workable point. It works particularly well with Blender 2.8 and Unity 2018/2019.x, until this 2019.3 version. There are some quirks, but it really isn't something worth "shuddering" over. That's quite the overreaction, and I suspect borne of a lack of experience using it in recent years.

    The "why use .blend in a beta?" comment.. why use anything in a beta? To test for compatibility issues moving forward, and good that we did, we found a big one.

    Our project had 100+ .blend files importing without issue prior to 2019.3. My main contention is that there doesn't seem to be any notable reason for the change. If we could at least get that, I'd be able to work to that rule in the future.

    Most of the suggestions here are to workaround by using a custom FBX export chain; sure. That's a valid option. However, if your workflow never took advantage of the .blend auto-import, and you're not impacted by this change, you're really not going to understand why this is so frustrating.
     
    Sirius64, Waz, ilmario and 1 other person like this.
  19. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,622
    MadeFromPolygons likes this.
  20. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    We've used it up to recently. We made the move about 6 months ago.

    There are two major hurdles with .blend files
    - It requires installing Blender, and setting the correct user settings, on all computers involved in the project. That scales very poorly, especially when you have external people come on the project.
    - Unity's model importer is a pile of garbage, and has always been. Any change to any property requires a complete reimport of the model. For .blend files, this also involves running Blender's fbx exporter. We had some pretty heavy animation files that took minutes for each time you hit apply. This got better when Blender removed the deprecated fbx ascii format that Unity were telling it to use internally, but it's still a major cost.

    So for everyone else than the people using Blender, having the blend files directly in the project is a major inconvenience.
     
    Peter77 likes this.
  21. jotapeh_

    jotapeh_

    Joined:
    Nov 16, 2012
    Posts:
    45
    If you read above Leonhard's post, I'm the one who first determined the change to that particular python script was the root issue, and found the workaround to begin with.

    What is lacking is an actual explanation - beyond the extremely thinly documented Issue 1117999. What problem does setting this flag actually solve? Why are you breaking the existing import functionality? There's no information on that.

    There's a case to be made about that, but again, if your workflow never utilized .blend auto-import, then you would not care about this flag either way.

    .blend auto-import still exists, and still works (mostly) for those of us who use it. I am simply wondering why it has been "tweaked" in this manner, which breaks a fairly standard Blender/Unity workflow in favour of some other type of Blender/Unity workflow.
     
    n0xid, zackblack and korimako like this.
  22. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,622
    I didn't notice, sorry. I thought it would help.
     
    jotapeh_ likes this.
  23. jotapeh_

    jotapeh_

    Joined:
    Nov 16, 2012
    Posts:
    45
    I definitely appreciate that, and no there's ill intent in my reply either.. It's difficult to track who is who and I'm not making it easier with a lack of avatar/signature.

    I'd just love actual information about the change which started this thread, not so much the available workarounds or alternative workflows etc
     
    korimako and Peter77 like this.
  24. korimako

    korimako

    Joined:
    Aug 10, 2013
    Posts:
    40
    OK, since you offered! I am having some trouble. I am cycling through an animator and finding the clips (UnityEditor.Motion classes), then cycling through an FBX file and finding the corresponding animations (UnityEditor.
    ModelImporterClipAnimation). But they are obviously different types, so I can't assign the FBX animation reference to the Animator motion.

    Any thoughts on what I am missing here? Can I access UnityEditor.Motion instances in the FBX file? Is there a way to convert to them? In the UI it is just drag and drop!

    Thank you!



    Here is where I am at with the code:

    This was my obviously wrong attempt from below:
    cas.state.motion = fbxClip as object as Motion;


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEditor;
    5. using UnityEditor.Animations;
    6. using System.IO;
    7. using System.Text.RegularExpressions;
    8.  
    9. public class UseFbxNotBlendFile : EditorWindow
    10. {
    11.  
    12.     // INSPIRED BY: https://forum.unity.com/threads/blender-2-8-animations-not-importing-in-beta-2019-3-0b4.749198/#post-5030687
    13.     // AND https://forum.unity.com/threads/blender-2-8-animations-not-importing-in-beta-2019-3-0b4.749198/#post-5033090
    14.  
    15.  
    16.     int currentPickerWindow = -1;
    17.  
    18.     int windowPickerType = -1;
    19.     const int blendWindow = 1;
    20.     const int fbxWindow = 2;
    21.     const int animatorWindow = 3;
    22.     const int prefabWindow = 4;
    23.  
    24.     object blendObject = null;
    25.     object fbxObject = null;
    26.     object animatorObject = null;
    27.     object prefabObject = null;
    28.  
    29.     string notSetString = "Not set";
    30.  
    31.  
    32.     string searchString = "";
    33.  
    34.     [MenuItem ("Window/UseFbxNotBlendFile")]
    35.     static void Init()
    36.     {
    37.         EditorWindow.GetWindow (typeof(UseFbxNotBlendFile)).Show ();
    38.     }
    39.  
    40.  
    41.     private void ShowPicker(int type)
    42.     {
    43.         //create a window picker control ID
    44.         currentPickerWindow = EditorGUIUtility.GetControlID(FocusType.Passive) + 100;
    45.         windowPickerType = type;
    46.  
    47.         if (windowPickerType == animatorWindow)
    48.         {
    49.             //use the ID you just created
    50.             EditorGUIUtility.ShowObjectPicker<AnimatorController>(null, false, searchString, currentPickerWindow);
    51.  
    52.         }
    53.         else {
    54.             //use the ID you just created
    55.             EditorGUIUtility.ShowObjectPicker<GameObject>(null, false, searchString, currentPickerWindow);
    56.         }
    57.     }
    58.  
    59.  
    60.     // Useful: https://answers.unity.com/questions/554012/how-do-i-use-editorguiutilityshowobjectpicker-c.html
    61.  
    62.  
    63.     [System.Obsolete]
    64.     private void OnGUI()
    65.     {
    66.  
    67.         searchString = EditorGUILayout.TextField("Search filter: ", searchString);
    68.  
    69.  
    70.         EditorGUILayout.Space();
    71.  
    72.         EditorGUILayout.TextField("Blend object: ", blendObject is GameObject? (blendObject as GameObject).name : notSetString);
    73.         if (GUILayout.Button ("Choose Blend"))
    74.         {
    75.             ChooseBlend ();
    76.         }
    77.  
    78.         EditorGUILayout.Space();
    79.  
    80.         EditorGUILayout.TextField("FBX object: ", fbxObject is GameObject ? (fbxObject as GameObject).name : notSetString);
    81.         if (GUILayout.Button("Choose FBX"))
    82.         {
    83.             ChooseFBX();
    84.         }
    85.  
    86.         //EditorGUILayout.TextField("Animator object: ", animatorObject is AnimatorController ? (animatorObject as AnimatorController).name : notSetString);
    87.         //animatorObject = EditorGUILayout.ObjectField()
    88.         //if (selectedObject != null)
    89.         //{
    90.         //    string assetPath = AssetDatabase.GetAssetPath(selectedObject);
    91.         //}
    92.  
    93.  
    94.  
    95.         EditorGUILayout.Space();
    96.  
    97.         EditorGUILayout.TextField("Animator object: ", animatorObject is AnimatorController ? (animatorObject as AnimatorController).name : notSetString);
    98.         if (GUILayout.Button("Choose Animator"))
    99.         {
    100.             ChooseAnimator();
    101.         }
    102.  
    103.         EditorGUILayout.Space();
    104.  
    105.         EditorGUILayout.TextField("Prefab object: ", prefabObject is GameObject ? (prefabObject as GameObject).name : notSetString);
    106.         if (GUILayout.Button("Choose Prefab"))
    107.         {
    108.             ChoosePrefab();
    109.         }
    110.  
    111.         EditorGUILayout.Space();
    112.  
    113.  
    114.  
    115.         if (blendObject is GameObject && fbxObject is GameObject && animatorObject is AnimatorController && prefabObject is GameObject)
    116.         {
    117.             EditorGUILayout.LabelField("All set!");
    118.             if (GUILayout.Button("Transfer Animations"))
    119.             {
    120.                 TransferAnimations();
    121.             }
    122.  
    123.  
    124.         }
    125.  
    126.         if (Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == currentPickerWindow)
    127.         {
    128.  
    129.             switch (windowPickerType)
    130.             {
    131.                 case blendWindow:
    132.                     blendObject = EditorGUIUtility.GetObjectPickerObject();
    133.                     break;
    134.                 case fbxWindow:
    135.                     fbxObject = EditorGUIUtility.GetObjectPickerObject();
    136.                     break;
    137.                 case animatorWindow:
    138.                     animatorObject = EditorGUIUtility.GetObjectPickerObject();
    139.                     break;
    140.                 case prefabWindow:
    141.                     prefabObject = EditorGUIUtility.GetObjectPickerObject();
    142.                     break;
    143.             }
    144.             currentPickerWindow = -1;
    145.         }
    146.  
    147.         if (Event.current.commandName == "ObjectSelectorClosed")
    148.         {
    149.             currentPickerWindow = -1;
    150.         }
    151.  
    152.  
    153.     }
    154.  
    155.  
    156.     private void ChooseBlend()
    157.     {
    158.         ShowPicker(blendWindow);
    159.     }
    160.  
    161.     private void ChooseFBX()
    162.     {
    163.         ShowPicker(fbxWindow);
    164.     }
    165.  
    166.     private void ChooseAnimator()
    167.     {
    168.         ShowPicker(animatorWindow);
    169.     }
    170.  
    171.     private void ChoosePrefab()
    172.     {
    173.         ShowPicker(prefabWindow);
    174.     }
    175.  
    176.  
    177.     private void TransferAnimations()
    178.     {
    179.         Debug.Log("Transfer Animations");
    180.  
    181.         // THE FBX ANIMATIONS
    182.         string path = AssetDatabase.GetAssetPath(fbxObject as UnityEngine.Object);
    183.         ModelImporter modelImporter = (ModelImporter)AssetImporter.GetAtPath(path);
    184.  
    185.         // THE ANIMATION CONTROLLER
    186.         AnimatorController animCont = animatorObject as AnimatorController;
    187.         foreach (AnimatorControllerLayer acl in animCont.layers)
    188.         {
    189.  
    190.             // Debug.Log("layer name: " + acl.name);
    191.             string motionName = "";
    192.             foreach (ChildAnimatorState cas in acl.stateMachine.states)
    193.             {
    194.  
    195.                 bool motionMatchFound = false;
    196.  
    197.                 if (cas.state.motion == null)
    198.                 {
    199.                     Debug.Log("No Motion");
    200.                     break;
    201.                 }
    202.  
    203.                 motionName = cas.state.motion.name;
    204.                 // Debug.Log("state: " + cas.state.name);
    205.                 // Debug.Log("motion: " + cas.state.motion.name);
    206.  
    207.                 Regex motionRegExp = new Regex(".*" + motionName + "$");
    208.  
    209.  
    210.  
    211.                 foreach (ModelImporterClipAnimation fbxClip in modelImporter.defaultClipAnimations)
    212.                 {
    213.  
    214.  
    215.                     Debug.Log(fbxClip.name);
    216.                     if (motionRegExp.IsMatch(fbxClip.name)){
    217.                         Debug.Log("Replace: " + acl.name + " " + cas.state.name + " " + motionName + " with " + fbxClip.name);
    218.                         cas.state.motion = fbxClip as object as Motion;
    219.  
    220.                         Debug.Log("Replaced: " + cas.state.motion.name);
    221.  
    222.                         motionMatchFound = true;
    223.                         break;
    224.                     }
    225.                  
    226.                 }
    227.  
    228.                 if (!motionMatchFound)
    229.                 {
    230.                     Debug.Log("<color='red'>Match not found for: " + acl.name + " " + cas.state.name + " " + motionName + "</color>");
    231.                 }
    232.  
    233.             }
    234.         }
    235.  
    236.  
    237.  
    238.     }
    239.  
    240. }
     
  25. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Yeah, turns out I didn't remember! quite how I did this!

    I got clips from a model simply by loading all the AnimationClips at the fbx' path:

    Code (csharp):
    1.  
    2. private List<AnimationClip> GetAnimationClipsFrommodel(Object fbxModel) {
    3.     return AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(fbxModel))
    4.                         .OfType<AnimationClip>()
    5.                          // The preview clips are generated by Unity to use in previewing the clips in the mode importer
    6.                         .Where(clip => !clip.name.StartsWith("__preview__"))
    7.                         .ToList();
    8. }
    For replacing motions in an AnimatorController, you just have to know that AnimationClip inherits from motion, so you can just set a state's motion to a clip.
     
  26. adamgryu

    adamgryu

    Joined:
    Mar 1, 2014
    Posts:
    188
    I just spent the past while searching the internet to see why my blender files were only importing the default take. For some reason, this thread doesn't show up in any of my searches! I'm going to repeat my account of the problem, if only for adding searchable keywords to this thread:

    After updating to Blender 2.8 and Unity 2019.2, my blend files only imported one animation and called it "source". It was missing all the other animations other than the default take.

    I wasn't sure if blender was configured wrong (I'm new to blender animating and still find exporting Actions a little confusing) but after tons of searching I found I could work around the problem by changing the FBX config file C:\Program Files\Unity\Hub\Editor\2019.2.13f1\Editor\Data\Tools\Unity-BlenderToFBX.py as mentioned above in this thread.

    Anyway, as jotapeh_ said earlier, I find it frustrating that there's no information on why this change was made or how I could adjust my blend files so the animations would export. If this bug won't be fixed because it's a matter a preference I would at least like to know what the other preference is.
     
    stst1616 and sd1515 like this.
  27. everystone

    everystone

    Joined:
    Jan 30, 2014
    Posts:
    7
    I just ran into this issue as well, and
    Code (CSharp):
    1.  bake_anim_use_all_actions=True
    in Unity-BlenderToFBX.py did the trick, thanks!
     
  28. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Is it possible to import different collections to different prefabs in Unity?

    For example, one collection goes to prefab 1., second collection goes to prefab 2., ...
     
  29. zackblack

    zackblack

    Joined:
    May 17, 2015
    Posts:
    76
    It's rather absurd that a breaking change is buried in a text file for each Unity installation. Why isn't this just a simple checkbox for the Blender asset?
     
    andyman404 likes this.
  30. z_orochii

    z_orochii

    Joined:
    Mar 8, 2013
    Posts:
    20
    Hi. Sorry for bringing this thread back again but I tried both converting files to FBX and turning on the flag in the .PY file and none worked. From what I see they're homologous now, dunno if it has something to do with the FBX version my Blender is using (which sadly got removed at 2.8, it had the option to pick before IIRC).

    They actually had the same outcome, which is (from what I can gather) the inability of Unity for reading FBX files with more than one action/animation. Or so claims "some guy on the internet".

    Can someone please explain what other options are there? Do I have to make every animation in a single one or something? Or maybe make several files and each have a single animation with a copy of the mesh or armature?

    Thanks!

    EDIT: For more information, this guy has the same problem. I got pretty much the same error stack.
    https://answers.unity.com/questions/1698208/unity-suddenly-unable-to-import-fbx-from-blender-c.html
     
  31. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    This is a known bug and should be fixed in 2019.3.4f1. https://issuetracker.unity3d.com/product/unity/issues/guid/1215431/
     
    z_orochii likes this.
  32. zackblack

    zackblack

    Joined:
    May 17, 2015
    Posts:
    76
    To my knowledge, that's a different issue. I was unable to use any version of 2019.3 until 4f1 because of the null ref errors when trying to inspect the animation. What this thread is about is that Unity will not import all animations unless you go into the installation for EACH version of Unity that you have installed and change the "bake_anim_use_all_actions=True" line. Again, every time you download a new version of Unity you have to manually change this - it's totally absurd that this isn't just a project/asset preference setting.
     
    Last edited: Mar 8, 2020
    Bip901 likes this.
  33. z_orochii

    z_orochii

    Joined:
    Mar 8, 2013
    Posts:
    20
    It's also important to note that, at least on my end, marking the "bake_anim_use_all_actions" flag at the importing script doesn't work anymore, and pretty much does the same as manually exporting the BLEND file to FBX. I'm using 2019.3.2f1, I can update, however I'd like to know if 4f1 really does fix the issue. I can wait if not, or work around it.
     
  34. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    607
    The 4f1 update still doesn't allow me to update my FBX files with new animations. I've spent several days looking for workarounds, but the problem even exists in 2018.4 LTS. Maddening.
     
  35. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    We're able to get new animations in fbx files on 2018.4 all the time. They're not automatically added to the list of clips, so you have to go into the animation importer and manually add them, but they're there.
     
  36. z_orochii

    z_orochii

    Joined:
    Mar 8, 2013
    Posts:
    20
    Interestingly enough, the FBX issue exists in 2019.3 only, as I was able to work with .blend files, with multiple animations (actions) with no problems. But in 2019.3 even the selector for actions disappeared, which makes me think it's either a removed feature, or they're working on a new way to manage multiple animations on files.
     
  37. Bip901

    Bip901

    Joined:
    May 18, 2017
    Posts:
    71
    I'm having the exact same problem with Unity 2019.3.3f1 (URP)
     
  38. dock

    dock

    Joined:
    Jan 2, 2008
    Posts:
    607
    I just switched back to 2018.4 LTS because of this bug, and even the latest release has the bug where fbx files won’t acknowledge any changes until you destroy the .meta file. I had to switch to 2018.4.1f1 LTS to avoid this error.

    Is this only effecting some people? How can the animation pipeline be so broken, even in LTS releases?
     
  39. Bip901

    Bip901

    Joined:
    May 18, 2017
    Posts:
    71
    I tried all workarounds mentioned here in 2019.3.3f1 and none of them worked. What I ended up doing was updating to 4f1,which fixed the console errors when importing the model, but still imported only a single "Scene" animation.

    I then exported to FBX manually from blender. I selected the mesh and the armature objects in object mode and exported with these settings:
    upload_2020-3-10_11-35-51.png upload_2020-3-10_11-36-7.png

    That did the trick.
     
    z_orochii and konsic like this.
  40. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    The team is aware of this and they are looking into a solution. They're targeting 2020.2.
     
    Last edited: Mar 10, 2020
    Waz likes this.
  41. zackblack

    zackblack

    Joined:
    May 17, 2015
    Posts:
    76
    This is common behavior across all versions of Unity. The .fbx is imported so you just have to
    Uhm... so what's the actual solution proposed in the meantime (besides painstakingly modifying the .py file after every Unity update - or worse, for projects with dozens of models/animation clips, re-exporting them all as .fbx and rebuilding all of our scenes)? Is it just expected behavior that a .blend file is only going to give one animation action?
     
  42. z_orochii

    z_orochii

    Joined:
    Mar 8, 2013
    Posts:
    20
    @Bip901 I'll try that on 4f1 then later. I did try that same configuration with 2f(something) but it threw me some nasty errors.

    I'll try more stuff too, because now I'm wondering if the bake_whatever flag does any difference, or not. I mean in solving the issue.

    Godspeed guys.
     
  43. Huxii

    Huxii

    Joined:
    Sep 15, 2018
    Posts:
    37
    Hi, Im having the same issue in 2019.3.5f1, none of the workarounds are working for me :(. Instead of the animations just "Scene" is imported.

    The pity is: When I export my model as .fbx, I see the animations in the project. Unfortunately I see no way to copy-paste /link them to the .blend model.

    Does anybody know if this is possible?

    Thank you
    Huxi
     
  44. Waz

    Waz

    Joined:
    May 1, 2010
    Posts:
    287
    From what I can tell, the base cause is something in Blender - it doesn't export all the Actions, even with that option selected.

    This is tested with Blender 2.83.0 LTS, not a beta, and (sorry @Baste) happens whether exported via FBX or just relying on Unity's import (with or without the change described above).

    Sometimes it works, but once it breaks, the break seems permanent. I've yet to produce a small reproducible example .blend file.
     
  45. trevorvonryan2

    trevorvonryan2

    Joined:
    Jan 28, 2014
    Posts:
    2
    Yo. I tried everything noted above. Here's what ended up working:

    Delete the two lines in the py file as noted above.
    Have your armature selected (I had it in pose mode, no idea if that is necessary).
    In the action editor, select each action you want imported, and then push it down to the NLA editor.

    Every action I pushed to the NLA now imports correctly, didn't even have to touch the import settings in Unity.
    Also, I'm just using blend files, not exporting to FBX.

    Cheers :)
     
    rboerdijk and DR_COUTINHO_MAP like this.
  46. fuser

    fuser

    Joined:
    Nov 23, 2013
    Posts:
    10
    Thanks for the fix. I've automated it for myself so I can quickly recreate my workspace - I can now right click in my project window and select "Fix Blender animations importer" and it'll try to do what you have recommended here.

    upload_2020-8-4_1-58-3.png

    Here's the script if you want to download it yourself. Note that it uses UnityEditor, so you'll need to put it in a folder named "Editor" (or in an editor assembly if you use assemblies)

    Code (CSharp):
    1. using System;
    2. using System.IO;
    3. using System.Text.RegularExpressions;
    4. using UnityEditor;
    5. using UnityEngine;
    6. using UnityEngine.Assertions;
    7.  
    8. public class BlenderAnimationImporterFix
    9. {
    10.     public const string MenuName = "Fix Blender animations importer";
    11.     public const string MenuPath = "Assets/" + MenuName;
    12.  
    13.     private const string importerScriptName = "Unity-BlenderToFBX.py";
    14.     private static readonly string relativePathFromAppToImporterScript = Path.Combine("Data", "Tools", importerScriptName);
    15.  
    16.     private static readonly Regex bakeAllAnimsFalseFinder = new Regex(@"(.*\b)bake_anim_use_all_actions=False(\b.*)");
    17.     private const string bakeAllAnimsTrueReplacement = "$1bake_anim_use_all_actions=True$2";
    18.  
    19.     [MenuItem(MenuPath)]
    20.     static void FixBlenderAnimationImporter()
    21.     {
    22.         var pathToApp = EditorApplication.applicationPath;
    23.         var pathToAppDirectory = Path.GetDirectoryName(pathToApp);
    24.         var pathToImporterScript = Path.Combine(pathToAppDirectory, relativePathFromAppToImporterScript);
    25.  
    26.         if (!File.Exists(pathToImporterScript))
    27.         {
    28.             EditorUtility.DisplayDialog("Could not find importer script", String.Join("Could not find the importer script, so the script cannot be fixed. We are looking for the file \"{0}\". If you find this file and it's still relevant please fix the reference in class {1}.", importerScriptName, nameof(BlenderAnimationImporterFix)), "OK");
    29.             return;
    30.         }
    31.  
    32.         var foundFalseBakeAllAnims = false;
    33.  
    34.         var tempFilePath = Path.GetTempFileName();
    35.         using (StreamWriter output = File.CreateText(tempFilePath))
    36.         {
    37.             using (StreamReader original = File.OpenText(pathToImporterScript))
    38.             {
    39.                 string singleLine;
    40.                 while ((singleLine = original.ReadLine()) != null)
    41.                 {
    42.                     var matches = bakeAllAnimsFalseFinder.Matches(singleLine);
    43.                     if (matches.Count > 0)
    44.                     {
    45.                         Assert.AreEqual(matches.Count, 1, "The regex expression should be greedy, so there should only be a maximum of one match per line");
    46.                         output.WriteLine(matches[0].Result(bakeAllAnimsTrueReplacement));
    47.                         foundFalseBakeAllAnims = true;
    48.                     }
    49.                     else
    50.                     {
    51.                         output.WriteLine(singleLine);
    52.                     }
    53.                 }
    54.             }
    55.         }
    56.  
    57.         if (!foundFalseBakeAllAnims)
    58.         {
    59.             EditorUtility.DisplayDialog("Could not find the line to fix", String.Format("We successfully found the script that needed to be fixed, but there was no line matching the \"{0}\" regex. This run of this script has not fixed the importer - it's possible that the importer has already been fixed.", bakeAllAnimsFalseFinder.ToString()), "OK");
    60.             File.Delete(tempFilePath);
    61.             return;
    62.         }
    63.  
    64.         File.Delete(pathToImporterScript);
    65.         File.Move(tempFilePath, pathToImporterScript);
    66.     }
    67. }
    68.  
     
    trevorvonryan2 and LeonhardP like this.
  47. Waz

    Waz

    Joined:
    May 1, 2010
    Posts:
    287
    2020.2f2 still makes a total mess of skinned meshes in Blender 2.92 .blend files that it can import just fine with Blender 2.79. The files themselves work just fine in both Blender 2.79 and Blender 2.92.

    So is The Team still working on a solution, or is it supposed to be all fixed in 2020.2?

    Happy to report a bug with an example if I'm seeing a new bug.
     
  48. CharlesFSG

    CharlesFSG

    Joined:
    Jan 5, 2021
    Posts:
    5
    Firstly, there is no valid reason for this change. What benefit comes of it? It's straight up infuriating and more than a little shady. Suggesting that FBX is superior or that having to have blender installed on all machines is too much of an inconvenience is bogus. If anything, having to use fbx is EXTREMELY DISRUPTIVE to workflow. I'm actually kind of amazed this isn't getting more attention.

    Secondly, if you changed

    bake_anim_use_all_actions=False

    to

    bake_anim_use_all_actions=True

    and you still don't see your animations, don't panic. Close and reopen Unity (and restart your computer if you're superstitious) and then check to see if the animation clips are there in the import settings. This worked with Blender 2.91 and Unity 2020.3.11f1 LTS
     
  49. CharlesFSG

    CharlesFSG

    Joined:
    Jan 5, 2021
    Posts:
    5
    I'm sorry but how is this acceptable? Have you looked at

    https://issuetracker.unity3d.com/product/unity/issues/guid/1117999/

    ???

    There's nothing there! Even all the comments are just a bunch of shady links or something about Belgium. What's going on here??? I have not heard a good reason as to why

    bake_anim_use_nla_strips=False
    bake_anim_use_all_actions=False

    were added to Unity-BlenderToFBX.py.
     
    akuno likes this.