Search Unity

Unity can't import .blend files suddenly(?)

Discussion in 'Asset Importing & Exporting' started by r3dlazer, Oct 12, 2020.

  1. r3dlazer

    r3dlazer

    Joined:
    Aug 14, 2017
    Posts:
    6
    Hello,

    Whenever I try to import a .blend file, I get an error saying that I need to be using Blender 2.45-2.49 or 2.58 and Later. I'm using 2.9.

    I've reinstalled Blender and Unity. I'm not using the Steam version of Blender either - nothing worked with that.

    I uninstalled Blender 2.8. Image previews in Windows 10 are working.

    Screenshot is attached. I'm using Unity's HDRP Testing project at the moment. Please tell me that is not the problem.

    Thankyou.
     

    Attached Files:

  2. r3dlazer

    r3dlazer

    Joined:
    Aug 14, 2017
    Posts:
    6
    Any help or direction would be greatly appreciated.
     
  3. Tipperty

    Tipperty

    Joined:
    Sep 24, 2020
    Posts:
    8
    I have been exporting blender files with no problem over the last few days. However, you need to make sure the file is a .FBX file and not a .blend file or it won't work.

    here is a good youtube video on how to import and export files from unity to blender

     
  4. r3dlazer

    r3dlazer

    Joined:
    Aug 14, 2017
    Posts:
    6
    Thank you. It used to work with .blend files until recently, why the change?
     
  5. Tipperty

    Tipperty

    Joined:
    Sep 24, 2020
    Posts:
    8
    I have no idea, the only possible explanation is that unity or Blender decided to develop down different paths and so the complication popped up.
     
  6. r3dlazer

    r3dlazer

    Joined:
    Aug 14, 2017
    Posts:
    6
    But it was working like, a couple weeks ago?
     
  7. Tipperty

    Tipperty

    Joined:
    Sep 24, 2020
    Posts:
    8
    As far as I know, it has been a problem for a while. I don't know your circumstances if you have recently updated your blender or unity to a new version and have suddenly started having the issue. The video I linked should fix your issue, but if it persists, you could have a 2nd older version of both Blender and unity installed, swap assets over and save the asset, then move the asset to the new version and run a fix if there are any issues. I believe both programs are mainly friendly at running older saves, with unity being the more problematic, but even then, they can be fixed fairly easily.
     
  8. r3dlazer

    r3dlazer

    Joined:
    Aug 14, 2017
    Posts:
    6
    Ok. I understand. Thankyou, I'll give the video a try tomorrow and see what it says.
     
  9. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    its probably because you installed blender 2.9 but unity script is still using 2.8. You can probably manually fix it by finding a file like this

    "C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\Tools\Unity-BlenderToFBX.py"

    then editing the version number. Warning though, it wont work for any other people with unity installed.
     
    LagSik likes this.
  10. Woopy8

    Woopy8

    Joined:
    Apr 4, 2019
    Posts:
    6
    I just encountered this problem today and I can't figure out for the life of me why - I didn't update unity or blender.
    Yesterday I was saving .blend files and they were importing just fine. Did it today and suddenly it just won't accept it :s
     
    OwlBoy- likes this.
  11. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    if you double click a blend file does the correct blender open it? Windows may have broken the file association. Try reinstalling blender
     
  12. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
    After much faffing about uninstalling and reinstalling Blender and reassociating blender to open .blend files etc and still having issues in Unity I noticed there was some kind of caching issue at play because if I renamed some of my blend files that weren't importing then they did magically start to import, or also if I e.g. made a small change to the import settings, such as setting a 1.1 scale and applying, that would also kick unity into importing them.

    I resorted to nuking my projects Library/ folder and letting it reimport everything from scratch and hey presto my blend files started to import again. (Note this was _also_ after having uninstalled all versions of blender and then I only had 2.93LTS installed via the msi installer - I'm not sure what other install combos work at this point)
     
    bernuly and Epimolophant like this.
  13. Rib

    Rib

    Joined:
    Nov 7, 2013
    Posts:
    39
    In my case I hit this same issue again after I tried re-installing Blender 3.0
     
    Deleted User likes this.
  14. OwlBoy-

    OwlBoy-

    Joined:
    Dec 11, 2015
    Posts:
    24
    For some reason, I started having this after installing a Blender Plugin, and it stopped when I turned that plugin off.

    In my case, it was the plugin TexTools. And I'm on macOS with Unity 2019.4.31f1 and Blender 3.0. I tried playing with the python script. Nothing worked there.

    I found if I watched Activity monitor, a Blender process would appear on import. And if I watched the editor.log, I saw an import start when that process appeared. If I quit the blender process, Unity would stop hanging, and the .blend would turn into a blender icon instead of a model preview. If I changed the import settings, it would nudge it back into reimporting. I seem to be OK again, and I can nudge the import settings on any of the .blend files I had import issues with.

    I hope this helps someone with this. In my case, it just seems like Blender was getting hung up on an plugin. It's strange, though, it took a bit for the hangup to happen. So I'm actually not sure the plugin was the precise issue. Maybe just saving the Blender preferences helped? Unity just decided to stop messing around? I dunno.
     
    Last edited: Mar 19, 2022
    noxelfoxel and ModerateWinGuy like this.
  15. George-Ing

    George-Ing

    Unity Technologies

    Joined:
    Jan 14, 2020
    Posts:
    78
    Thanks for the addition OwlBoy_, that's good to know, we'll watch out for that when we're debugging in the future.

    For anyone else discovering this post in the future, the main things to check are that:
    • Exporting an FBX of your model from Blender works correctly.
    • Double-clicking on a Blender file directly opens Blender.
    • You're not on one of the very early versions of Blender 3.0 - there were some initial problems that were patched in the later versions.
     
  16. GuidewireGames

    GuidewireGames

    Joined:
    Apr 20, 2017
    Posts:
    27
    I just started noticing this error. I feel like it started happening with the latest 2021.2.17
    I recall issues like this back "in the day" but blender and unity has been fairly solid for some time.
     

    Attached Files:

  17. unity_Etienne

    unity_Etienne

    Unity Technologies

    Joined:
    Nov 28, 2019
    Posts:
    17
    Hi @GuidewireGames
    Did this start as you upgraded to 2021.2.17 specifically?
    What is the version of Blender do you have installed and how was it installed?
    I've seen this happen on Windows when the file association had gone wrong, but I'm not familiar with the process on Mac.
    Also, there was a problem with the very first few versions of Blender 3.0 that would have caused a similar result but a fix landed in 3.0.1

    Let us know if this keeps on happening,
    Thanks!
     
  18. GuidewireGames

    GuidewireGames

    Joined:
    Apr 20, 2017
    Posts:
    27
    I'm running 2021.2.17 on Mac and PC.
    Blender 3.1 on both.
    Mac gives me the blender opening error and Windows is fine.
    Blender does open initially without a model but will give the above error when trying to open again.
     
  19. GuidewireGames

    GuidewireGames

    Joined:
    Apr 20, 2017
    Posts:
    27
    Hopefully I'm not subverting this thread too much, but looks like my above problem was solved by upgrading Mac OS 12.3 to 12.3.1

    Looked like adobe apps were having a similar problem
    https://community.adobe.com/t5/phot...or-smart-object-in-illustrator/idc-p/12780732
     
  20. ModerateWinGuy

    ModerateWinGuy

    Joined:
    Nov 2, 2020
    Posts:
    6
    THANKYOU!!!!
    I was fighting this all evening and uninstalled and reinstalled unity and blender and couldnt figure this out, then saw this and realized I'd installed Textools recently too and that was what was causing the issue. ♥
     
  21. George-Ing

    George-Ing

    Unity Technologies

    Joined:
    Jan 14, 2020
    Posts:
    78
    Not at all! Thanks for the addition - I'm sure it will help any future users visiting this thread. Keep up the good work!

    & glad you've got it sorted, ModerateWinGuy!
     
  22. Quickie_Wolf

    Quickie_Wolf

    Joined:
    Dec 5, 2021
    Posts:
    2
    Hi,

    Was having the same problem. Here are my error messages. "Cannot decompress file." "Cannot convert to .fbx."
    The latter told me in description that because I was not using the latest version of Blender i.e. 2.53 etc.

    I found that I had two versions of Blender on my computer. 2.93 and 3.3.1. I removed Blender 2.93 from my computer and then Unity started to load the .blend file without problems.

    Yay!

    Thanks for all your help. You all stoked my brain!

    Best,

    QW.
     
  23. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    I'm having this issue suddenly, sometimes the blend files can be imported and sometimes out of the blue after mesh or UV changes they can't be converted.

    Working
    upload_2023-1-18_13-58-53.png

    After some UV unwrapping
    upload_2023-1-18_14-0-41.png

    I tried launching the script through the command line and setting the correct env vars and it works. So I'm out of clues. There is only one "blender.exe" in my path (2.93)

    env UNITY_BLENDER_EXPORTER_OUTPUT_FILE="helm.fbx" blender --background --python "D:\UnityEditors\2021.3.13f1\Editor\Data\Tools\Unity-BlenderToFBX.py" helm.blend


    export finished in 0.0000 sec.
    Finished blender to FBX conversion helm.fbx


    Is there a way to display the log of the blender Import script within unity to check what could be the issue ?
     
  24. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    unity is just loading blender in the background and using the blender fbx exporter, did you try exporting the fbx directly from blender to see the error in blender? Blender export settings are in "D:\UnityEditors\2021.3.13f1\Editor\Data\Tools\Unity-BlenderToFBX.py" if you want to try and get the same settings

    if its not obvious you could try going back to unity and reverting the file to see if the old version still works or making a new one with a default cube and checking that gets into unity ok
     
  25. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    Thanks, though not sure you read all the length of my question, I might not have been clear enough ? :
    I tried launching the script through the command line and setting the correct env vars and it works. So I'm out of clues. There is only one "blender.exe" in my path (2.93)


    And you're right it's not obvious, and quite an advanced issue. I'm actually tempering with the blender script itself in order to get more functionality. Here : https://github.com/builder-main/unity-blender-better-import

    I need to retrieve the Blender log while launched by Unity to see what's going on. As you saw the exact same script can export the file without issue from the command that Unity is probably launching itself.
     
    Last edited: Jan 19, 2023
  26. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    are you sure it worked, and the fbx opens fine if you copy it into the blender folder? I only ask because "export finished in 0.0000 sec." is the blender log(or at least part of it), and it seems like nothing got exported as a default cube takes 0.0156 seconds for me.
     
  27. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    I'm not sure indeed, if the FBX is empty though, is it a sufficient reason for unity to fail import it ?
     
  28. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    After checking, if the manually generated FBX is empty It can be imported in unity. Though it does not say if Unity fails with the automatic import because it specifically checks if the generated file is empty or not.

    (and I don't get why blender is sometimes not getting my objects, the API is pretty obscure to me, it says I Have 1 collection and 0 objects. was pretty sure bpy.data.objects would retrieve all the objects in the file.)
    Code (CSharp):
    1.     collections = bpy.data.collections
    2.     cLen = len(collections)
    3.     objs = bpy.data.objects
    4.     oLen = len(objs)
    5.     print("Will look for shared modifiers in "+str(oLen)+" objects and "+str(cLen)+" collections")

    )
     
  29. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    Its not really what you asked but imo you should ditch the ".blend files in unity pipeline" and export fbx from Blender but with an exporter tool such as https://github.com/TiliSleepStealer/blender-addon-fbx-bundle (although I use one I made). To make things simple you can keep the blend files in a folder called /Source~ and then set the export path to /..

    you then have lots of benefits such as in blender merging multiple objects into one or not exporting reference meshes, or having multiple fbx files export from a single blend file.
     
  30. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    bpy.data.objects has always worked for me, maybe the error is elsewhere?
     
    Whatever560 likes this.
  31. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    I hear you. I went back and forth throughout the years between what you said and using the blend files directly.

    My take is that it's a matter of where you want to put the effort fixing the issue. Blender-FBX export has its bag of issues, and I'm using blender like I use photoshop for very quick iterations and with crazy alt-tabing. Now if I can find something that works the way "Generate Images" works in photoshop, I'll probably consider it. (Meanning I'll just have to hit ctrl+s and then something watches the directory or a plugin autogenerates the FBX)

    Regardless, for animation and rigged characters I'm indeed using FBX. Basically it's like with photoshop, I use PSD, PSB with the 2D importer plugin and "Generates Image", if nothing works for my take I start crying and save as png/jpg/tga.
     
  32. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    Yes this line does something strange, it sequentially execute the script then try to open the blend file.

    env UNITY_BLENDER_EXPORTER_OUTPUT_FILE="helm.fbx" blender --background --python "D:\UnityEditors\2021.3.13f1\Editor\Data\Tools\Unity-BlenderToFBX.py" helm.blend


    Output with a dummy file :

    export finished in 0.0156 sec.
    Finished blender to FBX conversion helm.fbx
    Error: Cannot read file 'helm.blendDUMMY': No such file or directory



    Correct syntax is : (blend file after background before python), I'll come back with further testing.
    env UNITY_BLENDER_EXPORTER_OUTPUT_FILE="helm.fbx" blender --background helm.blend --python "D:\UnityEditors\2021.3.13f1\Editor\Data\Tools\Unity-BlenderToFBX.py"
     
    Last edited: Jan 19, 2023
  33. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    you could bind a new hotkey to two python commands, "save and export".
    I agree that quick iteration is great, but also its useful to save my blend files without exporting an model to blender. The other benefit is if you work in a team then the other users don't need blender installed, or upgrading to a newer version of blender breaks everything (is that why you are still on 2.93 :p) which annoyingly has happened to me several times!!

    I'm not sure if you want to try but my exporter is https://github.com/FrankieHobbins/GameExport, it exports FBX files based on collection names. If you put & in the name it will merge it on export and use any object inside with origin in the name as the origin. It's great for me and some friends but not particularly user friendly, the one I linked earlier is probably better in that respect)
     
  34. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    Hey thanks, it looks interesting, I'm really into these nice productive tricks so no bother for me, definitely a save+export binding along with a save only could do. I like to version my sources anyway so I'll have both the blend and the FBX in the repo.
    As related, I also used https://github.com/builder-main/blendToFbxExporterForUnity in the past for bulk replacing the blend files by fbx without loosing any integration. It was during build time but could be done on a regular project for easy migration.
     
  35. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    Message me on twitter if you want more info about how the exporter works. https://twitter.com/FrankieHobbins

    Re, source and blend file on the repo, did you clock onto my "/source~" tip. Unity ignores any folders with ~ at the end so you can put source files in there and it wont try and import them alongside the fbx.

    Thanks for the link to the blend to fbx converter!
     
    Whatever560 likes this.
  36. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    Mmh, at least, I might have my answer on why imports are sometimes not working.
    When saving the blend file in Edit mode it does not import, I have to switch back to object. So I guess i'll check that in my importer script.

    Edit : Second error was also a blender concept issue. Blender can keep Mesh Data in its files even though no object are referencing them in the scene. So you need to filter this out if you use them. Fixes were added to the repo I linked some posts above.

    @EiknarF I might try to use your naming conventions and get inspired by yours in my script as well in order to have a finer control on the blender exporting process (removing booleans, save mesh, etc ..)
     
    Last edited: Jan 24, 2023
    EiknarF likes this.
  37. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    @EiknarF
    I'm trying this approach right now renaming ".blend" to ".blender" and setting auto export on blender post save callback.
    https://hextantstudios.com/unity-avoid-automatic-import/
    It might be the closest I get to a good workflow. I'd like to consider my ".blender" and ".fbx" file as a single asset actually to avoid discrepancies. I still can keep ".blend" files around that do not auto-export as they are ignored by my current script.
     
    Last edited: Mar 22, 2023
  38. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    Interesting, can you tell me more about the "auto export on blender post save callback", I'm not sure I quite understand
     
  39. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    Yes, so this is the blender addon performing the export (basically just a wrapper on unity export script) : https://github.com/builder-main/blendToFbxExporterForUnity/blob/master/Unity-BlenderAutoFBXExport.py
    I went for a .uniblend extension, as I find it clearer. And everything seems to work so far. I'm trying with my automated build pipeline right at the moment.

    The update steps :
    1. Take care to not have any fbx file next your .blend files with the same name.
    2. Close Unity (to avoid any meta file tempering)
    3. I used given command to bulk rename my blend to .uniblend (need gitbash / cygwin)
    Code (CSharp):
    1. find . -name "*.blend" -exec sh -c 'mv "$1" "${1%.blend}.uniblend"' _ {} \;
    4. Set uniblend files to open with Blender
    5. Rename all blend.meta to fbx.meta
    Code (CSharp):
    1. find . -name "*.blend.meta" -exec sh -c 'mv "$1" "${1%.blend.meta}.fbx.meta"' _ {} \;
    6. Then this cmd will go through all the uniblend files and open them one by one. You just have to save, see if the FBX is correctly exported then close blender and the next uniblend files will open. This can be lengthy if you have a lot of blend files but its good to see if everything goes well
    Code (CSharp):
    1. find . -name "*.uniblend" -exec sh -c 'blender $1' _ {} \;
    7. Reopen Unity and then all should be working as it was as the fbx.meta have the former blend files import settings.

    Now I can double click my uniblend in unity and save whenever I want to update my fbx.

    Issue though : I'm using Blender 2.93 but it looks like 3.41 does not support other than the .blend extension on blend files.
     
  40. EiknarF

    EiknarF

    Joined:
    Apr 28, 2011
    Posts:
    142
    thanks for the explanation. I tested opening blend files with different extensions on my install of 3.4 and 3.5 alpha and they seemed to be fine, I've got them setup with blender launcher but I don't think it should make a difference.
     
  41. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    519
    Good to know, thanks, so I'm not stuck with 2.93. Btw after testing it builds nicely, so I'm pretty happy with the workflow.
     
  42. TheOtherUserName

    TheOtherUserName

    Joined:
    May 30, 2020
    Posts:
    136
    Just in case somebody in 2023 is here make ure that the .blend file has open with set to blender by default: right click => Properties => click on 'Change' at 'Open with' => bottom right click 'Apply'

    Should work with any blender version installed
     
  43. starkilla

    starkilla

    Joined:
    May 3, 2023
    Posts:
    1
    I ran into the problem when installing everything on a new computer and upgrading the unity version. Solution for me (after Blender was installed) was to delete the associated .meta files (if you have model.blend, then unity will create model.blend.meta) to let unity recreate them
     
  44. cubrman

    cubrman

    Joined:
    Jun 18, 2016
    Posts:
    412
    For anyone stuck: make sure the .blend file you use in Unity is saved with the blender version that is installed (not portative, but installed) on your PC. If the .blend file was saved with a LOWER version on some other machine and you downloaded it - it won't work.