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.