Search Unity

TriLib - Model Loading Package

Discussion in 'Assets and Asset Store' started by rickomax, Jun 21, 2017.

  1. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    Hello,

    since using the latest version from asset store (2.0.11) when reading GLB from file I have multiple materials for one renderer and transparency / alpa is supported, too. That is very nice, in v1.87 that did not work.

    But I habe a strange problem: it works in editor, but in my build it does not. Do I need to incude some shader to the build or something like this?

    Thanks a lot!
     
  2. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    Hello,

    since the upgrad from TriLib 1.8.7 to 2.0.14 when reading a glb file each renderer can have multiple colors and alpha / transparency is supported, too, thants great!

    But it does only work in the editor...

    When I create Windows Standalone Build my GLB glass doors are fully white and opaque, in the editor they are transparent...

    I tried to add all TriLib shaders to my project settings, but does not seem to help.

    Any help please?
     
  3. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    Doublepost. Very strange I thought I lost the first one because it did not show...
     
  4. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    I solved the transparency problem by using the standard shader everywhere and set it's Mode (opaque, transparent) by script when needed.

    But I found another strange probem, I guess it is new after upgrading from TriLib 1.87 to 2.0.11:

    My loaded GLB files all appear mirrored! I am using this workaround now then it is okay:

    Code (CSharp):
    1.       /// <summary>
    2.         /// Done loading model, hide placeholder (bounding box) and progress and set collider
    3.         /// </summary>
    4.         private void OnModelLoad(AssetLoaderContext obj)
    5.         {
    6.             try
    7.             {
    8.                 GameObject loadedGameObject = obj.RootGameObject;
    9.                 loadedGameObject.transform.localScale = new Vector3(-1, 1, 1);
    Could it be a bug in the GLB loader?

    Thanks!
     
  5. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    You should provide the inner model file extension as an argument since TriLib can't guess the model file format from the URL. So if you're downloading an FBX file, you must pass "fbx" at the AssetDownloader "fileExtension" argument.
     
  6. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    It is possible!
    I found a few gltf files producing wrong rotation values but the next TriLib update has some matrix manipulation fixes which could fix your issues.
     
    LR-Developer likes this.
  7. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    TriLib will automatically include all needed shader variants in your output project. You could try adding a hidden object to your scene using the TriLib/Standard material to make sure Unity is including it in the build. Please tell me if it works, so we will know if Unity is adding the material to the output project.
     
  8. pekochun

    pekochun

    Joined:
    Nov 24, 2019
    Posts:
    5
    Hi!

    I want to load a .fbx file that is not a .zip file and a .png or .jpg texture separately.

    In that case, we should be able to do it using ExternalDataMapper and TextureMapper, but I don't know how to use these two.

    Below is the code I tried:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using TriLibCore;
    5. using TriLibCore.General;
    6.  
    7. public class SyncLoad : MonoBehaviour
    8. {
    9.  
    10.     private void OnError(IContextualizedError contextualizedError)
    11.     {
    12.         Debug.Log("OnError");  
    13.     }
    14.  
    15.     private void OnProgress(AssetLoaderContext assetLoaderContext, float progress)
    16.     {
    17.         Debug.Log("OnProgress");  
    18.  
    19.     }
    20.  
    21.     private void OnMaterialsLoad(AssetLoaderContext assetLoaderContext)
    22.     {
    23.         Debug.Log("OnMaterialsLoad");  
    24.     }
    25.  
    26.     private void OnLoad(AssetLoaderContext assetLoaderContext)
    27.     {
    28.         Debug.Log("OnLoad");  
    29.     }
    30.  
    31.     void Start()
    32.     {
    33.         var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
    34.         assetLoaderOptions.ExternalDataMapper = ScriptableObject.CreateInstance<ExternalDataMapperSample>();
    35.         assetLoaderOptions.TextureMapper = ScriptableObject.CreateInstance<TextureMapperSample>();
    36.         var modelPath = "/Users/mac/Downloads/testObj.fbx";
    37.         AssetLoader.LoadModelFromStream(File.OpenRead(modelPath), modelPath, null, OnLoad, OnMaterialsLoad, OnProgress, OnError, null, assetLoaderOptions);
    38.     }
    39. }
    40.  
    41. public class ExternalDataMapperSample : ExternalDataMapper
    42. {
    43.     public override Stream Map(AssetLoaderContext assetLoaderContext, string originalFilename, out string finalPath)
    44.     {
    45.         finalPath = $"{assetLoaderContext.BasePath}/{FileUtils.GetFilename(originalFilename)}";
    46.         if (File.Exists(finalPath))
    47.         {
    48.             Debug.Log($"Found external file at: {finalPath}");
    49.             return File.OpenRead(finalPath);
    50.         }
    51.         throw new Exception($"File {originalFilename} not found.");
    52.     }
    53. }
    54.  
    55. public class TextureMapperSample : TextureMapper
    56. {
    57.     public override TextureLoadingContext Map(AssetLoaderContext assetLoaderContext, ITexture texture)
    58.     {
    59.         var finalPath = $"{assetLoaderContext.BasePath}/{FileUtils.GetFilename(texture.Filename)}";
    60.         if (File.Exists(finalPath))
    61.         {
    62.             var textureLoadingContext = new TextureLoadingContext
    63.             {
    64.                 Context = assetLoaderContext,
    65.                 Stream = File.OpenRead(finalPath),
    66.                 Texture = texture
    67.             };
    68.             Debug.Log($"Found texture at: {finalPath}");
    69.             return textureLoadingContext;
    70.         }
    71.         throw new Exception($"Texture {texture.Filename} not found.");
    72.     }
    73. }
    However, I get the following error:

    Code (CSharp):
    1. Assets/SyncLoad.cs(55,36): error CS0246: The type or namespace name 'TextureMapper' could not be found (are you missing a using directive or an assembly reference?)
    2. Assets/SyncLoad.cs(57,83): error CS0246: The type or namespace name 'ITexture' could not be found (are you missing a using directive or an assembly reference?)
    3. Assets/SyncLoad.cs(57,40): error CS0115: 'TextureMapperSample.Map(AssetLoaderContext, ITexture)': no suitable method found to override
    4. Assets/SyncLoad.cs(41,41): error CS0246: The type or namespace name 'ExternalDataMapper' could not be found (are you missing a using directive or an assembly reference?)
    5. Assets/SyncLoad.cs(43,18): error CS0246: The type or namespace name 'Stream' could not be found (are you missing a using directive or an assembly reference?)
    6. Assets/SyncLoad.cs(43,25): error CS0115: 'ExternalDataMapperSample.Map(AssetLoaderContext, string, out string)': no suitable method found to override
    What am I missing in my code?
    Do I need to import anything other than TriLibCore and TriLibCore.General?
     
  9. icefallgames

    icefallgames

    Joined:
    Dec 6, 2014
    Posts:
    75
    We're having an issue where the first time any model is loaded, it has no materials (turns up pink).

    - it only happens in our game, I tried to make a simple repro project and was not able to.
    - it only happens in a build (Windows standalone), it does not happen in the editor
    - I've verified that AssetUnloader.OnDestroy is not being called
    - I'm pretty sure it happens with any model type, but definitely .obj
    - It isn't 100% repro, so maybe there is some race condition? But it seems to happen the majority of the time
    - Loading the same model a second time works fine - it's just the first time it is loaded

    Unity version: 2019.4.14

    Can you think of anything that might cause this, or what I can do to help diagnose it? Is there a way to turn on more detailed logging for TriLib2? I don't see anything unusual in the player.log.
     
    Last edited: Dec 7, 2020
  10. icefallgames

    icefallgames

    Joined:
    Dec 6, 2014
    Posts:
    75
    Got this invalid operation exception:


    Code (CSharp):
    1. TriLibCore.General.ContextualizedError`1[TriLibCore.AssetLoaderContext]: A contextualized error has occurred. ---> System.InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread
    2.   at UnityEngine.Object.EnsureRunningOnMainThread () [0x0000d] in <9674024ab0e74d27bbe9eaa30dab34d1>:0
    3.   at UnityEngine.Object.GetInstanceID () [0x00001] in <9674024ab0e74d27bbe9eaa30dab34d1>:0
    4.   at UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) [0x00035] in <9674024ab0e74d27bbe9eaa30dab34d1>:0
    5.   at UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) [0x0001d] in <9674024ab0e74d27bbe9eaa30dab34d1>:0
    6.   at UnityEngine.Object.op_Inequality (UnityEngine.Object x, UnityEngine.Object y) [0x00001] in <9674024ab0e74d27bbe9eaa30dab34d1>:0
    7.   at StbImageSharp.StbImage.LoadTexture (TriLibCore.TextureLoadingContext textureLoadingContext) [0x001ad] in <55c211aab4b848fbafef72ebecab1ceb>:0
    8.   at TriLibCore.AssetLoader.ProcessTextures (TriLibCore.AssetLoaderContext assetLoaderContext) [0x00087] in C:\SuperliminalNewRepo\Assets\TriLib\TriLibCore\Scripts\AssetLoader.cs:1023
    9.   at TriLibCore.General.ContextualizedAction`1[T].Invoke () [0x00000] in <ee225995bfcd4d31905b784ccd38f36c>:0
    10.   at TriLibCore.Utils.ThreadUtils+<>c__DisplayClass0_0`1[T].<RunThread>b__0 () [0x00011] in <ee225995bfcd4d31905b784ccd38f36c>:0
    11.    --- End of inner exception stack trace ---
    12. UnityEngine.Debug:LogError(Object)
    13. ModelLoadingPacket:OnError(IContextualizedError) (at Assets/_General Scripts/Core Gameplay Scripts/Specific/Workshop/ModelLoading/ModelLoader.cs:403)
    14. TriLibCore.General.ContextualizedAction`1:Invoke()
    15. TriLibCore.Utils.Dispatcher:Update()
    16.  
     
  11. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hey guys, sorry for being a bit away. Been working a lot on the next update.
    I will be answering the questions here again.
     
  12. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    288
    I want to support KTX2 / Basis texture. :)
     
  13. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Where are your textures located? I could provide a quick sample if you show me the structures/streams/classes containing the texture data.
     
  14. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!

    TriLib 2.0.12 is waiting approval on the Asset Store. I have fixed some Material Mapper assignment issues which may fix your issues as well.
     
  15. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    I will check out, never heard about these texture formats.
    One thing that I will probably add to the next TriLib update (2.0.13) is DDS textures support.
     
  16. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    TriLib 2.0.12 is pending approval on Asset Store, but I want to show an useful new feature I've added.
    Under Project Settings/TriLib area, we have a few more options now:

    The first section allows users to disable specific file formats reader which are not necessary for the project.

    The second section allows users to enable material mappers according to the project rendering pipeline. Custom material mappers following the template used in any of these mappers will be visible on this list as well.

    The third section allows users to enable advanced and experimental features.

    The settings are saved per-project on the TriLibSettings asset.
     
    LR-Developer and gtk2k like this.
  17. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Hi,
    I just purchased Trilib 2 and am having some trouble.

    I have a very specific use case where the user can put models in a folder, then I save the path to that folder and load all models in it on the scene load. Because my application is a VR app, I want to avoid opening a file dialog.

    Here's my code:

    Code (CSharp):
    1.  var filesInFolder = Directory.EnumerateFiles(modelPath, "*.*", SearchOption.AllDirectories)
    2.             .Where(s => s.EndsWith(".fbx") || s.EndsWith(".obj") || s.EndsWith(".zip") || s.EndsWith(".gltf")).ToArray();
    3.  
    4.         for (int i = 0; i < filesInFolder.Length; i++)
    5.         {
    6.             var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
    7.             AssetLoader.LoadModelFromFile(filesInFolder[i], null, OnMaterialsLoad, null, OnError, null, assetLoaderOptions);
    8.             Debug.Log(filesInFolder[i]);
    9.         }
    10.         Debug.Log(filesInFolder);
    11.     }
    12.     private void OnMaterialsLoad(AssetLoaderContext obj)
    13.     {
    14.         var loadedObject = obj.RootGameObject;
    15.  
    16.         if (loadedObject.GetComponent<SpawnableObject>() == null)
    17.         {
    18.             SpawnableObject SO = loadedObject.AddComponent<SpawnableObject>();
    19.         }
    20.         fullObjectLibrary.Add(loadedObject);
    21.         propLibrary.Add(loadedObject);
    22.         Debug.Log("ADDED CUSTOM MODEL TO DATABASE!");
    23.         loadedObject.SetActive(false);
    24.     }
    1) None of my materials are going through. The mesh just looks pink, even though I am doing everything correctly.
    2) When I set an imported model as inactive, then active again, all the meshes are missing and therefore invisible
    3) The same thing happens when I clone (Instantiate) an imported model -- All meshes are missing.

    Any and all help would be appreciated! Thanks!
     
    ZoroSrk likes this.
  18. pekochun

    pekochun

    Joined:
    Nov 24, 2019
    Posts:
    5
    Hi,Ricardo
    Thank you for your reply!

    The path for my model is below.
    "/Users/mac/Downloads/testObj.fbx"

    And my texture folder path is below.
    "/Users/mac/Downloads/textures"

    And my texture path is below.
    "/Users/mac/Downloads/textures/textureA.png"
    "/Users/mac/Downloads/textures/textureB.png"

    Please tell me how to load textures correctly.
     
  19. Chopium

    Chopium

    Joined:
    Jun 15, 2015
    Posts:
    19
    I'm using URP, Trilib 2.0.12 (went live on Dec 28?), Unity 2020.2.1f1.

    The TriLib I got from the package manager do NOT include the settings you screenshotted above, only TriLibCore's reader settings. To troubleshoot, I deleted Trilib and redownloaded but it appears 2.0.12 is actually 2.0.11? The TriLibVersion.txt file reports it as 2.0.11. Could this be a problem with the Asset Store?

    Back to my main problem:
    I have the URP material mapper in my asset loader options and hand that to the loader in code, but no materials are created at runtime, even though console reports success with no errors. Even the included samples do not create materials (I modified the sample's assetLoaderOption field to include one with a URP mapper). Is it a known issue?

    Otherwise this is such an improvement over the last version, I'm very happy with your refactoring and changes so far!
     
  20. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    It seems to be a problem on Asset Store, indeed. I will check it out!
     
  21. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Could you please re-download the package?
    I've tested it here and I'm getting the right version from the store:
     
  22. Chopium

    Chopium

    Joined:
    Jun 15, 2015
    Posts:
    19
    Thank you for the quick reply! It was totally a problem with the asset store. I had to delete the .unitypackage stored in %appdata% and redownload. I got the right copy now.
     
  23. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Hello- happy 1.x user just upgraded to 2.x :)

    Starting a new prototype where I'm trying to import .fbx character models from Daz Studio. I can import them with the avatar loader sample but the models come in twisted into knots.

    Is it possible to import rigged fbx models from Daz? If so what settings do you recommend? Thank you.
     
  24. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Could you send a model for testing to contato@ricardoreis.net?
     
    imaginationrabbit likes this.
  25. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Just emailed you some fbx model links- thank you.
     
  26. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    TriLib 1.9x users: I have updated the GitHub repositories with fixes, included an iOS bitcode workflow, and added a new repository containing the stb-image libraries and make-files.

    I've already invited all collaborators to this new repository.

    If you own TriLib 1.9x and want to join the repositories, please e-mail me at contato@ricardoreis.net
     
    mfleurent and imaginationrabbit like this.
  27. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    Hello,

    I am using PC standalone only for my build.

    I added TriLib 2 with the package manager, after that I deleted the Samples and HDRP folders.

    Can you give me a hint what else to delete to get my Build a bit smaller? There are so many DLLs maybe not all of them are needed for PC standalone.

    Thanks a lot!
     
  28. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    You can disable readers you won't use on the Project Settings/TriLib menu. After that, you can restart Unity and delete the DLLs from the readers you removed (eg: TriLibCore.obj.dll).
    Besides that and removing the folders from the rendering pipelines you won't use, I can't see anything else you could remove.

    Edit: There are some issues in the readers' selection area which I'm fixing now.
     
    Last edited: Jan 7, 2021
    LR-Developer likes this.
  29. santos9991

    santos9991

    Joined:
    Oct 31, 2018
    Posts:
    17
    Hello Ricardo,
    After I updated trilib 2 to the latest version the error below is always occurring.
    I'm using the latest version in Unity 2020.2.1 with HDRP.
    Already reinstalled and did not work.

    Recursive Serialization is not supported. You can't dereference a PPtr while loading. (Constructors of C# classes may not load objects either. See stacktrace.)
    0x00007ff7898b8c8c (Unity) StackWalker::GetCurrentCallstack
    0x00007ff7898c1069 (Unity) StackWalker::ShowCallstack
    0x00007ff78ad9564c (Unity) GetStacktrace
    0x00007ff78be54803 (Unity) DebugStringToFile
    0x00007ff7897d728a (Unity) PersistentManager::ReadObject
    0x00007ff787e2f866 (Unity) PPtr<Object>::eek:perator Object * __ptr64
    0x00007ff78a451694 (Unity) FindAssetImporterAtPath
    0x00007ff7896d1d9c (Unity) MonoScript::BelongsToEditorCompatibleAssembly
    0x00007ff7896d8174 (Unity) FindScriptByClass
    0x00007ff7896d7a51 (Unity) MonoScriptManager::FindRuntimeScript
    0x00007ff789743d71 (Unity) ReportRecursionDepthError
    0x00007ff78974428b (Unity) ShouldTransferField
    0x00007ff78978b0be (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974183b (Unity) EmitSerializationCommandsForManagedObjectField
    0x00007ff789740ee0 (Unity) EmitSerializationCommandsForField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974183b (Unity) EmitSerializationCommandsForManagedObjectField
    0x00007ff789740ee0 (Unity) EmitSerializationCommandsForField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974145a (Unity) EmitSerializationCommandsForLinearCollectionOfManagedObjectsField
    0x00007ff789741298 (Unity) EmitSerializationCommandsForLinearCollectionField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974183b (Unity) EmitSerializationCommandsForManagedObjectField
    0x00007ff789740ee0 (Unity) EmitSerializationCommandsForField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974145a (Unity) EmitSerializationCommandsForLinearCollectionOfManagedObjectsField
    0x00007ff789741298 (Unity) EmitSerializationCommandsForLinearCollectionField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974183b (Unity) EmitSerializationCommandsForManagedObjectField
    0x00007ff789740ee0 (Unity) EmitSerializationCommandsForField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974145a (Unity) EmitSerializationCommandsForLinearCollectionOfManagedObjectsField
    0x00007ff789741298 (Unity) EmitSerializationCommandsForLinearCollectionField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974183b (Unity) EmitSerializationCommandsForManagedObjectField
    0x00007ff789740ee0 (Unity) EmitSerializationCommandsForField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974145a (Unity) EmitSerializationCommandsForLinearCollectionOfManagedObjectsField
    0x00007ff789741298 (Unity) EmitSerializationCommandsForLinearCollectionField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974183b (Unity) EmitSerializationCommandsForManagedObjectField
    0x00007ff789740ee0 (Unity) EmitSerializationCommandsForField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974183b (Unity) EmitSerializationCommandsForManagedObjectField
    0x00007ff789740ee0 (Unity) EmitSerializationCommandsForField
    0x00007ff78978b10b (Unity) BuildSerializationCommandQueueFor
    0x00007ff78974448b (Unity) SerializationCache::WriteQueueForTransferSignatureIntoCache
    0x00007ff789740868 (Unity) SerializationCache::BuildSerializationCacheFor
    0x00007ff789741edc (Unity) SerializationCache::FetchData
    0x00007ff78922efb7 (Unity) TransferScriptingObject<GenerateTypeTreeTransfer,0>
    0x00007ff7896e7e50 (Unity) MonoBehaviour::Transfer<GenerateTypeTreeTransfer>
    0x00007ff7896ff23d (Unity) MonoBehaviour::VirtualRedirectTransfer
    0x00007ff789840c1b (Unity) TypeTreeCache::GetTypeTree
    0x00007ff789806cea (Unity) SerializedFile::SerializedType::CompareAgainstNewType
    0x00007ff789812e05 (Unity) SerializedFile::ReadObject
    0x00007ff7897d6f8c (Unity) PersistentManager::ReadAndActivateObjectThreaded
    0x00007ff7897d5201 (Unity) PersistentManager::LoadRemainingPreallocatedObjects
    0x00007ff7897d3d6f (Unity) PersistentManager::LoadAndIntegrateAllPreallocatedObjects
    0x00007ff7897d7303 (Unity) PersistentManager::ReadObject
    0x00007ff78963e3ef (Unity) Resources_Bindings::LoadAll
    0x00007ff789975383 (Unity) ResourcesAPIInternal_CUSTOM_LoadAll
    0x000001330a9cf7b7 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.ResourcesAPIInternal:LoadAll (string,System.Type)
    0x000001330a9cf64b (Mono JIT Code) UnityEngine.ResourcesAPI:LoadAll (string,System.Type)
    0x000001330a9cf087 (Mono JIT Code) UnityEngine.Resources:LoadAll (string,System.Type)
    0x000001330a9cee8b (Mono JIT Code) UnityEngine.Resources:LoadAll<T_REF> (string)
    0x000001330a9ce8eb (Mono JIT Code) [TriLibSettings.cs:23] TriLibCore.TriLibSettings:GetTriLibPreferences ()
    0x000001330a9ce42b (Mono JIT Code) [TriLibSettings.cs:65] TriLibCore.TriLibSettings:SetBool (string,bool)
    0x000001330a9c8913 (Mono JIT Code) [CheckMappers.cs:39] TriLibCore.Editor.CheckMappers:Initialize ()
    0x000001330a9c8be5 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
    0x00007ffed568e0c0 (mono-2.0-bdwgc) [mini-runtime.c:2812] mono_jit_runtime_invoke
    0x00007ffed5612902 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
    0x00007ffed561b95f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
    0x00007ff789735d94 (Unity) scripting_method_invoke
    0x00007ff78972e585 (Unity) ScriptingInvocation::Invoke
    0x00007ff78aa79792 (Unity) EditorSceneManager::processInitializeOnEnterPlayModeAttributes
    0x00007ff7881e1791 (Unity) CallbackArray::Invoke
    0x00007ff7896fc178 (Unity) MonoManager::SetupLoadedEditorAssemblies
    0x00007ff7896f330c (Unity) MonoManager::EndReloadAssembly
    0x00007ff7896fa339 (Unity) MonoManager::ReloadAssembly
    0x00007ff78aaa5b51 (Unity) ReloadAllUsedAssemblies
    0x00007ff78aa7ad2c (Unity) EditorSceneManager::RestoreSceneBackups
    0x00007ff78a424566 (Unity) PlayerLoopController::EnterPlayMode
    0x00007ff78a439ced (Unity) PlayerLoopController::SetIsPlaying
    0x00007ff78a43c9c5 (Unity) Application::TickTimer
    0x00007ff78ad9ee21 (Unity) MainMessageLoop
    0x00007ff78ada2eb1 (Unity) WinMain
    0x00007ff78cbe8fc6 (Unity) __scrt_common_main_seh
    0x00007fff60817c24 (KERNEL32) BaseThreadInitThunk
    0x00007fff60b4d4d1 (ntdll) RtlUserThreadStart
     
  30. Camilojr

    Camilojr

    Joined:
    Mar 26, 2014
    Posts:
    6
    en:
    Hi Ricardo! Congratulations, it's getting better and better !!
    I noticed a small crash in version 2.0.12b (asset store). It seems that every 1s there is some heavier processing that makes the screen reduce FPS, or even a small crash.
    Just reporting! Thanks!

    pt-br:
    Oi Ricardo! Parabéns, está ficando cada vez mais aprimorado!!
    Eu percebi um pequeno travamento na versão 2.0.12b (asset store). Parece que a cada 1s há algum processamento mais pesado que faz a tela reduzir o FPS, ou até mesmo uma pequena travada.
    Apenas reportando! Obrigado!
     
  31. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Is this while loading the model or after the model has been loaded?
     
  32. Camilojr

    Camilojr

    Joined:
    Mar 26, 2014
    Posts:
    6
    After the model has been loaded.
    In a response on Twitter, Marek Stój (@MarekStoj) told me that I could disable GCHelpers.
    What is the use of Garbage Collector every 1s?
    I tried to disable GCHelpers in three attempts:
    1 - Assigning the value false in ForceGCCollectionWhileLoading;
    2 - Deactivating by intance;
    3 - Commenting on an excerpt of the function that disables GCHelpers.

    The one that worked was attempt 3.
    What can I be doing wrong?

    Thanks Rick!

    upload_2021-1-11_9-54-31.png
     
  33. santos9991

    santos9991

    Joined:
    Oct 31, 2018
    Posts:
    17
    Hi Ricardo,
    About the error in post above?
     
  34. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!

    The GC helper's behavior is working right at my tests, but I will surely test the above issue before the next update.
    Sorry about the delay. I'm finishing the mesh loading refactoring.
     
  35. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Sorry about the delay guys.
    Next update will be ready tomorrow (should take some days to be accepted on Asset Store too).
     
    imaginationrabbit likes this.
  36. unitydevstudio

    unitydevstudio

    Joined:
    Jun 24, 2017
    Posts:
    24
    Hi,
    I got an error when I tried the AssetViewer example scene on Unity2020.2.1f1 and MacOS catalina.
    FilePicker worked in Unity Editor and if I select the model, it works to load model.
    But if I click the cancel button of FilePicking dialog, it occurs the following error.

    Code (CSharp):
    1. ArgumentException: Path is empty
    2. System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at <9577ac7a62ef43179789031239ba8798>:0)
    3. System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) (at <9577ac7a62ef43179789031239ba8798>:0)
    4. (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
    5. System.IO.File.OpenRead (System.String path) (at <9577ac7a62ef43179789031239ba8798>:0)
    6. TriLibCore.SFB.ItemWithStream.OpenStream () (at Assets/TriLib/TriLibStandaloneFileBrowser/StandaloneFileBrowser/ItemWithStream.cs:27)
    7. TriLibCore.AssetLoaderFilePicker+<DoHandleFileLoading>d__13.MoveNext () (at Assets/TriLib/TriLibStandaloneFileBrowser/StandaloneFileBrowser/TriLib/AssetLoaderFilePicker.cs:94)
    8. UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
    9. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
    On Windows, this error never happens and everything works well.

    Also, when I clicked the cancel button of LoadModelURL dialog, the unity editor crashed.

    -Another issue.
    Filepicker works only in unity editor on mac OS.
    MacOS standalone build doesn't work at all for filepicker.
    It doesn't even popup the filepicker dialog.
    Is the problem relate to the file access permission grant?

    Can u please help me to fix these 2 issues?
    Thanks.
     
    Last edited: Jan 20, 2021
  37. akbar74

    akbar74

    Joined:
    Nov 16, 2017
    Posts:
    21
    Hi. thanks for your great package.
    I have model with 3 different material. how can I load model, each time with different mat?
    or can I have one mat but 3 texture and each time set the different texture?
     
  38. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    Hello,

    I am using SolidWorks to export glb files and unity with TriLib 2 to load them from disk.

    But they seem to be mirrored or rotated...

    The old 1.9 documentation here says it can be rotated by option:

    https://ricardoreis.net/trilib/manual/html/class_tri_lib_1_1_asset_loader_options.html

    Vector3 RotationAngles = new Vector3(0f, 180f, 0f)

    and

    bool UseOriginalPositionRotationAndScale = false

    Are these gone or do I just not see them?
    Am I using it the correct way?

    Code (CSharp):
    1.         private void DownloadDragModel(string uriString, GameObject downloadGo)
    2.         {
    3.             var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
    4.             //assetLoaderOptions.UseFileScale = false;
    5.             AssetLoader.LoadModelFromFile(
    6.                 uriString,
    7.                 OnModelLoad,
    8.                 OnMaterialsLoad,
    9.                 downloadGo.GetComponent<DownloadPreview>().OnProgress,
    10.                 downloadGo.GetComponent<DownloadPreview>().OnError,
    11.                 downloadGo,
    12.                 assetLoaderOptions);
    13.         }
    It seems top is bottom? If I set localscale to 1,1,-1 it looks okay, or maybe if I rotate them by myself around y = 180 also okay, but in both cases they change their location because their pivot is not the middle of the object...

    How do I get out of this, any idea?

    Thanks a lot!
     
    HyunMok_Moon likes this.
  39. akbar74

    akbar74

    Joined:
    Nov 16, 2017
    Posts:
    21
  40. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    I will check out these issues.
     
  41. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!

    TriLib is meant to keep the original model orientation.
    TriLib 2.0 doesn't have the option to rotate loaded models manually when loading, since it should keep the original rotation.
    I could add this option if needed, or you could send me the file via e-mail so I can check out what is wrong.
     
  42. unitydevstudio

    unitydevstudio

    Joined:
    Jun 24, 2017
    Posts:
    24
    Thanks.
     
  43. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    I could not check out this issue yet. Still, I've included the native code for all file-picker libraries in the latest TriLib version, so you can debug it on Visual Studio while I'm still trying to reproduce such issues.
     
  44. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    You could create a class inheriting the MaterialMapper base class and use your own logic to handle the material variations.
    There is no sample on how to create a custom MaterialMapper yet. Still, you can check the StandardMaterialMapper.cs code, which is fully commented out and could be used as a reference.
     
    akbar74 likes this.
  45. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    The GCHelper class has been fixed on the latest update.
     
  46. unitydevstudio

    unitydevstudio

    Joined:
    Jun 24, 2017
    Posts:
    24
    Hi,
    Okay, I will try to debug it.
    But please try to reproduce the issues I mentioned on your side and keep me updated as you resolved them.
    Actually, MacOS standalone build doesn't show a file picker popup at all.

    Thanks.
     
  47. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Will do!
     
  48. Luedrin

    Luedrin

    Joined:
    Aug 21, 2018
    Posts:
    4
    I'm having difficulties migrating my project from old Trilib to Trilib 2 (and Unity 2018.4 > 2019.4). I checked the migrating example and implemented that into my code, replacing the previous version (using (AssetLoader assetLoader = new AssetLoader) etc.).

    Now I'm getting the errors such as:
    An error ocurred while loading your Model: System.ArgumentNullException: Value cannot be null. Parameter name: String
    and
    An error ocurred while loading your Model: System.IndexOutOfRangeException: Index was outside the bounds of the array.
    which don't make sense to me.
    As far as I understand the string null error traces back to AssetLoader.1045 where, after putting a breakpoint and debugging, everything seems fine. I've also tried it in the example scene (TriLibSamples/LoadModelFromFile) which gave me the same string error for the model I'm trying to load. Model's filename is: PS80801800. What am I not seeing/understanding?

    Code (CSharp):
    1. An error ocurred while loading your Model: System.ArgumentNullException: Value cannot be null.
    2. Parameter name: String
    3.   at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00003] in <9577ac7a62ef43179789031239ba8798>:0
    4.   at System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00013] in <9577ac7a62ef43179789031239ba8798>:0
    5.   at System.Int32.Parse (System.String s) [0x00007] in <9577ac7a62ef43179789031239ba8798>:0
    6.   at TriLibCore.Fbx.FBXProperties.ASCIIGetIntValue (System.Int32 index) [0x00007] in <f6b71504543646a0878c1d83e445a129>:0
    7.   at TriLibCore.Fbx.FBXProperties+<ASCIIGetIntValues>d__75.MoveNext () [0x00020] in <f6b71504543646a0878c1d83e445a129>:0
    8.   at TriLibCore.Pooling.ListPool`1[T]..ctor (System.Collections.Generic.IEnumerable`1[T] values, System.Int32 count, TriLibCore.Pooling.ArrayPoolBase`1[T] pool) [0x0004e] in <12d9fc1b6ce74d19ba7359d43eea79db>:0
    9.   at TriLibCore.Fbx.FBXProcessor.ProcessMaterialLayer (TriLibCore.Fbx.FBXGeometryGroup geometryGroup, TriLibCore.Fbx.FBXNode dataLayer, System.String mappingInformationTypeValue, TriLibCore.Fbx.FBXNode mappingInformationType) [0x00018] in <f6b71504543646a0878c1d83e445a129>:0
    10.   at TriLibCore.Fbx.FBXProcessor.ProcessGeometryLayer (TriLibCore.Fbx.FBXGeometryGroup geometryGroup, TriLibCore.Fbx.FBXNode layerElement, TriLibCore.Fbx.FBXLayerType layerType) [0x00185] in <f6b71504543646a0878c1d83e445a129>:0
    11.   at TriLibCore.Fbx.FBXProcessor.ProcessPolygons () [0x002a5] in <f6b71504543646a0878c1d83e445a129>:0
    12.   at TriLibCore.Fbx.FBXProcessor.ProcessGeometries () [0x00006] in <f6b71504543646a0878c1d83e445a129>:0
    13.   at TriLibCore.Fbx.FBXProcessor.Process (TriLibCore.Fbx.FBXNode rootNode, System.Boolean isBinary) [0x0011f] in <f6b71504543646a0878c1d83e445a129>:0
    14.   at TriLibCore.Fbx.Reader.FbxReader.ParseASCII (System.IO.Stream stream) [0x000c8] in <f6b71504543646a0878c1d83e445a129>:0
    15.   at TriLibCore.Fbx.Reader.FbxReader.ReadStream (System.IO.Stream stream, TriLibCore.AssetLoaderContext assetLoaderContext, System.String filename, System.Action`2[T1,T2] onProgress) [0x0002d] in <f6b71504543646a0878c1d83e445a129>:0
    16.   at TriLibCore.AssetLoader.LoadModel (TriLibCore.AssetLoaderContext assetLoaderContext) [0x000e6] in /Users/jarnecooijmans/Documents/Werk/Wij Doen Dingen/1. Klanten/Thibo/Projecten/thibo-trilib2/Assets/TriLib/TriLibCore/Scripts/AssetLoader.cs:1045
    17.   at TriLibCore.General.ContextualizedAction`1[T].Invoke () [0x00000] in <12d9fc1b6ce74d19ba7359d43eea79db>:0
    18.   at TriLibCore.Utils.ThreadUtils+<>c__DisplayClass0_0`1[T].<RunThread>b__0 () [0x0002f] in <12d9fc1b6ce74d19ba7359d43eea79db>:0
    19. UnityEngine.Debug:LogError(Object)
    20. PresetModelLoader:OnError(IContextualizedError) (at Assets/Scripts/ConfiguratorLogic/FbxDownloadingAndLoading/PresetModelLoader.cs:268)
    21. TriLibCore.General.ContextualizedAction`1:Invoke()
    22. TriLibCore.Utils.Dispatcher:Update()
     
  49. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    If you prefer, I could help you out via TeamViewer, please e-mail me at: contato@ricardoreis.net
     
    Luedrin likes this.
  50. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    TriLib 2.0.14 is awaiting approval on Asset Store.

    I apologize in forehand for an issue I've introduced in the latest version, which prevents the GCHandler quit from forcing the GC collection. It has been fixed on the upcoming update, along with many other changes:

    -Refactored FBX mesh generation.
    -Fixed StandaloneFileBrowser not opening on Windows.
    -Fixed STL flipped normals bug.
    -Fixed GCHelper.cs always running bug.
    -Fixed GLTF blend-shape animations bug.
    -Fixed GLTF roughness values.
    -Fixed FBX ASCII reader bug with out-of-range properties.
    -Fixed ImporterEditor references on newer Unity versions.
    -TriLib now fixes out of unit-range normals.
    -Removed bone weight limitations.
    -Added GLTF metallic texture creation to simulate metallic values when there is no texture available.
    -Added UseUnityNativeTextureLoader loader option to use Unity builtin texture loader instead of stb_image.
    -Added UseUnityNativeNormalCalculator loader option to use Unity builtin normal calculator.
    -Added GCHelperCollectionInterval loader option to set the interval GCHelper takes to release a loading model.
    -Added SimpleCustomAssetLoader sample.
     
    LR-Developer and Bartolomeus755 like this.