System.IO not working for brokered filesystem locations in UWP with Unity 2021 (regression)

I have the following code:

using System.IO;
using UnityEngine;

#if ENABLE_WINMD_SUPPORT
using Windows.Storage;
#endif

public class Test : MonoBehaviour
{
    void Start()
    {
        string localPath = Path.Combine(Application.persistentDataPath, "TestDir");
      
        try
        {
            Directory.CreateDirectory(localPath);
            Debug.Log("Directory created successfully");
        }
        catch (System.Exception ex)
        {
            Debug.LogException(ex);
        }

        try
        {
            Objects3DTest();
        }
        catch(System.Exception ex)
        {
            Debug.LogException(ex);
        }
    }

    [System.Diagnostics.Conditional("ENABLE_WINMD_SUPPORT")]
    void Objects3DTest()
    {
#if ENABLE_WINMD_SUPPORT
        try
        {
            string path = Path.Combine(KnownFolders.Objects3D.Path, "TestDir");

            Directory.CreateDirectory(path);
            Debug.Log("Direcotry in Objects3D created successfully");
        }
        catch (System.Exception ex)
        {
            Debug.LogException(ex);
        }
#endif
    }
}

Objects3D permission is enabled in the app manifest.
With Unity 2020.3.43 it works fine. After switching to Unity 2021.3.16 the Objects3D case does not work anymore, which prevents us from upgrading (our project needs to run on HoloLens).

Case number is IN-29088.

Hey, we received a but report about it a couple months ago. The fix is in progress: Unity Issue Tracker - Unable to access KnownFolders.Objects3D folder using System.IO API when deployed on HoloLens 2

1 Like

Awesome, thanks!

Do you know by chance when the fix will land in 2021 LTS? We’re trying to estimate whether to go forward with the upgrade or to stay on 2020 for another 3 or so months.

We are planning to land it to 2021.3.