19 lines
643 B
C#
Raw Normal View History

2025-05-18 01:04:31 +08:00
using System.Reflection;
namespace AddressableTests
{
static class TestReflectionHelpers
{
public static void SetResritctMainThreadFileIO(bool errorOnMainThreadFileIO)
{
System.Type t = System.Type.GetType("UnityEngine.IO.File, UnityEngine.CoreModule");
if (t != null)
{
System.Reflection.PropertyInfo pInfo = t.GetProperty("MainThreadIORestrictionMode", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
if (pInfo != null)
pInfo.SetValue(null, errorOnMainThreadFileIO ? 1 : 0);
}
}
}
}