unity3d – Trilib: Select files from iOS, nothing happens

0
183


I have some issue while using Trilib on iOS with LoadModelFromFilePickerAsync, although it runs well on Android, Unity Editor, and Mac.

Here code:

    var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
    var filePickerAssetLoader = AssetLoaderFilePicker.Create();
    filePickerAssetLoader.LoadModelFromFilePickerAsync("Load model",
        onLoad, 
        onMaterialsLoad, 
        onProgress, 
        onBeginLoad, 
        onError,
        null,
        assetLoaderOptions);
    private void onBeginLoad(bool x)
    {
        btnUploadModel3D.interactable = true;
        if (x == true)
        {
            uiCoat.SetActive(true);
            uiBFill.SetActive(true);
            // txtPercent.text="0%";
        }
        else
        {
            // txtPercent.text="";
            ReStore();
        }
    }

    private void onError(IContextualizedError obj)
    {
        btnUploadModel3D.interactable = true;
        ReStore();
        warningFileFormat.enabled = true;
        warningFileSize.enabled = false;
    }

    private void onProgress(AssetLoaderContext assetLoaderContext, float progress)
    {

    }

    private void onMaterialsLoad(AssetLoaderContext x)
    {

    }

    private void onLoad(AssetLoaderContext x)
    {
        string path = ModelManager.modelFilepath;

        var fileInfo = new System.IO.FileInfo(path);

        var lengthFile = fileInfo.Length / 1000000;

        var modelName = getModelName(path);

        string formatFile = ModelManager.modelExtension.ToUpper();
        if (Array.IndexOf(arrFormatFile, formatFile) < 0)
        {
            ReStore();
            warningFileSize.enabled = false;
            warningFileFormat.enabled = true;
        }
        else
        {
            if (lengthFile > 100)
            {
                ReStore();
                warningFileSize.enabled = true;
                warningFileFormat.enabled = false;

            }
            else
            {
                x.RootGameObject.tag = "ModelClone";
                x.RootGameObject.name = modelName;
                warningFileFormat.enabled = false;
                warningFileSize.enabled = false;
                UploadModelToServer(File.ReadAllBytes(path), path);
                DontDestroyOnLoad(x.RootGameObject);
            }
        }
    }

I used the above code to select file with extension: .fbx, .zip, .obj, .glb from my iPhone. I selected a file .fbx, nothing happens though. There are no errors reported.

How can I fix it ? Thanks.