Search Unity

Question Multiple glb importers. How do I fix this?

Discussion in 'Asset Importing & Exporting' started by CWatsonT2, Nov 22, 2022.

  1. CWatsonT2

    CWatsonT2

    Joined:
    Jan 9, 2019
    Posts:
    114
    I have two packages that each have their own glb and gltf importers (MRTK3 and Ready Player Me). This give me two errors like the one below. How do I fix this? I seem to need both importers. If I remove one, the package that uses that importer doesn't load the assets it needs properly and ultimately doesn't work.


    Multiple scripted importers are targeting the extension 'glb' and have all been rejected: Siccity.GLTFUtility.GLBImporter (assembly: C:\Users\Chris\Documents\Unity Projects\MRTK3SetupTest\MRTK3TestSetup\MRTK3TestSetup\MRTKDevTemplate\Library\ScriptAssemblies\Siccity.GLTFUtility.Editor.dll), GLTFast.Editor.GltfImporter (assembly: C:\Users\Chris\Documents\Unity Projects\MRTK3SetupTest\MRTK3TestSetup\MRTK3TestSetup\MRTKDevTemplate\Library\ScriptAssemblies\glTFastEditor.dll)
    UnityEditor.AssetImporters.ScriptedImporter:RegisterScriptedImporters ()
     
  2. bastien_humeau

    bastien_humeau

    Unity Technologies

    Joined:
    Jun 14, 2017
    Posts:
    191
    Hi there,
    I can't give a good answer here, apart from the fact that blocking import that way was probably a mistake on our side, I'm leaving a note in the team to look into it and try finding a way to make it work even if we have multiple "default".
    If you can edit one of these plugins' code in your project then you should be able to work around the issue easily.
    Choose one of the importer that you don't want to be the default for gltf import, and change the [ScriptedImporter] attribute to make it an optional importer.
    Code (CSharp):
    1. // Default importer
    2. [ScriptedImporter(1, new [] {"gltf", "glb"})]
    3. // Optional importer
    4. [ScriptedImporter(1, null, new [] {"gltf", "glb"})]
    From that point, selecting any gltf or glb asset in your project should show you a drop-down at the top of the inspector to let you change which importer you want to use on that asset.
     
    Ony and George-Ing like this.
  3. CWatsonT2

    CWatsonT2

    Joined:
    Jan 9, 2019
    Posts:
    114
    This is working. You are a lifesaver! Thank you sir.
     
  4. UnicornLoop

    UnicornLoop

    Joined:
    Apr 21, 2015
    Posts:
    11
    Hi Both,

    I seem to be facing the same issue with ReadyPlayerMe and the TriLib package (https://assetstore.unity.com/packages/tools/modeling/trilib-2-model-loading-package-157548) .

    This is the error:

    Multiple scripted importers are targeting the extension 'gltf' and have all been rejected: Siccity.GLTFUtility.GLTFImporter (assembly: D:\Users\Tony\Desktop\XRLab\ARSandbox\Library\ScriptAssemblies\Siccity.GLTFUtility.Editor.dll), TriLibCore.Editor.TriLibGLTFScriptedImporter (assembly: D:\Users\Tony\Desktop\XRLab\ARSandbox\Library\ScriptAssemblies\Assembly-CSharp-Editor.dll)

    Multiple scripted importers are targeting the extension 'glb' and have all been rejected: Siccity.GLTFUtility.GLBImporter (assembly: D:\Users\Tony\Desktop\XRLab\ARSandbox\Library\ScriptAssemblies\Siccity.GLTFUtility.Editor.dll), TriLibCore.Editor.TriLibGLTFScriptedImporter (assembly: D:\Users\Tony\Desktop\XRLab\ARSandbox\Library\ScriptAssemblies\Assembly-CSharp-Editor.dll)


    Just wondering if these a was a permanent fix that is not base on the user selecting on drop down. Couldn't I have each package using a different importer?
     
  5. CWatsonT2

    CWatsonT2

    Joined:
    Jan 9, 2019
    Posts:
    114
    I was able to solve this issue by making the ReadyPlayerMe importer optional as shown above. Then whenever I import a ReadyPlayerMe object I select the Siccity importer. I wasn't able to access the importer code for MRTK3 since it's built into a DLL. It got rid of the error and worked for me.
     
  6. febozzo

    febozzo

    Joined:
    Feb 26, 2018
    Posts:
    3
    Hi, but where is the script to modify as reported above?
     
    Smags and zdgra like this.
  7. MarvellousLunatic

    MarvellousLunatic

    Joined:
    May 1, 2020
    Posts:
    11
    Greetings,

    I'm facing a similar issue. I'm using a package for .webp handling. However, I don't want to use their default importer but use my own custom importer.
    Can I make my importer the default one?
    I could edit the one from the package, but as Unity guidelines for git are to ignore the Library it would fail for every other user that works with this project and I don't really like to have everyone do it manually on every setup.

    Edit:
    Changing the annoation of my custom importer to:

    Code (CSharp):
    1. [ScriptedImporter(1, "webp", -1)]
    resulted in the desired effect.
     
    Last edited: Feb 11, 2023
  8. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
    what's the solution if you can't edit ScriptedImporter?
     
    zdgra and rizviha like this.
  9. zdgra

    zdgra

    Joined:
    Feb 27, 2021
    Posts:
    9
    I was able to do this with Siccity/GLTFUtility and MRTK 2.

    I first had GLTFUtility in my project, without the MRTK.

    In the GitHub repository for GLTFUtility, I searched "ScriptedImporter" and found it in GLTFImporter.cs and GLBImporter.cs. From there, I went into both of those scripts in Unity. Here's what it looks like for GLTFImporter.cs.

    upload_2023-7-26_3-46-13.png

    You can see that I commented out everything but the line with
    null
    in the ScriptedImporter attribute. I did the same thing for GLBImporter.cs.

    After doing this, an issue with my GLTF model showed up. Still, I stayed the course. I deleted my model for now.

    I installed the MRTK 2 via the Mixed Reality Feature Tool, and then reimported my model. Finally, I clicked my model and there was the dropdown to select the importer.

    upload_2023-7-26_3-54-12.png

    I wanted to use GLTFUtility, and was able to select it. After that, my model was working fine again!
     
    erisgao likes this.