├── .gitignore ├── Assets ├── UniReflection.meta └── UniReflection │ ├── Runtime.meta │ ├── Runtime │ ├── FieldAccess.cs │ ├── FieldAccess.cs.meta │ ├── IL2CPP.meta │ ├── IL2CPP │ │ ├── Enums.cs │ │ ├── Enums.cs.meta │ │ ├── Extensions.cs │ │ ├── Extensions.cs.meta │ │ ├── Il2CppAssemblyHandle.cs │ │ ├── Il2CppAssemblyHandle.cs.meta │ │ ├── Il2CppAssemblyName.cs │ │ ├── Il2CppAssemblyName.cs.meta │ │ ├── Il2CppClassHandle.cs │ │ ├── Il2CppClassHandle.cs.meta │ │ ├── Il2CppCustomAttrInfoHandle.cs │ │ ├── Il2CppCustomAttrInfoHandle.cs.meta │ │ ├── Il2CppEventInfoHandle.cs │ │ ├── Il2CppEventInfoHandle.cs.meta │ │ ├── Il2CppFieldInfoHandle.cs │ │ ├── Il2CppFieldInfoHandle.cs.meta │ │ ├── Il2CppGenericClassHandle.cs │ │ ├── Il2CppGenericClassHandle.cs.meta │ │ ├── Il2CppImageHandle.cs │ │ ├── Il2CppImageHandle.cs.meta │ │ ├── Il2CppMetadataGenericContainerHandle.cs │ │ ├── Il2CppMetadataGenericContainerHandle.cs.meta │ │ ├── Il2CppMetadataImageHandle.cs │ │ ├── Il2CppMetadataImageHandle.cs.meta │ │ ├── Il2CppMetadataTypeHandle.cs │ │ ├── Il2CppMetadataTypeHandle.cs.meta │ │ ├── Il2CppMethodHandle.cs │ │ ├── Il2CppMethodHandle.cs.meta │ │ ├── Il2CppObject.cs │ │ ├── Il2CppObject.cs.meta │ │ ├── Il2CppPropertyInfoHandle.cs │ │ ├── Il2CppPropertyInfoHandle.cs.meta │ │ ├── Il2CppReflectionTypeHandle.cs │ │ ├── Il2CppReflectionTypeHandle.cs.meta │ │ ├── Il2CppRuntimeInterfaceOffsetPairHandle.cs │ │ ├── Il2CppRuntimeInterfaceOffsetPairHandle.cs.meta │ │ ├── Il2CppString.cs │ │ ├── Il2CppString.cs.meta │ │ ├── Il2CppTypeHandle.cs │ │ ├── Il2CppTypeHandle.cs.meta │ │ ├── Il2cppApi.cs │ │ ├── Il2cppApi.cs.meta │ │ ├── MarshaledString.cs │ │ ├── MarshaledString.cs.meta │ │ ├── NativeString.cs │ │ ├── NativeString.cs.meta │ │ ├── UniReflection.IL2CPP.asmdef │ │ └── UniReflection.IL2CPP.asmdef.meta │ ├── InstanceAction.cs │ ├── InstanceAction.cs.meta │ ├── InstanceActions.cs │ ├── InstanceActions.cs.meta │ ├── InstanceActions.tt │ ├── InstanceActions.tt.meta │ ├── InstanceFunc.cs │ ├── InstanceFunc.cs.meta │ ├── InstanceFuncs.cs │ ├── InstanceFuncs.cs.meta │ ├── InstanceFuncs.tt │ ├── InstanceFuncs.tt.meta │ ├── NewCache.cs │ ├── NewCache.cs.meta │ ├── NewCaches.cs │ ├── NewCaches.cs.meta │ ├── NewCaches.tt │ ├── NewCaches.tt.meta │ ├── PinnedObject.cs │ ├── PinnedObject.cs.meta │ ├── UniReflection.Runtime.asmdef │ ├── UniReflection.Runtime.asmdef.meta │ ├── Unsafe.meta │ ├── Unsafe │ │ ├── UniReflection.Unsafe.dll │ │ ├── UniReflection.Unsafe.dll.meta │ │ ├── UniReflection.Unsafe.il │ │ └── UniReflection.Unsafe.il.meta │ ├── UnsafeConversion.cs │ └── UnsafeConversion.cs.meta │ ├── Tests.meta │ ├── Tests │ ├── Benchmark.cs │ ├── Benchmark.cs.meta │ ├── UniReflection.Tests.asmdef │ └── UniReflection.Tests.asmdef.meta │ ├── package.json │ └── package.json.meta ├── LICENSE ├── Media ├── StaticField.png └── new.png ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── BurstAotSettings_StandaloneWindows.json ├── ClusterInputManager.asset ├── CommonBurstAotSettings.json ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── MemorySettings.asset ├── NavMeshAreas.asset ├── PackageManagerSettings.asset ├── Packages │ └── com.unity.testtools.codecoverage │ │ └── Settings.json ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── SceneTemplateSettings.json ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset └── XRSettings.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | 13 | # MemoryCaptures can get excessive in size. 14 | # They also could contain extremely sensitive data 15 | /[Mm]emoryCaptures/ 16 | 17 | # Recordings can get excessive in size 18 | /[Rr]ecordings/ 19 | 20 | # Uncomment this line if you wish to ignore the asset store tools plugin 21 | # /[Aa]ssets/AssetStoreTools* 22 | 23 | # Autogenerated Jetbrains Rider plugin 24 | /[Aa]ssets/Plugins/Editor/JetBrains* 25 | 26 | # Visual Studio cache directory 27 | .vs/ 28 | 29 | # Gradle cache directory 30 | .gradle/ 31 | 32 | # Autogenerated VS/MD/Consulo solution and project files 33 | ExportedObj/ 34 | .consulo/ 35 | *.csproj 36 | *.unityproj 37 | *.sln 38 | *.suo 39 | *.tmp 40 | *.user 41 | *.userprefs 42 | *.pidb 43 | *.booproj 44 | *.svd 45 | *.pdb 46 | *.mdb 47 | *.opendb 48 | *.VC.db 49 | 50 | # Unity3D generated meta files 51 | *.pidb.meta 52 | *.pdb.meta 53 | *.mdb.meta 54 | 55 | # Unity3D generated file on crash reports 56 | sysinfo.txt 57 | 58 | # Builds 59 | *.apk 60 | *.aab 61 | *.unitypackage 62 | *.app 63 | 64 | # Crashlytics generated file 65 | crashlytics-build.properties 66 | 67 | # Packed Addressables 68 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 69 | 70 | # Temporary auto-generated Android Assets 71 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 72 | /[Aa]ssets/[Ss]treamingAssets/aa/* 73 | 74 | # Visual Studio Code cache directory 75 | .vscode/ 76 | 77 | # DS_Store 78 | *.DS_Store -------------------------------------------------------------------------------- /Assets/UniReflection.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 586bc050fa7a34348aa949b4c54a9c3e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09f5abe38eee79a49b5b4d290540b833 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/FieldAccess.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR|| !ENABLE_IL2CPP 2 | #define Mono 3 | #endif 4 | 5 | 6 | using System; 7 | using System.Diagnostics.CodeAnalysis; 8 | using System.Linq.Expressions; 9 | using System.Reflection; 10 | using System.Reflection.Emit; 11 | using System.Runtime.CompilerServices; 12 | using Unity.Collections.LowLevel.Unsafe; 13 | using UniReflection.IL2CPP; 14 | namespace UniReflection { 15 | 16 | public static unsafe class FieldAccess { 17 | class SimpleClass { 18 | public byte I; 19 | } 20 | public static readonly int BaseClassFieldOffset= UnsafeUtility.GetFieldOffset(typeof(SimpleClass).GetField("I")); 21 | public static void Read(Span a){} 22 | 23 | public static int GetOffset(this FieldInfo fieldInfo) { 24 | var declaringType = fieldInfo.DeclaringType; 25 | if(declaringType is null) throw new NullReferenceException(); 26 | if(declaringType.IsValueType) return UnsafeUtility.GetFieldOffset(fieldInfo); 27 | return UnsafeUtility.GetFieldOffset(fieldInfo)-BaseClassFieldOffset; 28 | } 29 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 30 | public static ref byte GetBaseRef(this object obj) { 31 | return ref Unsafe.As(obj).I; 32 | } 33 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 34 | public static ref readonly TValue ReadFieldFromObject(object obj,int offset) { 35 | return ref Unsafe.As(ref Unsafe.Add(ref obj.GetBaseRef(),offset)); 36 | } 37 | 38 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 39 | public static ref TValue GetFieldReferenceFromObject(object obj,int offset) { 40 | return ref Unsafe.As(ref Unsafe.AddByteOffset(ref Unsafe.As(obj).I,(IntPtr)offset)); 41 | } 42 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 43 | public static ref readonly TValue ReadFieldFromRef(in T obj,int offset) {//where T:struct 44 | return ref Unsafe.As(ref Unsafe.AddByteOffset(ref Unsafe.AsRef(in obj),(IntPtr)offset)); 45 | } 46 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 47 | public static ref TValue GetFieldReferenceFromRef(ref T obj,int offset) { 48 | return ref Unsafe.As(ref Unsafe.AddByteOffset(ref obj,(IntPtr)offset)); 49 | } 50 | 51 | public static Func CreateStaticFieldGetter( 52 | this FieldInfo fieldInfo) { 53 | #if Mono 54 | DynamicMethod m = new DynamicMethod("getter", typeof(TValue),TypeArrayCache.TypeArray); 55 | ILGenerator cg = m.GetILGenerator(); 56 | cg.Emit(OpCodes.Ldsfld, fieldInfo); 57 | cg.Emit(OpCodes.Ret); 58 | return (Func) m.CreateDelegate(typeof(Func)); 59 | #else 60 | var handle = fieldInfo.GetHandle(); 61 | if(!handle.IsStatic)return null; 62 | return () => { 63 | var v = default(TValue); 64 | Il2CppApi.il2cpp_field_static_get_value(handle, Unsafe.AsPointer(ref v)); 65 | return v; 66 | }; 67 | #endif 68 | } 69 | public static Action CreateStaticFieldSetter( 70 | this FieldInfo fieldInfo) { 71 | #if Mono 72 | DynamicMethod m = new DynamicMethod("setter", null,TypeArrayCache.TypeArray); 73 | ILGenerator cg = m.GetILGenerator(); 74 | cg.Emit(OpCodes.Ldarg_1); 75 | cg.Emit(OpCodes.Stsfld, fieldInfo); 76 | cg.Emit(OpCodes.Ret); 77 | return (Action) m.CreateDelegate(typeof(Action)); 78 | #else 79 | var handle = fieldInfo.GetHandle(); 80 | if(!handle.IsStatic)return null; 81 | var t=typeof(TValue); 82 | if(t.IsValueType&&!t.IsPointer) 83 | { 84 | return v => { Il2CppApi.il2cpp_field_static_set_value(handle, Unsafe.AsPointer(ref v)); }; 85 | } 86 | { 87 | return v => Il2CppApi.il2cpp_field_static_set_value(handle, Unsafe.As(ref v).ToPointer()); 88 | } 89 | #endif 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/FieldAccess.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a76abda8f124dbcb4b9b64deb5a3849 3 | timeCreated: 1702446811 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7db332eedd3c3204bb043d7feda73b67 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Enums.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public enum Il2CppGCMode 3 | { 4 | IL2CPP_GC_MODE_DISABLED = 0, 5 | IL2CPP_GC_MODE_ENABLED = 1, 6 | IL2CPP_GC_MODE_MANUAL = 2 7 | } 8 | public enum Il2CppStat { 9 | IL2CPP_STAT_NEW_OBJECT_COUNT, 10 | IL2CPP_STAT_INITIALIZED_CLASS_COUNT, 11 | //IL2CPP_STAT_GENERIC_VTABLE_COUNT, 12 | //IL2CPP_STAT_USED_CLASS_COUNT, 13 | IL2CPP_STAT_METHOD_COUNT, 14 | //IL2CPP_STAT_CLASS_VTABLE_SIZE, 15 | IL2CPP_STAT_CLASS_STATIC_DATA_SIZE, 16 | IL2CPP_STAT_GENERIC_INSTANCE_COUNT, 17 | IL2CPP_STAT_GENERIC_CLASS_COUNT, 18 | IL2CPP_STAT_INFLATED_METHOD_COUNT, 19 | IL2CPP_STAT_INFLATED_TYPE_COUNT, 20 | //IL2CPP_STAT_DELEGATE_CREATIONS, 21 | //IL2CPP_STAT_MINOR_GC_COUNT, 22 | //IL2CPP_STAT_MAJOR_GC_COUNT, 23 | //IL2CPP_STAT_MINOR_GC_TIME_USECS, 24 | //IL2CPP_STAT_MAJOR_GC_TIME_USECS 25 | } 26 | public enum Il2CppVarType 27 | { 28 | IL2CPP_VT_EMPTY = 0, 29 | IL2CPP_VT_NULL = 1, 30 | IL2CPP_VT_I2 = 2, 31 | IL2CPP_VT_I4 = 3, 32 | IL2CPP_VT_R4 = 4, 33 | IL2CPP_VT_R8 = 5, 34 | IL2CPP_VT_CY = 6, 35 | IL2CPP_VT_DATE = 7, 36 | IL2CPP_VT_BSTR = 8, 37 | IL2CPP_VT_DISPATCH = 9, 38 | IL2CPP_VT_ERROR = 10, 39 | IL2CPP_VT_BOOL = 11, 40 | IL2CPP_VT_VARIANT = 12, 41 | IL2CPP_VT_UNKNOWN = 13, 42 | IL2CPP_VT_DECIMAL = 14, 43 | IL2CPP_VT_I1 = 16, 44 | IL2CPP_VT_UI1 = 17, 45 | IL2CPP_VT_UI2 = 18, 46 | IL2CPP_VT_UI4 = 19, 47 | IL2CPP_VT_I8 = 20, 48 | IL2CPP_VT_UI8 = 21, 49 | IL2CPP_VT_INT = 22, 50 | IL2CPP_VT_UINT = 23, 51 | IL2CPP_VT_VOID = 24, 52 | IL2CPP_VT_HRESULT = 25, 53 | IL2CPP_VT_PTR = 26, 54 | IL2CPP_VT_SAFEARRAY = 27, 55 | IL2CPP_VT_CARRAY = 28, 56 | IL2CPP_VT_USERDEFINED = 29, 57 | IL2CPP_VT_LPSTR = 30, 58 | IL2CPP_VT_LPWSTR = 31, 59 | IL2CPP_VT_RECORD = 36, 60 | IL2CPP_VT_INT_PTR = 37, 61 | IL2CPP_VT_UINT_PTR = 38, 62 | IL2CPP_VT_FILETIME = 64, 63 | IL2CPP_VT_BLOB = 65, 64 | IL2CPP_VT_STREAM = 66, 65 | IL2CPP_VT_STORAGE = 67, 66 | IL2CPP_VT_STREAMED_OBJECT = 68, 67 | IL2CPP_VT_STORED_OBJECT = 69, 68 | IL2CPP_VT_BLOB_OBJECT = 70, 69 | IL2CPP_VT_CF = 71, 70 | IL2CPP_VT_CLSID = 72, 71 | IL2CPP_VT_VERSIONED_STREAM = 73, 72 | IL2CPP_VT_BSTR_BLOB = 0xfff, 73 | IL2CPP_VT_VECTOR = 0x1000, 74 | IL2CPP_VT_ARRAY = 0x2000, 75 | IL2CPP_VT_BYREF = 0x4000, 76 | IL2CPP_VT_RESERVED = 0x8000, 77 | IL2CPP_VT_ILLEGAL = 0xffff, 78 | IL2CPP_VT_ILLEGALMASKED = 0xfff, 79 | IL2CPP_VT_TYPEMASK = 0xfff, 80 | } 81 | public enum Il2CppTypeEnum : byte 82 | { 83 | IL2CPP_TYPE_END = 0x00, /* End of List */ 84 | IL2CPP_TYPE_VOID = 0x01, 85 | IL2CPP_TYPE_BOOLEAN = 0x02, 86 | IL2CPP_TYPE_CHAR = 0x03, 87 | IL2CPP_TYPE_I1 = 0x04, 88 | IL2CPP_TYPE_U1 = 0x05, 89 | IL2CPP_TYPE_I2 = 0x06, 90 | IL2CPP_TYPE_U2 = 0x07, 91 | IL2CPP_TYPE_I4 = 0x08, 92 | IL2CPP_TYPE_U4 = 0x09, 93 | IL2CPP_TYPE_I8 = 0x0a, 94 | IL2CPP_TYPE_U8 = 0x0b, 95 | IL2CPP_TYPE_R4 = 0x0c, 96 | IL2CPP_TYPE_R8 = 0x0d, 97 | IL2CPP_TYPE_STRING = 0x0e, 98 | IL2CPP_TYPE_PTR = 0x0f, /* arg: token */ 99 | IL2CPP_TYPE_BYREF = 0x10, /* arg: token */ 100 | IL2CPP_TYPE_VALUETYPE = 0x11, /* arg: token */ 101 | IL2CPP_TYPE_CLASS = 0x12, /* arg: token */ 102 | IL2CPP_TYPE_VAR = 103 | 0x13, /* Generic parameter in a generic type definition, represented as number (compressed unsigned integer) number */ 104 | IL2CPP_TYPE_ARRAY = 0x14, /* type, rank, boundsCount, bound1, loCount, lo1 */ 105 | IL2CPP_TYPE_GENERICINST = 0x15, /* \x{2026} */ 106 | IL2CPP_TYPE_TYPEDBYREF = 0x16, 107 | IL2CPP_TYPE_I = 0x18, 108 | IL2CPP_TYPE_U = 0x19, 109 | IL2CPP_TYPE_FNPTR = 0x1b, /* arg: full method signature */ 110 | IL2CPP_TYPE_OBJECT = 0x1c, 111 | IL2CPP_TYPE_SZARRAY = 0x1d, /* 0-based one-dim-array */ 112 | 113 | IL2CPP_TYPE_MVAR = 114 | 0x1e, /* Generic parameter in a generic method definition, represented as number (compressed unsigned integer) */ 115 | IL2CPP_TYPE_CMOD_REQD = 0x1f, /* arg: typedef or typeref token */ 116 | IL2CPP_TYPE_CMOD_OPT = 0x20, /* optional arg: typedef or typref token */ 117 | IL2CPP_TYPE_INTERNAL = 0x21, /* CLR internal type */ 118 | 119 | IL2CPP_TYPE_MODIFIER = 0x40, /* Or with the following types */ 120 | IL2CPP_TYPE_SENTINEL = 0x41, /* Sentinel for varargs method signature */ 121 | IL2CPP_TYPE_PINNED = 0x45, /* Local var that points to pinned object */ 122 | 123 | IL2CPP_TYPE_ENUM = 0x55 /* an enumeration */ 124 | } 125 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Enums.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73bbb59a775f4446930bb3d75631bf2a 3 | timeCreated: 1702445938 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Extensions.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR||!ENABLE_IL2CPP 2 | #define Mono 3 | #endif 4 | using System.Reflection; 5 | using System; 6 | using Unity.Collections.LowLevel.Unsafe; 7 | 8 | namespace UniReflection.IL2CPP { 9 | public static unsafe class Extensions { 10 | public static Il2CppFieldInfoHandle GetHandle(this FieldInfo fieldInfo) { 11 | return new Il2CppFieldInfoHandle(fieldInfo); 12 | } 13 | 14 | public static Il2CppClassHandle GetClassHandle(this Type type) { 15 | return new Il2CppClassHandle(type); 16 | } 17 | 18 | public static Il2CppTypeHandle GetTypeHandle(this Type type) { 19 | return new Il2CppTypeHandle(type); 20 | } 21 | 22 | public static unsafe Il2CppClassHandle GetClassHandleFromObject(this object obj) { 23 | return new Il2CppObjectHandle(obj).Value->klass; 24 | } 25 | 26 | public static unsafe Il2CppTypeHandle GetTypeHandleFromObject(this object obj) { 27 | return new Il2CppTypeHandle(&(new Il2CppObjectHandle(obj).Value->klass.Value->byval_arg)); 28 | } 29 | 30 | public static IntPtr AsPointer(this object obj) { 31 | return UnsafeUtility.As(ref obj); 32 | } 33 | 34 | public static Il2CppMethodInfoHandle GetHandle(this System.Reflection.MethodInfo methodInfo) { 35 | return new Il2CppMethodInfoHandle(methodInfo); 36 | } 37 | public static void* GetFunctionPointer(this System.Reflection.MethodBase methodBase) { 38 | #if Mono 39 | return methodBase.MethodHandle.GetFunctionPointer().ToPointer(); 40 | #else 41 | return (void*)methodBase.MethodHandle.Value; 42 | #endif 43 | } 44 | } 45 | 46 | 47 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Extensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09ae33365ec94fe3b4efe8f465c553d6 3 | timeCreated: 1702445983 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppAssemblyHandle.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public unsafe struct Il2CppAssemblyHandle { 3 | public Il2CppAssembly* Value; 4 | 5 | } 6 | public struct Il2CppAssembly { 7 | public Il2CppImageHandle image; 8 | public uint token; 9 | public int referencedAssemblyStart; 10 | public int referencedAssemblyCount; 11 | public Il2CppAssemblyNameHandle aname; 12 | } 13 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppAssemblyHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c8c209c545064e8db3f0ec099f4b5e9b 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppAssemblyName.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public unsafe struct Il2CppAssemblyNameHandle { 3 | public Il2CppAssemblyName* Value; 4 | } 5 | 6 | public unsafe struct Il2CppAssemblyName { 7 | public byte* name; 8 | public byte* culture; 9 | public byte* public_key; 10 | public uint hash_alg; 11 | public int hash_len; 12 | public uint flags; 13 | public int major; 14 | public int minor; 15 | public int build; 16 | public int revision; 17 | public ulong public_key_token; 18 | } 19 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppAssemblyName.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ae6a635c883409ea220205b381d1fec 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppClassHandle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | using UnityEngine; 5 | 6 | namespace UniReflection.IL2CPP { 7 | public unsafe struct Il2CppClassHandle { 8 | public Il2CppClass* Value; 9 | 10 | public Il2CppClassHandle(Type type) { 11 | this=Il2CppApi.il2cpp_class_from_type(type.GetTypeHandle()); 12 | } 13 | public Il2CppClassHandle(Il2CppTypeHandle typeHandle) { 14 | this= Il2CppApi.il2cpp_class_from_type(typeHandle); 15 | } 16 | 17 | public void Init() { 18 | Il2CppApi.il2cpp_runtime_class_init(this); 19 | } 20 | public static Il2CppClass* Alloc(int vTableSlots)=> 21 | (Il2CppClass*)Il2CppApi.il2cpp_alloc((uint) (sizeof(Il2CppClass) + sizeof(VirtualInvokeData) * vTableSlots)); 22 | 23 | public uint ActualSize => Value->actualSize; 24 | 25 | public object NewUninitialized() => Il2CppApi.il2cpp_object_new(this).SystemObject; 26 | 27 | 28 | public object New() { 29 | var o= Il2CppApi.il2cpp_object_new(this).SystemObject; 30 | foreach (var m in Methods) { 31 | if(m is { IsConstructor: true, Parameters: { Length: 0 } }) { 32 | var method = (delegate*unmanaged[Cdecl])m.Value->methodPointer; 33 | method(o); 34 | break; 35 | } 36 | } 37 | 38 | return o; 39 | } 40 | public Type SystemType=>Il2CppApi.il2cpp_class_get_type(this).SystemType; 41 | 42 | public ReadOnlySpan ImplementedInterfaces { 43 | get { 44 | var count = Value->interfaces_count; 45 | if(count==0)return ReadOnlySpan.Empty; 46 | Init(); 47 | void* interfaces = null; 48 | Il2CppApi.il2cpp_class_get_interfaces(this, ref interfaces); 49 | return new ReadOnlySpan(interfaces, Value->interfaces_count); 50 | } 51 | } 52 | 53 | public ReadOnlySpan NestedTypes { 54 | get { Init(); 55 | return new ReadOnlySpan(Value->nestedTypes, Value->nested_type_count); } 56 | } 57 | 58 | public ReadOnlySpan Fields { 59 | get { 60 | var count = Value->interfaces_count; 61 | if(count==0)return ReadOnlySpan.Empty; 62 | void* fields = null; 63 | Il2CppApi.il2cpp_class_get_fields(this, ref fields); 64 | return new ReadOnlySpan(fields, count); } 65 | } 66 | 67 | public ReadOnlySpan Methods { 68 | get { Init(); 69 | void* methods = null; 70 | Il2CppApi.il2cpp_class_get_methods(this, ref methods); 71 | return new ReadOnlySpan(methods, Value->method_count); } 72 | } 73 | 74 | public bool IsAssignableFrom(Il2CppClassHandle other) { 75 | return Il2CppApi.il2cpp_class_is_assignable_from(this, other); 76 | } 77 | 78 | public bool IsSubclassOf(Il2CppClassHandle other,bool checkInterfaces=true) { 79 | return Il2CppApi.il2cpp_class_is_subclass_of(this, other,checkInterfaces); 80 | } 81 | public NativeString Name=>Value->name; 82 | public NativeString Namespace=>Value->namespaze; 83 | 84 | public static Func CreateConstructorDelegate() { 85 | var klass=typeof(T).GetClassHandle(); 86 | if (klass.Value->byval_arg.IsValueType) { 87 | return () => default(T); 88 | } 89 | foreach (var m in klass.Methods) { 90 | if(m.IsConstructor&&m.Parameters.Length==1) { 91 | var method = (delegate*unmanaged[Cdecl])m.Value->methodPointer; 92 | return () => { 93 | var o = Il2CppApi.il2cpp_object_new(klass); 94 | var instance = UnsafeUtility.As(ref o); 95 | method(instance); 96 | return instance; 97 | }; 98 | } 99 | } 100 | return null; 101 | } 102 | public static Func CreateConstructorDelegate() { 103 | var klass=typeof(T).GetClassHandle(); 104 | foreach (var m in klass.Methods) { 105 | var parameters = m.Parameters; 106 | if(m.IsConstructor&¶meters.Length==2&¶meters[1].SystemType==typeof(TArg)) { 107 | if (!parameters[1].IsValueType) { 108 | if(!klass.Value->byval_arg.IsValueType) { 109 | var method = (delegate*unmanaged[Cdecl]) m.Value->methodPointer; 110 | return (tArg) => { 111 | var o = Il2CppApi.il2cpp_object_new(klass); 112 | var instance = UnsafeUtility.As(ref o); 113 | var arg = UnsafeUtility.As(ref tArg); 114 | method(instance, arg); 115 | return instance; 116 | }; 117 | } 118 | else { 119 | var method = (delegate*unmanaged[Cdecl]) m.Value->methodPointer; 120 | return (tArg) => { 121 | var o = default(T); 122 | var arg = UnsafeUtility.As(ref tArg); 123 | method(ref UnsafeUtility.As(ref o), arg); 124 | return o; 125 | }; 126 | } 127 | } 128 | else { 129 | if(!klass.Value->byval_arg.IsValueType) { 130 | return (tArg) => { 131 | var o = Il2CppApi.il2cpp_object_new(klass); 132 | var p=UnsafeUtility.AddressOf(ref UnsafeUtility.As(ref tArg)); 133 | m.InvokeUnsafe(o.Value, &p,null); 134 | return UnsafeUtility.As(ref o); 135 | }; 136 | } 137 | else { 138 | return (tArg) => { 139 | var o = default(T); 140 | var oPtr=UnsafeUtility.AddressOf(ref UnsafeUtility.As(ref o)); 141 | var p=UnsafeUtility.AddressOf(ref UnsafeUtility.As(ref tArg)); 142 | m.InvokeUnsafe(oPtr, &p,null); 143 | return o; 144 | }; 145 | } 146 | } 147 | 148 | } 149 | } 150 | return null; 151 | } 152 | 153 | public bool IsValueType => Value->byval_arg.IsValueType; 154 | public Il2CppClassHandle GetBaseClassHandle()=>Value->parent; 155 | public Type GetSystemType()=>Il2CppApi.il2cpp_type_get_object(new Il2CppTypeHandle(&Value->parent.Value->byval_arg)).SystemType; 156 | public struct Il2CppClass { 157 | public Il2CppImageHandle image; 158 | public void* gc_desc; 159 | public NativeString name; 160 | public NativeString namespaze; 161 | public Il2CppTypeHandle.Il2CppType byval_arg; 162 | public Il2CppTypeHandle.Il2CppType this_arg; 163 | public Il2CppClassHandle element_class; 164 | public Il2CppClassHandle castClass; 165 | public Il2CppClassHandle declaringType; 166 | public Il2CppClassHandle parent; 167 | public Il2CppGenericClassHandle generic_class; 168 | public Il2CppMetadataTypeHandle typeMetadataHandle; 169 | public void* interopData; 170 | public Il2CppClassHandle klass; 171 | // The following fields need initialized before access. This can be done per field or as an aggregate via a call to Class::Init 172 | public Il2CppFieldInfoHandle fields; 173 | public Il2CppEventInfoHandle events; 174 | public Il2CppPropertyInfoHandle properties; 175 | public Il2CppMethodInfoHandle* methods; 176 | public Il2CppClassHandle* nestedTypes; 177 | public Il2CppClassHandle* implementedInterfaces; 178 | public Il2CppRuntimeInterfaceOffsetPairHandle interfaceOffsets; 179 | public void* static_fields; 180 | public void* rgctx_data; 181 | public Il2CppClassHandle* typeHierarchy; 182 | public void* unity_user_data; 183 | #if UNITY_2023_1_OR_NEWER 184 | public Il2CppGCHandle initializationExceptionGCHandle; 185 | #else 186 | public uint initializationExceptionGCHandle; 187 | #endif 188 | public uint cctor_started; 189 | public uint cctor_finished_or_no_cctor; 190 | public IntPtr cctor_thread; 191 | public Il2CppMetadataGenericContainerHandle genericContainerHandle; 192 | public uint instance_size; 193 | public uint stack_slot_size; 194 | public uint actualSize; 195 | public uint element_size; 196 | public int native_size; 197 | public uint static_fields_size; 198 | public uint thread_static_fields_size; 199 | public int thread_static_fields_offset; 200 | public TypeAttributes flags; 201 | public uint token; 202 | public ushort method_count; 203 | public ushort property_count; 204 | public ushort field_count; 205 | public ushort event_count; 206 | public ushort nested_type_count; 207 | public ushort vtable_count; 208 | public ushort interfaces_count; 209 | public ushort interface_offsets_count; 210 | public byte typeHierarchyDepth; 211 | public byte genericRecursionDepth; 212 | public byte rank; 213 | public byte minimumAlignment; 214 | public byte packingSize; 215 | public Bitfield0 _bitfield0; 216 | public Bitfield1 _bitfield1; 217 | [Flags] 218 | public enum Bitfield0 : byte 219 | { 220 | BIT_initialized_and_no_error = 0, 221 | initialized_and_no_error = (1 << BIT_initialized_and_no_error), 222 | BIT_initialized = 1, 223 | initialized = (1 << BIT_initialized), 224 | BIT_enumtype = 2, 225 | enumtype = (1 << BIT_enumtype), 226 | BIT_nullabletype = 3, 227 | nullabletype = (1 << BIT_nullabletype), 228 | BIT_is_generic = 4, 229 | is_generic = (1 << BIT_is_generic), 230 | BIT_has_references = 5, 231 | has_references = (1 << BIT_has_references), 232 | BIT_init_pending = 6, 233 | init_pending = (1 << BIT_init_pending), 234 | BIT_size_init_pending = 7, 235 | size_init_pending = (1 << BIT_size_init_pending), 236 | } 237 | 238 | public enum Bitfield1 : byte 239 | { 240 | BIT_size_inited = 0, 241 | size_inited = (1 << BIT_size_inited), 242 | BIT_has_finalize = 1, 243 | has_finalize = (1 << BIT_has_finalize), 244 | BIT_has_cctor = 2, 245 | has_cctor = (1 << BIT_has_cctor), 246 | BIT_is_blittable = 3, 247 | is_blittable = (1 << BIT_is_blittable), 248 | BIT_is_import_or_windows_runtime = 4, 249 | is_import_or_windows_runtime = (1 << BIT_is_import_or_windows_runtime), 250 | BIT_is_vtable_initialized = 5, 251 | is_vtable_initialized = (1 << BIT_is_vtable_initialized), 252 | BIT_is_byref_like = 6, 253 | is_byref_like = (1 << BIT_is_byref_like), 254 | } 255 | } 256 | } 257 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppClassHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ad81242f8994daf86c250d8ba3cf8bb 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppCustomAttrInfoHandle.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public unsafe struct Il2CppCustomAttrInfoHandle { 3 | public Il2CppCustomAttrInfo* Value; 4 | 5 | public struct Il2CppCustomAttrInfo { 6 | 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppCustomAttrInfoHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 20425abca4024cb19d24794de1755cad 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppEventInfoHandle.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public unsafe struct Il2CppEventInfoHandle { 3 | public EventInfo* Value; 4 | public struct EventInfo { 5 | public NativeString name; 6 | public Il2CppTypeHandle eventType; 7 | public Il2CppClassHandle parent; 8 | public Il2CppMethodInfoHandle add; 9 | public Il2CppMethodInfoHandle remove; 10 | public Il2CppMethodInfoHandle raise; 11 | public uint token; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppEventInfoHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3b209337a3e46bbb51f41db10f76279 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppFieldInfoHandle.cs: -------------------------------------------------------------------------------- 1 |  2 | using System; 3 | using System.Reflection; 4 | using Unity.Collections.LowLevel.Unsafe; 5 | 6 | namespace UniReflection.IL2CPP { 7 | public unsafe struct Il2CppFieldInfoHandle { 8 | public FieldInfo* Value; 9 | 10 | public Il2CppFieldInfoHandle(System.Reflection.FieldInfo fieldInfo) { 11 | Value =(FieldInfo*) fieldInfo.FieldHandle.Value; 12 | } 13 | 14 | public int Offset=>Value->offset; 15 | 16 | public bool IsThreadStatic=>Value->offset==-1; 17 | 18 | public bool IsStatic=> ((FieldAttributes) (Value->type.Value->attrs) & FieldAttributes.Static)!=0; 19 | 20 | public bool IsPublic=> ((FieldAttributes) (Value->type.Value->attrs) & FieldAttributes.Public)!=0; 21 | public void SetValueUnsafe(object obj,void* value) { 22 | Il2CppApi.il2cpp_field_set_value(new Il2CppObjectHandle(obj),this,value); 23 | } 24 | public void SetValueUnsafe(object obj,object value) { 25 | var valueHandle = new Il2CppObjectHandle(value); 26 | Il2CppApi.il2cpp_field_set_value_object(new Il2CppObjectHandle(obj),this,valueHandle); 27 | } 28 | public void SetValue(object obj,object value) { 29 | var valueHandle = new Il2CppObjectHandle(value); 30 | if (Value->type.IsValueType) { 31 | if(Value->type.Value== (&valueHandle.Value->klass.Value->this_arg)) { 32 | Il2CppApi.il2cpp_field_set_value(new Il2CppObjectHandle(obj),this,Il2CppApi.il2cpp_object_unbox(valueHandle)); 33 | } 34 | else { 35 | throw new Exception(); 36 | } 37 | }else { 38 | if (Value->type.ClassHandle.IsAssignableFrom(valueHandle.Value->klass)) { 39 | Il2CppApi.il2cpp_field_set_value_object(new Il2CppObjectHandle(obj),this,valueHandle); 40 | } 41 | else { 42 | throw new Exception(); 43 | } 44 | 45 | } 46 | 47 | } 48 | 49 | public void SetStaticValue(void* value) { 50 | Il2CppApi.il2cpp_field_static_set_value(this,value); 51 | } 52 | public void GetValue(object obj,void* value) { 53 | Il2CppApi.il2cpp_field_get_value(new Il2CppObjectHandle(obj),this,value); 54 | } 55 | public void GetStaticValue(void* value) { 56 | Il2CppApi.il2cpp_field_static_get_value(this,value); 57 | } 58 | public Il2CppClassHandle Parent=>Value->parent; 59 | public Il2CppTypeHandle Type=>Value->type; 60 | public struct FieldInfo { 61 | public NativeString name; 62 | public Il2CppTypeHandle type; 63 | public Il2CppClassHandle parent; 64 | public int offset; 65 | public uint token; 66 | public FieldAttributes Attributes =>(FieldAttributes) type.Value->attrs ; 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppFieldInfoHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ebf3c614b9b6456d899ed61490d006ee 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppGenericClassHandle.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public unsafe struct Il2CppGenericClassHandle { 3 | public Il2CppGenericClass* Value; 4 | public struct Il2CppGenericClass { 5 | 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppGenericClassHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 011948e0a9d044bd8d22cf11c82ccc70 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppImageHandle.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public unsafe struct Il2CppImageHandle { 3 | public Il2CppImage* Value; 4 | public struct Il2CppImage { 5 | public NativeString name; 6 | public NativeString nameNoExt; 7 | public Il2CppAssemblyHandle assembly; 8 | public uint typeCount; 9 | public uint exportedTypeCount; 10 | public uint customAttributeCount; 11 | public Il2CppMetadataImageHandle metadataHandle; 12 | public void* nameToClassHashTable; 13 | public void* codeGenModule; 14 | public uint token; 15 | public byte dynamic; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppImageHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aaaf63f2e7b046119db17cc385753987 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppMetadataGenericContainerHandle.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public unsafe struct Il2CppMetadataGenericContainerHandle { 3 | public void* Value; 4 | } 5 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppMetadataGenericContainerHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 950115cf267a4af3a688dfbaa1c2e132 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppMetadataImageHandle.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public struct Il2CppMetadataImageHandle { 3 | private readonly unsafe void* dummy; 4 | } 5 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppMetadataImageHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 349e7d5b34ff48b6af4f5be9fdd68c54 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppMetadataTypeHandle.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public unsafe struct Il2CppMetadataTypeHandle { 3 | public void* Value; 4 | } 5 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppMetadataTypeHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae80cf559f144b178987744a018abe90 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppMethodHandle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using Unity.Collections.LowLevel.Unsafe; 5 | 6 | namespace UniReflection.IL2CPP { 7 | public unsafe struct VirtualInvokeData 8 | { 9 | public IntPtr methodPtr; 10 | public Il2CppMethodInfoHandle method; 11 | } 12 | public unsafe struct Il2CppMethodInfoHandle { 13 | public MethodInfo* Value; 14 | 15 | public Il2CppMethodInfoHandle(IntPtr value) { 16 | Value = (MethodInfo*)value; 17 | } 18 | public Il2CppMethodInfoHandle(MethodBase methodBase) { 19 | Value = (MethodInfo*)methodBase.MethodHandle.Value; 20 | } 21 | 22 | public object Invoke(void* obj, void** args, out Exception ex) { 23 | return Il2CppApi.il2cpp_runtime_invoke(Value, obj, args, out ex); 24 | } 25 | public object InvokeConvertArgs(object obj, Span args, out Exception ex) { 26 | var objPtr=(void*) UnsafeUtility.As(ref obj); 27 | if (args.IsEmpty) { 28 | return Il2CppApi.il2cpp_runtime_invoke_convert_args(Value, objPtr, null,0, out ex); 29 | } 30 | else { 31 | return Il2CppApi.il2cpp_runtime_invoke_convert_args(Value, objPtr, (void**)UnsafeUtility.AddressOf(ref UnsafeUtility.As( 32 | ref args[0])),args.Length, out ex); 33 | } 34 | 35 | } 36 | public object InvokeConvertArgs( void* obj, void** param, 37 | int paramCount, out Exception exc) { 38 | return Il2CppApi.il2cpp_runtime_invoke_convert_args(Value, obj, param, paramCount, out exc); 39 | } 40 | /// 41 | /// Invoke without any check. 42 | /// If obj or args is value type, you should pass the address of the value. 43 | /// If obj or args is reference (e.g. class, ref), you should pass the reference it's self. 44 | /// 45 | /// Invoke Instance reference 46 | /// Invoke argument references 47 | /// return target reference 48 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 49 | public void InvokeUnsafe(void* obj, void** args, void* returnValue) { 50 | Value->invoker_method(Value->methodPointer, Value, obj, args, returnValue); 51 | } 52 | 53 | public MethodAttributes Attributes { 54 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 55 | get => (MethodAttributes) Value->flags; 56 | } 57 | 58 | public bool IsAbstract => (uint) (this.Attributes & MethodAttributes.Abstract) > 0U; 59 | 60 | public bool IsConstructor => !this.IsStatic && 61 | (this.Attributes & MethodAttributes.RTSpecialName) == 62 | MethodAttributes.RTSpecialName; 63 | 64 | public bool IsFinal => (uint) (this.Attributes & MethodAttributes.Final) > 0U; 65 | 66 | public bool IsHideBySig => (uint) (this.Attributes & MethodAttributes.HideBySig) > 0U; 67 | 68 | public bool IsSpecialName => (uint) (this.Attributes & MethodAttributes.SpecialName) > 0U; 69 | 70 | public bool IsStatic { 71 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 72 | get => (uint) (this.Attributes & MethodAttributes.Static) > 0U; 73 | } 74 | 75 | public bool IsVirtual => (uint) (this.Attributes & MethodAttributes.Virtual) > 0U; 76 | 77 | public bool IsAssembly => (this.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assembly; 78 | 79 | public bool IsFamily => (this.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Family; 80 | 81 | public bool IsFamilyAndAssembly => 82 | (this.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamANDAssem; 83 | 84 | public bool IsFamilyOrAssembly => 85 | (this.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamORAssem; 86 | 87 | public bool IsPrivate => (this.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; 88 | 89 | public bool IsPublic => (this.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; 90 | public byte ParametersCount => Value->parameters_count; 91 | 92 | public bool IsGenericMethod => (Value->_bitfield0 & MethodInfo.Bitfield0.is_generic) != 0; 93 | public bool IsInflated => (Value->_bitfield0 & MethodInfo.Bitfield0.is_inflated) != 0; 94 | public bool IsWrapperType => (Value->_bitfield0 & MethodInfo.Bitfield0.wrapper_type) != 0; 95 | public bool HasFullRangeGenericParameters => (Value->_bitfield0 & MethodInfo.Bitfield0.has_full_generic_sharing_signature) != 0; 96 | 97 | public ReadOnlySpan Parameters { 98 | get { 99 | var span = new ReadOnlySpan(Value->parameters, ParametersCount); 100 | return span; 101 | } 102 | } 103 | public Il2CppTypeHandle ReturnType => Value->return_type; 104 | public Il2CppClassHandle DeclaringType => Value->klass; 105 | 106 | public void *MethodPointer { 107 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 108 | get=> Value->methodPointer; 109 | } 110 | public unsafe struct MethodInfo { 111 | public void* methodPointer; 112 | public void* virtualMethodPointer; 113 | public delegate*unmanaged[Cdecl] invoker_method; 114 | public NativeString name; 115 | public Il2CppClassHandle klass; 116 | public Il2CppTypeHandle return_type; 117 | public Il2CppTypeHandle* parameters; 118 | public void* runtime_data; 119 | public void* generic_data; 120 | public uint token; 121 | public ushort flags; 122 | public ushort iflags; 123 | public ushort slot; 124 | public byte parameters_count; 125 | public Bitfield0 _bitfield0; 126 | [Flags] 127 | 128 | public enum Bitfield0 : byte { 129 | BIT_is_generic = 0, 130 | is_generic = (1 << BIT_is_generic), 131 | BIT_is_inflated = 1, 132 | is_inflated = (1 << BIT_is_inflated), 133 | BIT_wrapper_type = 2, 134 | wrapper_type = (1 << BIT_wrapper_type), 135 | BIT_has_full_generic_sharing_signature = 3, 136 | has_full_generic_sharing_signature = (1 << BIT_has_full_generic_sharing_signature), 137 | #if UNITY_2023_2_OR_NEWER 138 | BIT_is_unmanaged_callers_only = 4, 139 | is_unmanaged_callers_only = (1 << BIT_is_unmanaged_callers_only), 140 | #endif 141 | } 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppMethodHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d8953389fd94f4e8b45a7dd159dfa35 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Unity.Collections.LowLevel.Unsafe; 5 | 6 | namespace UniReflection.IL2CPP { 7 | public unsafe struct Il2CppObjectHandle { 8 | public Il2CppObject* Value; 9 | 10 | public Il2CppObjectHandle(Il2CppObject* value) { 11 | Value = value; 12 | } 13 | 14 | public Il2CppObjectHandle(object o) { 15 | Value = (Il2CppObject*) o.AsPointer(); 16 | } 17 | 18 | public object SystemObject { 19 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 20 | get => Unsafe.As(ref this); 21 | } 22 | 23 | public override string ToString() => SystemObject.ToString(); 24 | } 25 | 26 | 27 | public unsafe struct Il2CppObject { 28 | public Il2CppClassHandle klass; 29 | MonitorData* monitor; 30 | } 31 | 32 | public struct MonitorData { 33 | } 34 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0df6416978fc495aaaaeafb68017dc7b 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppPropertyInfoHandle.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public unsafe struct Il2CppPropertyInfoHandle { 3 | public PropertyInfo* Value; 4 | public struct PropertyInfo { 5 | public Il2CppClassHandle parent; 6 | public NativeString name; 7 | public Il2CppMethodInfoHandle get; 8 | public Il2CppMethodInfoHandle set; 9 | public uint attrs; 10 | public uint token; 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppPropertyInfoHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e89a1523f654b24bea501e5eb117e3e 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppReflectionTypeHandle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Collections.LowLevel.Unsafe; 3 | 4 | namespace UniReflection.IL2CPP { 5 | public unsafe struct Il2CppReflectionTypeHandle { 6 | public Il2CppReflectionType* Value; 7 | public Il2CppReflectionTypeHandle(Type type) { 8 | Value = (Il2CppReflectionType*) UnsafeUtility.As(ref type); 9 | } 10 | 11 | public Type SystemType { 12 | get { 13 | var p = (IntPtr*) UnsafeUtility.AddressOf(ref this); 14 | return UnsafeUtility.As(ref p[0]); 15 | } 16 | } 17 | public static implicit operator Il2CppReflectionTypeHandle(Type type) => new Il2CppReflectionTypeHandle(type); 18 | public static explicit operator Type(Il2CppReflectionTypeHandle type) => type.SystemType; 19 | public override string ToString() => SystemType.ToString(); 20 | public struct Il2CppReflectionType 21 | { 22 | public Il2CppObject o; 23 | public Il2CppTypeHandle type; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppReflectionTypeHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f88f4a523ed4cb2a4bca199133f007a 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppRuntimeInterfaceOffsetPairHandle.cs: -------------------------------------------------------------------------------- 1 | namespace UniReflection.IL2CPP { 2 | public unsafe struct Il2CppRuntimeInterfaceOffsetPairHandle { 3 | public Il2CppRuntimeInterfaceOffsetPair* Value; 4 | public struct Il2CppRuntimeInterfaceOffsetPair { 5 | 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppRuntimeInterfaceOffsetPairHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9d4569769c64275a7c2d751b8d485f2 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppString.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | 5 | namespace UniReflection.IL2CPP { 6 | 7 | 8 | public unsafe struct Il2CppStringHandle { 9 | public Il2CppString* Value; 10 | 11 | public Il2CppStringHandle(Il2CppString* value) { 12 | Value = value; 13 | } 14 | 15 | public Il2CppStringHandle(string str) { 16 | Value = (Il2CppString*) UnsafeUtility.As(ref str); 17 | } 18 | 19 | public string SystemString { 20 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 21 | get => Unsafe.As(ref this); 22 | 23 | } 24 | public static implicit operator Il2CppStringHandle(string str) => new Il2CppStringHandle(str); 25 | public override string ToString() => SystemString; 26 | } 27 | 28 | 29 | 30 | public unsafe struct Il2CppString { 31 | public Il2CppObject Object; 32 | public int length; 33 | public char* chars; 34 | } 35 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppString.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e6e0aae8de7432a98185a96e9e2f0dd 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppTypeHandle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UniReflection.IL2CPP { 4 | public readonly unsafe struct Il2CppTypeHandle { 5 | public readonly Il2CppType* Value; 6 | 7 | public Il2CppTypeHandle(Type type) { 8 | Value = (Il2CppType*)type.TypeHandle.Value; 9 | } 10 | public Il2CppTypeHandle(Il2CppType* value) { 11 | Value = value; 12 | } 13 | public Type SystemType=>Il2CppApi.il2cpp_type_get_object(this).SystemType; 14 | public Il2CppClassHandle ClassHandle=>Il2CppApi.il2cpp_class_from_type(this); 15 | 16 | public bool IsByRef => (Value->_bitfield0 & Il2CppType.Bitfield0.byref) != 0; 17 | public bool IsValueType => (Value->_bitfield0 & Il2CppType.Bitfield0.valuetype) != 0; 18 | public bool IsRefOrByRef => IsByRef || !IsValueType; 19 | public bool IsVoid => Value->type ==Il2CppTypeEnum.IL2CPP_TYPE_VOID; 20 | public bool IsPinned => (Value->_bitfield0 & Il2CppType.Bitfield0.pinned) != 0; 21 | public Il2CppTypeEnum TypeEnum => Value->type; 22 | 23 | 24 | public unsafe struct Il2CppType { 25 | public void* data; 26 | public ushort attrs; 27 | public Il2CppTypeEnum type; 28 | public Bitfield0 _bitfield0; 29 | 30 | [Flags] 31 | public enum Bitfield0 : byte { 32 | byref = (1 << 5), 33 | pinned = (1 << 6), 34 | valuetype = (1 << 7), 35 | } 36 | 37 | public bool IsByRef => (_bitfield0 & Bitfield0.byref) != 0; 38 | public bool IsValueType => (_bitfield0 & Bitfield0.valuetype) != 0; 39 | public bool IsRefOrByRef => IsByRef || IsValueType; 40 | public bool IsVoid => type ==Il2CppTypeEnum.IL2CPP_TYPE_VOID; 41 | } 42 | } 43 | 44 | 45 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2CppTypeHandle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 875395ba81894db38c47c4ba36a4284f 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/Il2cppApi.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d9ed19df0444e7e9ac7fe7fded3ca24 3 | timeCreated: 1702445684 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/MarshaledString.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace UniReflection.IL2CPP 5 | { 6 | public unsafe struct MarshaledString:IDisposable { 7 | public override bool Equals(object obj) { 8 | return obj is MarshaledString other && Equals(other); 9 | } 10 | 11 | public override int GetHashCode() { 12 | return unchecked((int) (long) Chars); 13 | } 14 | 15 | public byte* Chars; 16 | public MarshaledString(string str) { 17 | Chars=(byte*)Marshal.StringToHGlobalAnsi(str); 18 | } 19 | public NativeString AsNativeString() => new NativeString(Chars); 20 | public static bool operator ==(MarshaledString a, MarshaledString b) => a.Equals(b); 21 | public static bool operator !=(MarshaledString a, MarshaledString b) => !a.Equals(b); 22 | public static bool operator ==(MarshaledString a, NativeString b) => a.Equals(b); 23 | public static bool operator !=(MarshaledString a, NativeString b) => !a.Equals(b); 24 | 25 | public bool Equals(NativeString other) => NativeString.AnsiEquals(Chars,other.Chars); 26 | public bool Equals(MarshaledString other) => NativeString.AnsiEquals(Chars,other.Chars); 27 | public void Dispose() { 28 | if(Chars==null) return; 29 | Marshal.FreeHGlobal((IntPtr)Chars); 30 | Chars = null; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/MarshaledString.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00d370ddf4364a7c917cb0844b41e365 3 | timeCreated: 1703400732 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/NativeString.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Text; 4 | using Unity.Collections.LowLevel.Unsafe; 5 | 6 | namespace UniReflection.IL2CPP { 7 | public unsafe struct NativeString { 8 | public override bool Equals(object obj) { 9 | return obj is NativeString other && Equals(other); 10 | } 11 | 12 | public override int GetHashCode() { 13 | return unchecked((int) (long) Chars); 14 | } 15 | 16 | public byte* Chars; 17 | public NativeString(IntPtr str) { 18 | Chars=(byte*)str; 19 | } 20 | public NativeString(byte* str) { 21 | Chars=str; 22 | } 23 | public override string ToString() { 24 | if(Chars==null||Chars[0]==0) return ""; 25 | return Marshal.PtrToStringAnsi((IntPtr) Chars); 26 | } 27 | 28 | public static explicit operator string(NativeString str) => str.ToString(); 29 | public static bool operator ==(NativeString a, NativeString b) => a.Equals(b); 30 | public static bool operator !=(NativeString a, NativeString b) => !a.Equals(b); 31 | public static bool operator ==(NativeString a, MarshaledString b) => a.Equals(b); 32 | public static bool operator !=(NativeString a, MarshaledString b) => !a.Equals(b); 33 | 34 | public static bool AnsiEquals(byte* a, byte* b) { 35 | 36 | if(a==b) return true; 37 | if(a==null||b==null) return false; 38 | while ((*a & *b)!=0) { 39 | if(*a++!=*b++)return false; 40 | } 41 | return true; 42 | } 43 | public bool Equals(NativeString other) => AnsiEquals(Chars,other.Chars); 44 | public bool Equals(MarshaledString other) => AnsiEquals(Chars,other.Chars); 45 | 46 | 47 | } 48 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/NativeString.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce653f765a5c4ae4813d4531cc176a74 3 | timeCreated: 1702445778 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/UniReflection.IL2CPP.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniReflection.IL2CPP", 3 | "rootNamespace": "UniReflection.IL2CPP", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": true, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [], 13 | "noEngineReferences": false 14 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/IL2CPP/UniReflection.IL2CPP.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91e66e2e63b788444bb2dab4b253479b 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UniReflection.IL2CPP; 3 | 4 | namespace UniReflection 5 | { 6 | public unsafe struct InstanceAction: IDisposable 7 | { 8 | private PinnedObject pinnedObject; 9 | public PinnedObject Object=>pinnedObject; 10 | 11 | #if Mono 12 | delegate* unmanaged[Cdecl] functionPointer; 13 | #else 14 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 15 | #endif 16 | public InstanceAction(Action action) 17 | 18 | { 19 | pinnedObject =new(action.Target); 20 | #if Mono 21 | functionPointer = (delegate*unmanaged[Cdecl] )action.Method.MethodHandle.GetFunctionPointer(); 22 | #else 23 | methodInfoHandle =new (action.Method) ; 24 | #endif 25 | } 26 | 27 | public readonly void Invoke() 28 | { 29 | #if Mono 30 | functionPointer(Object.ObjectPointer); 31 | #else 32 | ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer, methodInfoHandle); 33 | #endif 34 | } 35 | public void Dispose() 36 | { 37 | pinnedObject.Dispose(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceAction.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 840c93878c6c4c80b6cd7fd914e57e1a 3 | timeCreated: 1703400757 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceActions.cs: -------------------------------------------------------------------------------- 1 |  2 | #if UNITY_EDITOR ||!ENABLE_IL2CPP 3 | #define Mono 4 | #else 5 | using UniReflection.IL2CPP; 6 | #endif 7 | using System; 8 | 9 | namespace UniReflection 10 | { 11 | public unsafe struct InstanceAction: IDisposable 12 | { 13 | private PinnedObject pinnedObject; 14 | public PinnedObject Object=>pinnedObject; 15 | #if Mono 16 | private readonly delegate* unmanaged[Cdecl] functionPointer; 17 | 18 | public InstanceAction(Action action) 19 | 20 | { 21 | pinnedObject =new(action.Target); 22 | functionPointer = (delegate*unmanaged[Cdecl] )action.Method.MethodHandle.GetFunctionPointer(); 23 | } 24 | 25 | public readonly void Invoke(T0 t0) 26 | { 27 | functionPointer(pinnedObject.ObjectPointer,t0); 28 | } 29 | #else 30 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 31 | 32 | public InstanceAction(Action action) 33 | 34 | { 35 | pinnedObject =new(action.Target); 36 | methodInfoHandle =new (action.Method) ; 37 | } 38 | 39 | public readonly void Invoke(T0 t0) 40 | { 41 | ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0, methodInfoHandle); 42 | } 43 | #endif 44 | public void Dispose() 45 | { 46 | pinnedObject.Dispose(); 47 | } 48 | } 49 | public unsafe struct InstanceAction: IDisposable 50 | { 51 | private PinnedObject pinnedObject; 52 | public PinnedObject Object=>pinnedObject; 53 | #if Mono 54 | private readonly delegate* unmanaged[Cdecl] functionPointer; 55 | 56 | public InstanceAction(Action action) 57 | 58 | { 59 | pinnedObject =new(action.Target); 60 | functionPointer = (delegate*unmanaged[Cdecl] )action.Method.MethodHandle.GetFunctionPointer(); 61 | } 62 | 63 | public readonly void Invoke(T0 t0,T1 t1) 64 | { 65 | functionPointer(pinnedObject.ObjectPointer,t0,t1); 66 | } 67 | #else 68 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 69 | 70 | public InstanceAction(Action action) 71 | 72 | { 73 | pinnedObject =new(action.Target); 74 | methodInfoHandle =new (action.Method) ; 75 | } 76 | 77 | public readonly void Invoke(T0 t0,T1 t1) 78 | { 79 | ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1, methodInfoHandle); 80 | } 81 | #endif 82 | public void Dispose() 83 | { 84 | pinnedObject.Dispose(); 85 | } 86 | } 87 | public unsafe struct InstanceAction: IDisposable 88 | { 89 | private PinnedObject pinnedObject; 90 | public PinnedObject Object=>pinnedObject; 91 | #if Mono 92 | private readonly delegate* unmanaged[Cdecl] functionPointer; 93 | 94 | public InstanceAction(Action action) 95 | 96 | { 97 | pinnedObject =new(action.Target); 98 | functionPointer = (delegate*unmanaged[Cdecl] )action.Method.MethodHandle.GetFunctionPointer(); 99 | } 100 | 101 | public readonly void Invoke(T0 t0,T1 t1,T2 t2) 102 | { 103 | functionPointer(pinnedObject.ObjectPointer,t0,t1,t2); 104 | } 105 | #else 106 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 107 | 108 | public InstanceAction(Action action) 109 | 110 | { 111 | pinnedObject =new(action.Target); 112 | methodInfoHandle =new (action.Method) ; 113 | } 114 | 115 | public readonly void Invoke(T0 t0,T1 t1,T2 t2) 116 | { 117 | ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1,t2, methodInfoHandle); 118 | } 119 | #endif 120 | public void Dispose() 121 | { 122 | pinnedObject.Dispose(); 123 | } 124 | } 125 | public unsafe struct InstanceAction: IDisposable 126 | { 127 | private PinnedObject pinnedObject; 128 | public PinnedObject Object=>pinnedObject; 129 | #if Mono 130 | private readonly delegate* unmanaged[Cdecl] functionPointer; 131 | 132 | public InstanceAction(Action action) 133 | 134 | { 135 | pinnedObject =new(action.Target); 136 | functionPointer = (delegate*unmanaged[Cdecl] )action.Method.MethodHandle.GetFunctionPointer(); 137 | } 138 | 139 | public readonly void Invoke(T0 t0,T1 t1,T2 t2,T3 t3) 140 | { 141 | functionPointer(pinnedObject.ObjectPointer,t0,t1,t2,t3); 142 | } 143 | #else 144 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 145 | 146 | public InstanceAction(Action action) 147 | 148 | { 149 | pinnedObject =new(action.Target); 150 | methodInfoHandle =new (action.Method) ; 151 | } 152 | 153 | public readonly void Invoke(T0 t0,T1 t1,T2 t2,T3 t3) 154 | { 155 | ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1,t2,t3, methodInfoHandle); 156 | } 157 | #endif 158 | public void Dispose() 159 | { 160 | pinnedObject.Dispose(); 161 | } 162 | } 163 | public unsafe struct InstanceAction: IDisposable 164 | { 165 | private PinnedObject pinnedObject; 166 | public PinnedObject Object=>pinnedObject; 167 | #if Mono 168 | private readonly delegate* unmanaged[Cdecl] functionPointer; 169 | 170 | public InstanceAction(Action action) 171 | 172 | { 173 | pinnedObject =new(action.Target); 174 | functionPointer = (delegate*unmanaged[Cdecl] )action.Method.MethodHandle.GetFunctionPointer(); 175 | } 176 | 177 | public readonly void Invoke(T0 t0,T1 t1,T2 t2,T3 t3,T4 t4) 178 | { 179 | functionPointer(pinnedObject.ObjectPointer,t0,t1,t2,t3,t4); 180 | } 181 | #else 182 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 183 | 184 | public InstanceAction(Action action) 185 | 186 | { 187 | pinnedObject =new(action.Target); 188 | methodInfoHandle =new (action.Method) ; 189 | } 190 | 191 | public readonly void Invoke(T0 t0,T1 t1,T2 t2,T3 t3,T4 t4) 192 | { 193 | ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1,t2,t3,t4, methodInfoHandle); 194 | } 195 | #endif 196 | public void Dispose() 197 | { 198 | pinnedObject.Dispose(); 199 | } 200 | } 201 | public unsafe struct InstanceAction: IDisposable 202 | { 203 | private PinnedObject pinnedObject; 204 | public PinnedObject Object=>pinnedObject; 205 | #if Mono 206 | private readonly delegate* unmanaged[Cdecl] functionPointer; 207 | 208 | public InstanceAction(Action action) 209 | 210 | { 211 | pinnedObject =new(action.Target); 212 | functionPointer = (delegate*unmanaged[Cdecl] )action.Method.MethodHandle.GetFunctionPointer(); 213 | } 214 | 215 | public readonly void Invoke(T0 t0,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5) 216 | { 217 | functionPointer(pinnedObject.ObjectPointer,t0,t1,t2,t3,t4,t5); 218 | } 219 | #else 220 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 221 | 222 | public InstanceAction(Action action) 223 | 224 | { 225 | pinnedObject =new(action.Target); 226 | methodInfoHandle =new (action.Method) ; 227 | } 228 | 229 | public readonly void Invoke(T0 t0,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5) 230 | { 231 | ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1,t2,t3,t4,t5, methodInfoHandle); 232 | } 233 | #endif 234 | public void Dispose() 235 | { 236 | pinnedObject.Dispose(); 237 | } 238 | } 239 | public unsafe struct InstanceAction: IDisposable 240 | { 241 | private PinnedObject pinnedObject; 242 | public PinnedObject Object=>pinnedObject; 243 | #if Mono 244 | private readonly delegate* unmanaged[Cdecl] functionPointer; 245 | 246 | public InstanceAction(Action action) 247 | 248 | { 249 | pinnedObject =new(action.Target); 250 | functionPointer = (delegate*unmanaged[Cdecl] )action.Method.MethodHandle.GetFunctionPointer(); 251 | } 252 | 253 | public readonly void Invoke(T0 t0,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5,T6 t6) 254 | { 255 | functionPointer(pinnedObject.ObjectPointer,t0,t1,t2,t3,t4,t5,t6); 256 | } 257 | #else 258 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 259 | 260 | public InstanceAction(Action action) 261 | 262 | { 263 | pinnedObject =new(action.Target); 264 | methodInfoHandle =new (action.Method) ; 265 | } 266 | 267 | public readonly void Invoke(T0 t0,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5,T6 t6) 268 | { 269 | ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1,t2,t3,t4,t5,t6, methodInfoHandle); 270 | } 271 | #endif 272 | public void Dispose() 273 | { 274 | pinnedObject.Dispose(); 275 | } 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceActions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e06b07c04ae2ca468668b8d94bf28ff 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceActions.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ import namespace="System.Linq" #> 3 | <#@ output extension="cs"#> 4 | <# 5 | string CreateGenericTypes(int start, int count) 6 | => string.Join(",", Enumerable.Range(start, count).Select(i => $"T{i}")); 7 | 8 | string CreateParameters(int start, int count) 9 | => string.Join(",", Enumerable.Range(start, count).Select(i => $"T{i} t{i}")); 10 | string CreateArguments(int start, int count) 11 | => string.Join(",", Enumerable.Range(start, count).Select(i => $"t{i}")); 12 | #> 13 | 14 | #if UNITY_EDITOR ||!ENABLE_IL2CPP 15 | #define Mono 16 | #else 17 | using UniReflection.IL2CPP; 18 | #endif 19 | using System; 20 | 21 | namespace UniReflection 22 | { 23 | <# for(var i =1;i<8;i++) { 24 | var genericTypes = CreateGenericTypes(0, i); 25 | var parameters = CreateParameters(0, i); 26 | var arguments = CreateArguments(0, i);#> 27 | public unsafe struct InstanceAction<<#=genericTypes#>>: IDisposable 28 | { 29 | private PinnedObject pinnedObject; 30 | public PinnedObject Object=>pinnedObject; 31 | #if Mono 32 | private readonly delegate* unmanaged[Cdecl],void> functionPointer; 33 | 34 | public InstanceAction(Action<<#=genericTypes#>> action) 35 | 36 | { 37 | pinnedObject =new(action.Target); 38 | functionPointer = (delegate*unmanaged[Cdecl],void> )action.Method.MethodHandle.GetFunctionPointer(); 39 | } 40 | 41 | public readonly void Invoke(<#=parameters#>) 42 | { 43 | functionPointer(pinnedObject.ObjectPointer,<#=arguments#>); 44 | } 45 | #else 46 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 47 | 48 | public InstanceAction(Action<<#=genericTypes#>> action) 49 | 50 | { 51 | pinnedObject =new(action.Target); 52 | methodInfoHandle =new (action.Method) ; 53 | } 54 | 55 | public readonly void Invoke(<#=parameters#>) 56 | { 57 | ((delegate* unmanaged[Cdecl],Il2CppMethodInfoHandle, void>)methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,<#=arguments#>, methodInfoHandle); 58 | } 59 | #endif 60 | public void Dispose() 61 | { 62 | pinnedObject.Dispose(); 63 | } 64 | } 65 | <# } #> 66 | } 67 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceActions.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5411be45f464766994f8fd02c4fc787 3 | timeCreated: 1703401617 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceFunc.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR ||!ENABLE_IL2CPP 2 | #define Mono 3 | #else 4 | using UniReflection.IL2CPP; 5 | #endif 6 | using System; 7 | 8 | namespace UniReflection 9 | { 10 | public unsafe struct InstanceFunc : IDisposable 11 | { 12 | private PinnedObject pinnedObject; 13 | public PinnedObject Object=>pinnedObject; 14 | #if Mono 15 | private readonly delegate* unmanaged[Cdecl] functionPointer; 16 | 17 | public InstanceFunc(Func func) 18 | 19 | { 20 | pinnedObject = new(func.Target); 21 | functionPointer = (delegate*unmanaged[Cdecl])func.Method.MethodHandle.GetFunctionPointer(); 22 | } 23 | 24 | public readonly T Invoke() 25 | { 26 | return functionPointer(pinnedObject.ObjectPointer); 27 | } 28 | #else 29 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 30 | 31 | public InstanceFunc(Func func) 32 | 33 | { 34 | pinnedObject = new(func.Target); 35 | methodInfoHandle = new (func.Method) ; 36 | } 37 | 38 | public readonly T Invoke() 39 | { 40 | return ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer, methodInfoHandle); 41 | } 42 | #endif 43 | public void Dispose() 44 | { 45 | pinnedObject.Dispose(); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceFunc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00d33ec3fea64e56b0b5362576c9a400 3 | timeCreated: 1703402236 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceFuncs.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR ||!ENABLE_IL2CPP 2 | #define Mono 3 | #else 4 | using UniReflection.IL2CPP; 5 | #endif 6 | using System; 7 | 8 | namespace UniReflection 9 | { 10 | public unsafe struct InstanceFunc : IDisposable 11 | { 12 | private PinnedObject pinnedObject; 13 | public PinnedObject Object=>pinnedObject; 14 | #if Mono 15 | private readonly delegate* unmanaged[Cdecl] functionPointer; 16 | 17 | public InstanceFunc(Func func) 18 | 19 | { 20 | pinnedObject = new(func.Target); 21 | functionPointer = 22 | (delegate*unmanaged[Cdecl])func.Method.MethodHandle.GetFunctionPointer(); 23 | } 24 | 25 | public readonly TRet Invoke(T0 t0) 26 | { 27 | return functionPointer(pinnedObject.ObjectPointer, t0); 28 | } 29 | #else 30 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 31 | 32 | public InstanceFunc(Func func) 33 | 34 | { 35 | pinnedObject = new(func.Target); 36 | methodInfoHandle = new (func.Method) ; 37 | } 38 | 39 | public readonly TRet Invoke(T0 t0) 40 | { 41 | return ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0, methodInfoHandle); 42 | } 43 | #endif 44 | public void Dispose() 45 | { 46 | pinnedObject.Dispose(); 47 | } 48 | } 49 | 50 | public unsafe struct InstanceFunc : IDisposable 51 | { 52 | private PinnedObject pinnedObject; 53 | public PinnedObject Object=>pinnedObject; 54 | #if Mono 55 | private readonly delegate* unmanaged[Cdecl] functionPointer; 56 | 57 | public InstanceFunc(Func func) 58 | 59 | { 60 | pinnedObject = new(func.Target); 61 | functionPointer = 62 | (delegate*unmanaged[Cdecl])func.Method.MethodHandle.GetFunctionPointer(); 63 | } 64 | 65 | public readonly TRet Invoke(T0 t0, T1 t1) 66 | { 67 | return functionPointer(pinnedObject.ObjectPointer, t0, t1); 68 | } 69 | #else 70 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 71 | 72 | public InstanceFunc(Func func) 73 | 74 | { 75 | pinnedObject = new(func.Target); 76 | methodInfoHandle = new (func.Method) ; 77 | } 78 | 79 | public readonly TRet Invoke(T0 t0,T1 t1) 80 | { 81 | return ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1, methodInfoHandle); 82 | } 83 | #endif 84 | public void Dispose() 85 | { 86 | pinnedObject.Dispose(); 87 | } 88 | } 89 | 90 | public unsafe struct InstanceFunc : IDisposable 91 | { 92 | private PinnedObject pinnedObject; 93 | public PinnedObject Object=>pinnedObject; 94 | #if Mono 95 | private readonly delegate* unmanaged[Cdecl] functionPointer; 96 | 97 | public InstanceFunc(Func func) 98 | 99 | { 100 | pinnedObject = new(func.Target); 101 | functionPointer = 102 | (delegate*unmanaged[Cdecl])func.Method.MethodHandle.GetFunctionPointer(); 103 | } 104 | 105 | public readonly TRet Invoke(T0 t0, T1 t1, T2 t2) 106 | { 107 | return functionPointer(pinnedObject.ObjectPointer, t0, t1, t2); 108 | } 109 | #else 110 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 111 | 112 | public InstanceFunc(Func func) 113 | 114 | { 115 | pinnedObject = new(func.Target); 116 | methodInfoHandle = new (func.Method) ; 117 | } 118 | 119 | public readonly TRet Invoke(T0 t0,T1 t1,T2 t2) 120 | { 121 | return ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1,t2, methodInfoHandle); 122 | } 123 | #endif 124 | public void Dispose() 125 | { 126 | pinnedObject.Dispose(); 127 | } 128 | } 129 | 130 | public unsafe struct InstanceFunc : IDisposable 131 | { 132 | private PinnedObject pinnedObject; 133 | public PinnedObject Object=>pinnedObject; 134 | #if Mono 135 | private readonly delegate* unmanaged[Cdecl] functionPointer; 136 | 137 | public InstanceFunc(Func func) 138 | 139 | { 140 | pinnedObject = new(func.Target); 141 | functionPointer = 142 | (delegate*unmanaged[Cdecl])func.Method.MethodHandle 143 | .GetFunctionPointer(); 144 | } 145 | 146 | public readonly TRet Invoke(T0 t0, T1 t1, T2 t2, T3 t3) 147 | { 148 | return functionPointer(pinnedObject.ObjectPointer, t0, t1, t2, t3); 149 | } 150 | #else 151 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 152 | 153 | public InstanceFunc(Func func) 154 | 155 | { 156 | pinnedObject = new(func.Target); 157 | methodInfoHandle = new (func.Method) ; 158 | } 159 | 160 | public readonly TRet Invoke(T0 t0,T1 t1,T2 t2,T3 t3) 161 | { 162 | return ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1,t2,t3, methodInfoHandle); 163 | } 164 | #endif 165 | public void Dispose() 166 | { 167 | pinnedObject.Dispose(); 168 | } 169 | } 170 | 171 | public unsafe struct InstanceFunc : IDisposable 172 | { 173 | private PinnedObject pinnedObject; 174 | public PinnedObject Object=>pinnedObject; 175 | #if Mono 176 | private readonly delegate* unmanaged[Cdecl] functionPointer; 177 | 178 | public InstanceFunc(Func func) 179 | 180 | { 181 | pinnedObject = new(func.Target); 182 | functionPointer = 183 | (delegate*unmanaged[Cdecl])func.Method.MethodHandle 184 | .GetFunctionPointer(); 185 | } 186 | 187 | public readonly TRet Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) 188 | { 189 | return functionPointer(pinnedObject.ObjectPointer, t0, t1, t2, t3, t4); 190 | } 191 | #else 192 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 193 | 194 | public InstanceFunc(Func func) 195 | 196 | { 197 | pinnedObject = new(func.Target); 198 | methodInfoHandle = new (func.Method) ; 199 | } 200 | 201 | public readonly TRet Invoke(T0 t0,T1 t1,T2 t2,T3 t3,T4 t4) 202 | { 203 | return ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1,t2,t3,t4, methodInfoHandle); 204 | } 205 | #endif 206 | public void Dispose() 207 | { 208 | pinnedObject.Dispose(); 209 | } 210 | } 211 | 212 | public unsafe struct InstanceFunc : IDisposable 213 | { 214 | private PinnedObject pinnedObject; 215 | public PinnedObject Object=>pinnedObject; 216 | #if Mono 217 | private readonly delegate* unmanaged[Cdecl] functionPointer; 218 | 219 | public InstanceFunc(Func func) 220 | 221 | { 222 | pinnedObject = new(func.Target); 223 | functionPointer = 224 | (delegate*unmanaged[Cdecl])func.Method.MethodHandle 225 | .GetFunctionPointer(); 226 | } 227 | 228 | public readonly TRet Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) 229 | { 230 | return functionPointer(pinnedObject.ObjectPointer, t0, t1, t2, t3, t4, t5); 231 | } 232 | #else 233 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 234 | 235 | public InstanceFunc(Func func) 236 | 237 | { 238 | pinnedObject = new(func.Target); 239 | methodInfoHandle = new (func.Method) ; 240 | } 241 | 242 | public readonly TRet Invoke(T0 t0,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5) 243 | { 244 | return ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1,t2,t3,t4,t5, methodInfoHandle); 245 | } 246 | #endif 247 | public void Dispose() 248 | { 249 | pinnedObject.Dispose(); 250 | } 251 | } 252 | 253 | public unsafe struct InstanceFunc : IDisposable 254 | { 255 | private PinnedObject pinnedObject; 256 | public PinnedObject Object=>pinnedObject; 257 | #if Mono 258 | private readonly delegate* unmanaged[Cdecl] functionPointer; 259 | 260 | public InstanceFunc(Func func) 261 | 262 | { 263 | pinnedObject = new(func.Target); 264 | functionPointer = 265 | (delegate*unmanaged[Cdecl])func.Method.MethodHandle 266 | .GetFunctionPointer(); 267 | } 268 | 269 | public readonly TRet Invoke(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) 270 | { 271 | return functionPointer(pinnedObject.ObjectPointer, t0, t1, t2, t3, t4, t5, t6); 272 | } 273 | #else 274 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 275 | 276 | public InstanceFunc(Func func) 277 | 278 | { 279 | pinnedObject = new(func.Target); 280 | methodInfoHandle = new (func.Method) ; 281 | } 282 | 283 | public readonly TRet Invoke(T0 t0,T1 t1,T2 t2,T3 t3,T4 t4,T5 t5,T6 t6) 284 | { 285 | return ((delegate* unmanaged[Cdecl])methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,t0,t1,t2,t3,t4,t5,t6, methodInfoHandle); 286 | } 287 | #endif 288 | public void Dispose() 289 | { 290 | pinnedObject.Dispose(); 291 | } 292 | } 293 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceFuncs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2c6ec7f2c5f42a38e28830acea682e6 3 | timeCreated: 1703405071 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceFuncs.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ import namespace="System.Linq" #> 3 | <#@ output extension="cs"#> 4 | <# 5 | string CreateGenericTypes(int start, int count) 6 | => string.Join(",", Enumerable.Range(start, count).Select(i => $"T{i}")); 7 | string CreateParameters(int start, int count) 8 | => string.Join(",", Enumerable.Range(start, count).Select(i => $"T{i} t{i}")); 9 | string CreateArguments(int start, int count) 10 | => string.Join(",", Enumerable.Range(start, count).Select(i => $"t{i}")); 11 | #> 12 | #if UNITY_EDITOR ||!ENABLE_IL2CPP 13 | #define Mono 14 | #else 15 | using UniReflection.IL2CPP; 16 | #endif 17 | using System; 18 | 19 | namespace UniReflection 20 | { 21 | <# for(var i =1;i<8;i++) { 22 | var genericTypes = CreateGenericTypes(0, i); 23 | var parameters = CreateParameters(0, i); 24 | var arguments = CreateArguments(0, i);#> 25 | public unsafe struct InstanceFunc<<#=genericTypes#>,TRet>: IDisposable 26 | { 27 | private PinnedObject pinnedObject; 28 | public PinnedObject Object=>pinnedObject; 29 | #if Mono 30 | private readonly delegate* unmanaged[Cdecl],TRet> functionPointer; 31 | 32 | public InstanceFunc(Func<<#=genericTypes#>> func) 33 | 34 | { 35 | pinnedObject =new(func.Target); 36 | functionPointer = (delegate*unmanaged[Cdecl],TRet> )func.Method.MethodHandle.GetFunctionPointer(); 37 | } 38 | 39 | public readonly TRet Invoke(<#=parameters#>) 40 | { 41 | return functionPointer(pinnedObject.ObjectPointer,<#=arguments#>); 42 | } 43 | #else 44 | private readonly Il2CppMethodInfoHandle methodInfoHandle; 45 | 46 | public InstanceFunc(Func<<#=genericTypes#>> func) 47 | 48 | { 49 | pinnedObject =new(func.Target); 50 | methodInfoHandle =new (func.Method) ; 51 | } 52 | 53 | public readonly TRet Invoke(<#=parameters#>) 54 | { 55 | return ((delegate* unmanaged[Cdecl],Il2CppMethodInfoHandle, TRet>)methodInfoHandle.MethodPointer)(pinnedObject.ObjectPointer,<#=arguments#>, methodInfoHandle); 56 | } 57 | #endif 58 | public void Dispose() 59 | { 60 | Object.Dispose(); 61 | } 62 | } 63 | <# } #> 64 | } 65 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/InstanceFuncs.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b17736dac5544a4380571d8722c0ad56 3 | timeCreated: 1703404798 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/NewCache.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR ||!ENABLE_IL2CPP 2 | #define Mono 3 | #endif 4 | 5 | using System; 6 | using System.Reflection; 7 | using System.Reflection.Emit; 8 | using System.Runtime.CompilerServices; 9 | using System.Threading; 10 | using UnityEngine; 11 | using UniReflection.IL2CPP; 12 | 13 | namespace UniReflection 14 | { 15 | internal static class TypeArrayCache 16 | { 17 | 18 | internal static readonly Type[] TypeArray0 = Array.Empty(); 19 | internal static readonly Type[] TypeArray1 = new Type[1]; 20 | internal static readonly Type[] TypeArray2 = new Type[2]; 21 | internal static readonly Type[] TypeArray3 = new Type[3]; 22 | internal static readonly Type[] TypeArray4 = new Type[4]; 23 | internal static readonly Type[] TypeArray5 = new Type[5]; 24 | internal static readonly Type[] TypeArray6 = new Type[6]; 25 | internal static readonly Type[] TypeArray7 = new Type[7]; 26 | internal static readonly Type[] TypeArray8 = new Type[8]; 27 | internal static readonly Type[] TypeArray9 = new Type[9]; 28 | internal static readonly Type[] TypeArray10 = new Type[10]; 29 | 30 | } 31 | 32 | internal static class TypeArrayCache 33 | { 34 | internal static readonly Type[] TypeArray = { typeof(T) }; 35 | } 36 | internal static class TypeArrayCache 37 | { 38 | internal static readonly Type[] TypeArray = { typeof(T1),typeof(T2) }; 39 | } 40 | public static unsafe class NewCache 41 | { 42 | /*[MethodImpl(MethodImplOptions.AggressiveInlining)] 43 | public static T CreateInstance() 44 | { 45 | #if Mono 46 | if( typeof(T).IsValueType) 47 | return Activator.CreateInstance(); 48 | #else 49 | if(IsValueType) 50 | { 51 | return default; 52 | } 53 | #endif 54 | return CreateInstance(); 55 | }*/ 56 | public static readonly Func CreateInstance; 57 | public static readonly bool HasValidConstructor; 58 | public static readonly bool IsValueType; 59 | 60 | public static bool TryCreateInstance(out T instance) 61 | { 62 | if (HasValidConstructor) 63 | { 64 | instance = CreateInstance(); 65 | return true; 66 | } 67 | 68 | instance = default; 69 | return false; 70 | } 71 | 72 | static NewCache() 73 | { 74 | var targetType = typeof(T); 75 | var isValueType = targetType.IsValueType; 76 | IsValueType = isValueType; 77 | var constructor = targetType.GetConstructor(BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic,null,Array.Empty(),null); 78 | if (constructor is null) 79 | { 80 | if (!isValueType) 81 | { 82 | CreateInstance = () => throw new Exception($"no default constructor for {targetType}"); 83 | HasValidConstructor = false; 84 | } 85 | return; 86 | } 87 | 88 | HasValidConstructor = true; 89 | #if Mono 90 | 91 | var dm = 92 | new DynamicMethod("", typeof(T), TypeArrayCache.TypeArray, restrictedSkipVisibility: true); 93 | var il = dm.GetILGenerator(); 94 | il.Emit(OpCodes.Newobj, constructor); 95 | il.Emit(OpCodes.Ret); 96 | CreateInstance = (Func)dm.CreateDelegate(typeof(Func)); 97 | #else 98 | 99 | 100 | { 101 | if (isValueType) 102 | { 103 | var p = (delegate*)constructor.MethodHandle.Value; 104 | CreateInstance = () => 105 | { 106 | var t = default(T); 107 | p(ref t); 108 | return t; 109 | }; 110 | } 111 | else 112 | { 113 | var klass = targetType.GetClassHandle(); 114 | var p = (delegate*)constructor.MethodHandle.Value; 115 | CreateInstance = () => 116 | { 117 | var o = Il2CppApi.il2cpp_object_new(klass); 118 | p(o); 119 | return Unsafe.As(ref o); 120 | }; 121 | } 122 | } 123 | #endif 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/NewCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62bbead343684530bc45c2a1b3e6b5de 3 | timeCreated: 1702446240 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/NewCaches.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3adf9ccf35634fabb331be3a4f97e71f 3 | timeCreated: 1703474456 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/NewCaches.tt: -------------------------------------------------------------------------------- 1 | <#@ template language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ import namespace="System.Linq" #> 4 | <#@ import namespace="System.Text" #> 5 | <#@ import namespace="System.Collections.Generic" #> 6 | <#@ import namespace="System.Linq" #> 7 | <#@ output extension="cs"#> 8 | <# 9 | string CreateGenericTypes(int start, int count) 10 | => string.Join(",", Enumerable.Range(start, count).Select(i => $"T{i}")); 11 | 12 | string CreateParameters(int start, int count) 13 | => string.Join(",", Enumerable.Range(start, count).Select(i => $"T{i} t{i}")); 14 | string CreateArguments(int start, int count) 15 | => string.Join(",", Enumerable.Range(start, count).Select(i => $"t{i}")); 16 | #> 17 | 18 | #if UNITY_EDITOR ||!ENABLE_IL2CPP 19 | #define Mono 20 | #else 21 | using UniReflection.IL2CPP; 22 | #endif 23 | using System; 24 | using System.Reflection; 25 | using System.Reflection.Emit; 26 | namespace UniReflection 27 | { 28 | <# 29 | for (var i = 1; i < 10; i++) 30 | { 31 | var genericTypes = CreateGenericTypes(0, i); 32 | var parameters = CreateParameters(0, i); 33 | var arguments = CreateArguments(0, i); 34 | #> 35 | public static unsafe class NewCache> 36 | { 37 | public static readonly Func<<#=genericTypes#>, TInstance> CreateInstance; 38 | public static readonly bool HasValidConstructor; 39 | 40 | public static bool TryCreateInstance(<#=parameters#>, out TInstance instance) 41 | { 42 | if (HasValidConstructor) 43 | { 44 | instance = CreateInstance(<#=arguments#>); 45 | return true; 46 | } 47 | 48 | instance = default; 49 | return false; 50 | } 51 | 52 | static NewCache() 53 | { 54 | var targetType = typeof(TInstance); 55 | 56 | ConstructorInfo constructor; 57 | lock (TypeArrayCache.TypeArray<#=i#>) 58 | { 59 | var paramTypes = TypeArrayCache.TypeArray<#=i#>; 60 | <# 61 | for (var j = 0; j < i; j++) 62 | { 63 | #> 64 | paramTypes[<#=j#>] = typeof(T<#=j#>); 65 | <#} 66 | #> 67 | constructor = targetType.GetConstructor( 68 | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, paramTypes, 69 | null); 70 | } 71 | 72 | HasValidConstructor = true; 73 | 74 | #if Mono 75 | lock (TypeArrayCache.TypeArray<#=i+1#>) 76 | { 77 | var paramTypes = TypeArrayCache.TypeArray<#=i+1#>; 78 | paramTypes[0] = typeof(object); 79 | <# 80 | for (var j = 0; j < i; j++) 81 | { 82 | #> 83 | paramTypes[<#=j+1#>] = typeof(T<#=j#>); 84 | <#} 85 | #> 86 | 87 | var dm = 88 | new DynamicMethod("new", typeof(TInstance),paramTypes, restrictedSkipVisibility: true); 89 | var il = dm.GetILGenerator(); 90 | <# 91 | for (var j = 0; j < i; j++) 92 | { 93 | #> 94 | il.Emit(OpCodes.Ldarg_S,<#=j+1#>); 95 | <#} 96 | #> 97 | il.Emit(OpCodes.Newobj, constructor); 98 | il.Emit(OpCodes.Ret); 99 | CreateInstance = (Func<<#=genericTypes#>, TInstance>)dm.CreateDelegate(typeof(Func<<#=genericTypes#>, TInstance>)); 100 | } 101 | 102 | #else 103 | var isValueType = targetType.IsValueType; 104 | var klass = targetType.GetClassHandle(); 105 | if (isValueType) 106 | { 107 | var p = (delegate*, void>)constructor.MethodHandle.Value; 108 | CreateInstance = (<#=arguments#>) => 109 | { 110 | var t = default(TInstance); 111 | p(ref t, <#=arguments#>); 112 | return t; 113 | }; 114 | } 115 | else 116 | { 117 | var p = (delegate*, void>)constructor.MethodHandle.Value; 118 | CreateInstance = (<#=arguments#>) => 119 | { 120 | var o = Il2CppApi.il2cpp_object_new(klass); 121 | p(o, <#=arguments#>); 122 | return Unsafe.As(ref o); 123 | }; 124 | } 125 | #endif 126 | } 127 | } 128 | <# 129 | } 130 | #> 131 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/NewCaches.tt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d99a88795c54d2ab76842d95b1ef785 3 | timeCreated: 1703472753 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/PinnedObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Collections.LowLevel.Unsafe; 3 | namespace UniReflection 4 | { 5 | public unsafe struct PinnedObject : IDisposable 6 | { 7 | public readonly IntPtr ObjectPointer; 8 | public readonly ulong GCHandle; 9 | 10 | public PinnedObject(object obj) 11 | { 12 | if(obj is null) throw new NullReferenceException("GC can't pin null"); 13 | else ObjectPointer=(IntPtr) UnsafeUtility.PinGCObjectAndGetAddress(obj,out GCHandle); 14 | } 15 | 16 | public void Dispose() 17 | { 18 | if(ObjectPointer==IntPtr.Zero) return; 19 | UnsafeUtility.ReleaseGCObject(GCHandle); 20 | this= default; 21 | // ObjectPointer = IntPtr.Zero; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/PinnedObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93ff2eec87094c06b6f396f6d5870967 3 | timeCreated: 1703400686 -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/UniReflection.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniReflection", 3 | "rootNamespace": "UniReflection", 4 | "references": [ 5 | "GUID:2665a8d13d1b3f18800f46e256720795", 6 | "GUID:9c6dda6c7922c624cb7ea9a7f1c7d54a", 7 | "GUID:91e66e2e63b788444bb2dab4b253479b" 8 | ], 9 | "includePlatforms": [], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": true, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [], 17 | "noEngineReferences": false 18 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/UniReflection.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0c0d079cb9bcd8644a539f29f8e4142c 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/Unsafe.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4c0cd89fb1fd4634bae09fb711543f67 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/Unsafe/UniReflection.Unsafe.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akeit0/UniReflection/32b4dfb0a87d7019408d534707cf2cda0d3c777a/Assets/UniReflection/Runtime/Unsafe/UniReflection.Unsafe.dll -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/Unsafe/UniReflection.Unsafe.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2850ed6114f142479957b5bf5f4913e 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | Windows Store Apps: WindowsStoreApps 27 | second: 28 | enabled: 0 29 | settings: 30 | CPU: AnyCPU 31 | userData: 32 | assetBundleName: 33 | assetBundleVariant: 34 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/Unsafe/UniReflection.Unsafe.il: -------------------------------------------------------------------------------- 1 | 2 | // Metadata version: v4.0.30319 3 | .assembly extern netstandard 4 | { 5 | .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) // .{...-.Q 6 | .ver 2:1:0:0 7 | } 8 | .assembly UniReflection.Unsafe 9 | { 10 | .custom instance void [netstandard]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) 11 | .custom instance void [netstandard]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) 12 | .custom instance void [netstandard]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx 13 | 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. 14 | 15 | .hash algorithm 0x00008004 16 | .ver 4:0:6:0 17 | } 18 | .module UniReflection.Unsafe.dll 19 | // MVID: {9AF8BDDC-406F-4A74-9F37-09AF6F151255} 20 | .imagebase 0x00400000 21 | .file alignment 0x00000200 22 | .stackreserve 0x00100000 23 | .subsystem 0x0003 // WINDOWS_CUI 24 | .corflags 0x00000009 // ILONLY 25 | // Image base: 0x05010000 26 | 27 | 28 | // =============== CLASS MEMBERS DECLARATION =================== 29 | 30 | .class public abstract auto ansi sealed beforefieldinit UniReflection.Unsafe 31 | extends [netstandard]System.Object 32 | { 33 | 34 | .method public hidebysig static 35 | void SkipInit ( 36 | [out] !!T& 'value' 37 | ) cil managed aggressiveinlining 38 | { 39 | // Method begins at RVA 0x2050 40 | // Code size 8 (0x8) 41 | // Code size 1 (0x1) 42 | .maxstack 1 43 | 44 | IL_0000: ret 45 | } // end of method Unsafe::SkipInit 46 | 47 | .method public hidebysig static !!T Read(void* source) cil managed aggressiveinlining 48 | { 49 | // コード サイズ 7 (0x7) 50 | .maxstack 1 51 | IL_0000: ldarg.0 52 | IL_0001: ldobj !!T 53 | IL_0006: ret 54 | } // end of method Unsafe::Read 55 | 56 | .method public hidebysig static !!T ReadUnaligned(void* source) cil managed aggressiveinlining 57 | { 58 | // コード サイズ 10 (0xa) 59 | .maxstack 1 60 | IL_0000: ldarg.0 61 | IL_0001: unaligned. 1 62 | IL_0004: ldobj !!T 63 | IL_0009: ret 64 | } // end of method Unsafe::ReadUnaligned 65 | 66 | .method public hidebysig static !!T ReadUnaligned(uint8& source) cil managed aggressiveinlining 67 | { 68 | // コード サイズ 10 (0xa) 69 | .maxstack 1 70 | IL_0000: ldarg.0 71 | IL_0001: unaligned. 1 72 | IL_0004: ldobj !!T 73 | IL_0009: ret 74 | } // end of method Unsafe::ReadUnaligned 75 | 76 | .method public hidebysig static void Write(void* destination, 77 | !!T 'value') cil managed aggressiveinlining 78 | { 79 | // コード サイズ 8 (0x8) 80 | .maxstack 2 81 | IL_0000: ldarg.0 82 | IL_0001: ldarg.1 83 | IL_0002: stobj !!T 84 | IL_0007: ret 85 | } // end of method Unsafe::Write 86 | 87 | .method public hidebysig static void WriteUnaligned(void* destination, 88 | !!T 'value') cil managed aggressiveinlining 89 | { 90 | // コード サイズ 11 (0xb) 91 | .maxstack 2 92 | IL_0000: ldarg.0 93 | IL_0001: ldarg.1 94 | IL_0002: unaligned. 1 95 | IL_0005: stobj !!T 96 | IL_000a: ret 97 | } // end of method Unsafe::WriteUnaligned 98 | 99 | .method public hidebysig static void WriteUnaligned(uint8& destination, 100 | !!T 'value') cil managed aggressiveinlining 101 | { 102 | // コード サイズ 11 (0xb) 103 | .maxstack 2 104 | IL_0000: ldarg.0 105 | IL_0001: ldarg.1 106 | IL_0002: unaligned. 1 107 | IL_0005: stobj !!T 108 | IL_000a: ret 109 | } // end of method Unsafe::WriteUnaligned 110 | 111 | .method public hidebysig static void Copy(void* destination, 112 | !!T& source) cil managed aggressiveinlining 113 | { 114 | // コード サイズ 13 (0xd) 115 | .maxstack 2 116 | IL_0000: ldarg.0 117 | IL_0001: ldarg.1 118 | IL_0002: ldobj !!T 119 | IL_0007: stobj !!T 120 | IL_000c: ret 121 | } // end of method Unsafe::Copy 122 | 123 | .method public hidebysig static void Copy(!!T& destination, 124 | void* source) cil managed aggressiveinlining 125 | { 126 | // コード サイズ 13 (0xd) 127 | .maxstack 2 128 | IL_0000: ldarg.0 129 | IL_0001: ldarg.1 130 | IL_0002: ldobj !!T 131 | IL_0007: stobj !!T 132 | IL_000c: ret 133 | } // end of method Unsafe::Copy 134 | 135 | 136 | .method public hidebysig static void* AsPointer(!!T& 'value') cil managed aggressiveinlining 137 | { 138 | // コード サイズ 3 (0x3) 139 | .maxstack 1 140 | IL_0000: ldarg.0 141 | IL_0001: conv.u 142 | IL_0002: ret 143 | } // end of method Unsafe::AsPointer 144 | .method public hidebysig static void* AsPointer(valuetype [netstandard]System.Span`1& 'value') cil managed aggressiveinlining 145 | { 146 | // コード サイズ 3 (0x3) 147 | .maxstack 1 148 | IL_0000: ldarg.0 149 | IL_0001: conv.u 150 | IL_0002: ret 151 | } // end of method Unsafe::AsPointer 152 | .method public hidebysig static void* AsPointer(valuetype [netstandard]System.ReadOnlySpan`1& 'value') cil managed aggressiveinlining 153 | { 154 | // コード サイズ 3 (0x3) 155 | .maxstack 1 156 | IL_0000: ldarg.0 157 | IL_0001: conv.u 158 | IL_0002: ret 159 | } // end of method Unsafe::AsPointer 160 | 161 | 162 | .method public hidebysig static void* AsPointer(object o) cil managed aggressiveinlining 163 | { 164 | // コード サイズ 2 (0x2) 165 | .maxstack 1 166 | IL_0000: ldarg.0 167 | IL_0001: conv.u 168 | IL_0002: ret 169 | } // end of method Unsafe::AsPointer 170 | 171 | .method public hidebysig static valuetype [netstandard]System.Span`1& AsSpanRef(void* source) cil managed aggressiveinlining 172 | { 173 | // コード サイズ 4 (0x4) 174 | .maxstack 1 175 | IL_0000: ldarg.0 176 | IL_0001: ret 177 | } // end of method Unsafe::AsSpanRef 178 | .method public hidebysig static valuetype [netstandard]System.ReadOnlySpan`1& AsReadOnlySpanRef(void* source) cil managed aggressiveinlining 179 | { 180 | // コード サイズ 4 (0x4) 181 | .maxstack 1 182 | IL_0000: ldarg.0 183 | IL_0001: ret 184 | } // end of method Unsafe::AsReadOnlySpanRef 185 | 186 | .method public hidebysig static int32 SizeOf() cil managed aggressiveinlining 187 | { 188 | // コード サイズ 7 (0x7) 189 | .maxstack 1 190 | IL_0000: sizeof !!T 191 | IL_0006: ret 192 | } // end of method Unsafe::SizeOf 193 | 194 | .method public hidebysig static void CopyBlock(void* destination, 195 | void* source, 196 | uint32 byteCount) cil managed aggressiveinlining 197 | { 198 | // コード サイズ 6 (0x6) 199 | .maxstack 3 200 | IL_0000: ldarg.0 201 | IL_0001: ldarg.1 202 | IL_0002: ldarg.2 203 | IL_0003: cpblk 204 | IL_0005: ret 205 | } // end of method Unsafe::CopyBlock 206 | 207 | .method public hidebysig static void CopyBlock(uint8& destination, 208 | uint8& source, 209 | uint32 byteCount) cil managed aggressiveinlining 210 | { 211 | // コード サイズ 6 (0x6) 212 | .maxstack 3 213 | IL_0000: ldarg.0 214 | IL_0001: ldarg.1 215 | IL_0002: ldarg.2 216 | IL_0003: cpblk 217 | IL_0005: ret 218 | } // end of method Unsafe::CopyBlock 219 | 220 | .method public hidebysig static void CopyBlockUnaligned(void* destination, 221 | void* source, 222 | uint32 byteCount) cil managed aggressiveinlining 223 | { 224 | // コード サイズ 9 (0x9) 225 | .maxstack 3 226 | IL_0000: ldarg.0 227 | IL_0001: ldarg.1 228 | IL_0002: ldarg.2 229 | IL_0003: unaligned. 1 230 | IL_0006: cpblk 231 | IL_0008: ret 232 | } // end of method Unsafe::CopyBlockUnaligned 233 | 234 | .method public hidebysig static void CopyBlockUnaligned(uint8& destination, 235 | uint8& source, 236 | uint32 byteCount) cil managed aggressiveinlining 237 | { 238 | // コード サイズ 9 (0x9) 239 | .maxstack 3 240 | IL_0000: ldarg.0 241 | IL_0001: ldarg.1 242 | IL_0002: ldarg.2 243 | IL_0003: unaligned. 1 244 | IL_0006: cpblk 245 | IL_0008: ret 246 | } // end of method Unsafe::CopyBlockUnaligned 247 | 248 | .method public hidebysig static void InitBlock(void* startAddress, 249 | uint8 'value', 250 | uint32 byteCount) cil managed aggressiveinlining 251 | { 252 | // コード サイズ 6 (0x6) 253 | .maxstack 3 254 | IL_0000: ldarg.0 255 | IL_0001: ldarg.1 256 | IL_0002: ldarg.2 257 | IL_0003: initblk 258 | IL_0005: ret 259 | } // end of method Unsafe::InitBlock 260 | 261 | .method public hidebysig static void InitBlock(uint8& startAddress, 262 | uint8 'value', 263 | uint32 byteCount) cil managed aggressiveinlining 264 | { 265 | // コード サイズ 6 (0x6) 266 | .maxstack 3 267 | IL_0000: ldarg.0 268 | IL_0001: ldarg.1 269 | IL_0002: ldarg.2 270 | IL_0003: initblk 271 | IL_0005: ret 272 | } // end of method Unsafe::InitBlock 273 | 274 | .method public hidebysig static void InitBlockUnaligned(void* startAddress, 275 | uint8 'value', 276 | uint32 byteCount) cil managed aggressiveinlining 277 | { 278 | // コード サイズ 9 (0x9) 279 | .maxstack 3 280 | IL_0000: ldarg.0 281 | IL_0001: ldarg.1 282 | IL_0002: ldarg.2 283 | IL_0003: unaligned. 1 284 | IL_0006: initblk 285 | IL_0008: ret 286 | } // end of method Unsafe::InitBlockUnaligned 287 | 288 | .method public hidebysig static void InitBlockUnaligned(uint8& startAddress, 289 | uint8 'value', 290 | uint32 byteCount) cil managed aggressiveinlining 291 | { 292 | // コード サイズ 9 (0x9) 293 | .maxstack 3 294 | IL_0000: ldarg.0 295 | IL_0001: ldarg.1 296 | IL_0002: ldarg.2 297 | IL_0003: unaligned. 1 298 | IL_0006: initblk 299 | IL_0008: ret 300 | } // end of method Unsafe::InitBlockUnaligned 301 | 302 | .method public hidebysig static !!T As(object o) cil managed aggressiveinlining 303 | { 304 | // コード サイズ 2 (0x2) 305 | .maxstack 1 306 | IL_0000: ldarg.0 307 | IL_0001: ret 308 | } // end of method Unsafe::As 309 | .method public hidebysig static !!T& AsRef(void* source) cil managed aggressiveinlining 310 | { 311 | // コード サイズ 4 (0x4) 312 | .maxstack 1 313 | IL_0000: ldarg.0 314 | IL_0001: ret 315 | } // end of method Unsafe::AsRef 316 | 317 | .method public hidebysig static !!T& AsRef(!!T& source) cil managed aggressiveinlining 318 | { 319 | .param [1] 320 | .custom instance void [netstandard]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 321 | 01 00 00 00 322 | ) 323 | // コード サイズ 2 (0x2) 324 | .maxstack 1 325 | IL_0000: ldarg.0 326 | IL_0001: ret 327 | } // end of method Unsafe::AsRef 328 | .method public hidebysig static valuetype [netstandard]System.ReadOnlySpan`1& AsRef(valuetype [netstandard]System.ReadOnlySpan`1& source) cil managed aggressiveinlining 329 | { 330 | .param [1] 331 | .custom instance void [netstandard]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 332 | 01 00 00 00 333 | ) 334 | // コード サイズ 2 (0x2) 335 | .maxstack 1 336 | IL_0000: ldarg.0 337 | IL_0001: ret 338 | } // end of method Unsafe::AsRef 339 | .method public hidebysig static valuetype [netstandard]System.Span`1& AsRef(valuetype [netstandard]System.Span`1& source) cil managed aggressiveinlining 340 | { 341 | .param [1] 342 | .custom instance void [netstandard]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 343 | 01 00 00 00 344 | ) 345 | // コード サイズ 2 (0x2) 346 | .maxstack 1 347 | IL_0000: ldarg.0 348 | IL_0001: ret 349 | } // end of method Unsafe::AsRef 350 | .method public hidebysig static !!TTo& 351 | As(!!TFrom& source) cil managed aggressiveinlining 352 | { 353 | // コード サイズ 2 (0x2) 354 | .maxstack 1 355 | IL_0000: ldarg.0 356 | IL_0001: ret 357 | } // end of method Unsafe::As 358 | 359 | .method public hidebysig static !!T& Unbox(object 'box') cil managed aggressiveinlining 360 | { 361 | // コード サイズ 7 (0x7) 362 | .maxstack 1 363 | IL_0000: ldarg.0 364 | IL_0001: unbox !!T 365 | IL_0006: ret 366 | } // end of method Unsafe::Unbox 367 | 368 | .method public hidebysig static !!T& Add(!!T& source, 369 | int32 elementOffset) cil managed aggressiveinlining 370 | { 371 | // コード サイズ 12 (0xc) 372 | .maxstack 3 373 | IL_0000: ldarg.0 374 | IL_0001: ldarg.1 375 | IL_0002: sizeof !!T 376 | IL_0008: conv.i 377 | IL_0009: mul 378 | IL_000a: add 379 | IL_000b: ret 380 | } // end of method Unsafe::Add 381 | 382 | .method public hidebysig static void* Add(void* source, 383 | int32 elementOffset) cil managed aggressiveinlining 384 | { 385 | // コード サイズ 12 (0xc) 386 | .maxstack 3 387 | IL_0000: ldarg.0 388 | IL_0001: ldarg.1 389 | IL_0002: sizeof !!T 390 | IL_0008: conv.i 391 | IL_0009: mul 392 | IL_000a: add 393 | IL_000b: ret 394 | } // end of method Unsafe::Add 395 | 396 | .method public hidebysig static !!T& Add(!!T& source, 397 | native int elementOffset) cil managed aggressiveinlining 398 | { 399 | // コード サイズ 11 (0xb) 400 | .maxstack 3 401 | IL_0000: ldarg.0 402 | IL_0001: ldarg.1 403 | IL_0002: sizeof !!T 404 | IL_0008: mul 405 | IL_0009: add 406 | IL_000a: ret 407 | } // end of method Unsafe::Add 408 | 409 | .method public hidebysig static !!T& AddByteOffset(!!T& source, 410 | native int byteOffset) cil managed aggressiveinlining 411 | { 412 | // コード サイズ 4 (0x4) 413 | .maxstack 2 414 | IL_0000: ldarg.0 415 | IL_0001: ldarg.1 416 | IL_0002: add 417 | IL_0003: ret 418 | } // end of method Unsafe::AddByteOffset 419 | 420 | .method public hidebysig static !!T& Subtract(!!T& source, 421 | int32 elementOffset) cil managed aggressiveinlining 422 | { 423 | // コード サイズ 12 (0xc) 424 | .maxstack 3 425 | IL_0000: ldarg.0 426 | IL_0001: ldarg.1 427 | IL_0002: sizeof !!T 428 | IL_0008: conv.i 429 | IL_0009: mul 430 | IL_000a: sub 431 | IL_000b: ret 432 | } // end of method Unsafe::Subtract 433 | 434 | .method public hidebysig static void* Subtract(void* source, 435 | int32 elementOffset) cil managed aggressiveinlining 436 | { 437 | // コード サイズ 12 (0xc) 438 | .maxstack 3 439 | IL_0000: ldarg.0 440 | IL_0001: ldarg.1 441 | IL_0002: sizeof !!T 442 | IL_0008: conv.i 443 | IL_0009: mul 444 | IL_000a: sub 445 | IL_000b: ret 446 | } // end of method Unsafe::Subtract 447 | 448 | .method public hidebysig static !!T& Subtract(!!T& source, 449 | native int elementOffset) cil managed aggressiveinlining 450 | { 451 | // コード サイズ 11 (0xb) 452 | .maxstack 3 453 | IL_0000: ldarg.0 454 | IL_0001: ldarg.1 455 | IL_0002: sizeof !!T 456 | IL_0008: mul 457 | IL_0009: sub 458 | IL_000a: ret 459 | } // end of method Unsafe::Subtract 460 | 461 | .method public hidebysig static !!T& SubtractByteOffset(!!T& source, 462 | native int byteOffset) cil managed aggressiveinlining 463 | { 464 | // コード サイズ 4 (0x4) 465 | .maxstack 2 466 | IL_0000: ldarg.0 467 | IL_0001: ldarg.1 468 | IL_0002: sub 469 | IL_0003: ret 470 | } // end of method Unsafe::SubtractByteOffset 471 | 472 | .method public hidebysig static native int 473 | ByteOffset(!!T& origin, 474 | !!T& target) cil managed aggressiveinlining 475 | { 476 | // コード サイズ 4 (0x4) 477 | .maxstack 2 478 | IL_0000: ldarg.1 479 | IL_0001: ldarg.0 480 | IL_0002: sub 481 | IL_0003: ret 482 | } // end of method Unsafe::ByteOffset 483 | 484 | .method public hidebysig static bool AreSame(!!T& left, 485 | !!T& right) cil managed aggressiveinlining 486 | { 487 | // コード サイズ 5 (0x5) 488 | .maxstack 2 489 | IL_0000: ldarg.0 490 | IL_0001: ldarg.1 491 | IL_0002: ceq 492 | IL_0004: ret 493 | } // end of method Unsafe::AreSame 494 | 495 | .method public hidebysig static bool IsAddressGreaterThan(!!T& left, 496 | !!T& right) cil managed aggressiveinlining 497 | { 498 | // コード サイズ 5 (0x5) 499 | .maxstack 2 500 | IL_0000: ldarg.0 501 | IL_0001: ldarg.1 502 | IL_0002: cgt.un 503 | IL_0004: ret 504 | } // end of method Unsafe::IsAddressGreaterThan 505 | 506 | .method public hidebysig static bool IsAddressLessThan(!!T& left, 507 | !!T& right) cil managed aggressiveinlining 508 | { 509 | // コード サイズ 5 (0x5) 510 | .maxstack 2 511 | IL_0000: ldarg.0 512 | IL_0001: ldarg.1 513 | IL_0002: clt.un 514 | IL_0004: ret 515 | } // end of method Unsafe::IsAddressLessThan 516 | .method public hidebysig static !!0/*T*/& 517 | NullRef() cil managed 518 | { 519 | .maxstack 8 520 | IL_0000: ldc.i4.0 521 | IL_0001: conv.u 522 | IL_0002: ret 523 | 524 | } // end of method Unsafe::NullRef 525 | 526 | .method public hidebysig static bool IsNullRef(!!T& ptr) cil managed aggressiveinlining 527 | { 528 | // コード サイズ 5 (0x5) 529 | .maxstack 2 530 | IL_0000: ldarg.0 531 | IL_0001: ldc.i4.0 532 | IL_0002: conv.u 533 | IL_0003: ceq 534 | IL_0004: ret 535 | } // end of method Unsafe::AreSame 536 | 537 | 538 | } // end of class netstandard.CompilerServices.Unsafe 539 | 540 | .class private auto ansi sealed beforefieldinit netstandard.CompilerServices.IsReadOnlyAttribute 541 | extends [netstandard]System.Attribute 542 | { 543 | .method public hidebysig specialname rtspecialname 544 | instance void .ctor() cil managed 545 | { 546 | // コード サイズ 7 (0x7) 547 | .maxstack 1 548 | IL_0000: ldarg.0 549 | IL_0001: call instance void [netstandard]System.Attribute::.ctor() 550 | IL_0006: ret 551 | } // end of method IsReadOnlyAttribute::.ctor 552 | 553 | } // end of class netstandard.CompilerServices.IsReadOnlyAttribute -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/Unsafe/UniReflection.Unsafe.il.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 119c49601ff7ede4b9459abd677b6f67 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/UnsafeConversion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | 5 | namespace UniReflection { 6 | public static unsafe class UnsafeConversion { 7 | #if UNITY_EDITOR||!ENABLE_IL2CPP 8 | public static readonly delegate* IdentityFunctionPointer =(delegate*) ((Func) Identity).Method.MethodHandle.GetFunctionPointer(); 9 | #else 10 | public static readonly delegate* IdentityFunctionPointer = &Identity; 11 | #endif 12 | 13 | 14 | 15 | 16 | 17 | public static IntPtr Identity(IntPtr ptr) { 18 | return ptr; 19 | } 20 | 21 | 22 | 23 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 24 | public static T As(object o ){ 25 | return UnsafeUtility.As(ref o); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Runtime/UnsafeConversion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5d02e280170f4ac59517290167bccdeb 3 | timeCreated: 1702446335 -------------------------------------------------------------------------------- /Assets/UniReflection/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed3bdfb0ee1449fca17a46a2d92dcad0 3 | timeCreated: 1703479288 -------------------------------------------------------------------------------- /Assets/UniReflection/Tests/Benchmark.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | using Unity.PerformanceTesting; 7 | using NUnit.Framework; 8 | 9 | namespace UniReflection.Tests 10 | { 11 | 12 | public class BenchmarkClassNew 13 | { 14 | const int WarmupCount = 5; 15 | const int MeasurementCount = 100; 16 | 17 | class MyClass 18 | { 19 | public int A = 5; 20 | } 21 | 22 | [TearDown] 23 | public void TearDown() 24 | { 25 | GC.Collect(); 26 | } 27 | 28 | [Test, Performance] 29 | public void NewDirect() 30 | { 31 | Measure.Method(() => 32 | { 33 | for (int i = 0; i < 1000; i++) 34 | { 35 | new MyClass(); 36 | } 37 | }) 38 | .WarmupCount(WarmupCount) 39 | .MeasurementCount(MeasurementCount) 40 | .SampleGroup(new SampleGroup("New class Direct", SampleUnit.Microsecond)) 41 | .Run(); 42 | } 43 | 44 | [Test, Performance] 45 | public void NewConstraint() 46 | { 47 | static T New() where T : new() => new T(); 48 | Measure.Method(() => 49 | { 50 | for (int i = 0; i < 1000; i++) 51 | { 52 | New(); 53 | } 54 | }) 55 | .WarmupCount(WarmupCount) 56 | .MeasurementCount(MeasurementCount) 57 | .SampleGroup(new SampleGroup("New class generic constrained", SampleUnit.Microsecond)) 58 | .Run(); 59 | } 60 | 61 | [Test, Performance] 62 | public void NewCache() 63 | { 64 | Measure.Method(() => 65 | { 66 | for (int i = 0; i < 1000; i++) 67 | { 68 | NewCache.CreateInstance(); 69 | } 70 | }) 71 | .WarmupCount(WarmupCount) 72 | .MeasurementCount(MeasurementCount) 73 | .SampleGroup(new SampleGroup("New class cache", SampleUnit.Microsecond)) 74 | .Run(); 75 | } 76 | 77 | 78 | } 79 | public class BenchmarkClassNewWithParameter 80 | { 81 | const int WarmupCount = 5; 82 | const int MeasurementCount = 100; 83 | 84 | private class MyClass 85 | { 86 | public MyClass(int a) 87 | { 88 | A = a; 89 | } 90 | 91 | public int A = 5; 92 | } 93 | 94 | [TearDown] 95 | public void TearDown() 96 | { 97 | GC.Collect(); 98 | } 99 | 100 | [Test, Performance] 101 | public void NewDirect() 102 | { 103 | Measure.Method(() => 104 | { 105 | for (int i = 0; i < 1000; i++) 106 | { 107 | new MyClass(1); 108 | } 109 | }) 110 | .WarmupCount(WarmupCount) 111 | .MeasurementCount(MeasurementCount) 112 | .SampleGroup(new SampleGroup("New class Direct", SampleUnit.Microsecond)) 113 | .Run(); 114 | } 115 | [Test, Performance] 116 | public void NewActivator() 117 | { 118 | [MethodImpl(MethodImplOptions.NoInlining)] 119 | static T New() where T : new() => new T(); 120 | Measure.Method(() => 121 | { 122 | for (int i = 0; i < 1000; i++) 123 | { 124 | Activator.CreateInstance(typeof(MyClass),1); 125 | } 126 | }) 127 | .WarmupCount(WarmupCount) 128 | .MeasurementCount(MeasurementCount) 129 | .SampleGroup(new SampleGroup("New class generic constrained", SampleUnit.Microsecond)) 130 | .Run(); 131 | } 132 | 133 | [Test, Performance] 134 | public void NewCache() 135 | { 136 | Measure.Method(() => 137 | { 138 | for (int i = 0; i < 1000; i++) 139 | { 140 | NewCache< MyClass,int>.CreateInstance(1); 141 | } 142 | }) 143 | .WarmupCount(WarmupCount) 144 | .MeasurementCount(MeasurementCount) 145 | .SampleGroup(new SampleGroup("New class cache", SampleUnit.Microsecond)) 146 | .Run(); 147 | } 148 | } 149 | public class BenchmarkStructNew 150 | { 151 | const int WarmupCount = 5; 152 | const int MeasurementCount = 100; 153 | 154 | 155 | 156 | struct MyStruct 157 | { 158 | public int A ; 159 | } 160 | 161 | [TearDown] 162 | public void TearDown() 163 | { 164 | GC.Collect(); 165 | } 166 | [Test, Performance] 167 | public void CallNop() 168 | { 169 | Measure.Method(() => 170 | { 171 | [MethodImpl(MethodImplOptions.NoInlining)] 172 | static void New() {} 173 | for (int i = 0; i < 1000; i++) 174 | { 175 | New(); 176 | } 177 | }) 178 | .WarmupCount(WarmupCount) 179 | .MeasurementCount(MeasurementCount) 180 | .SampleGroup(new SampleGroup("New class Direct", SampleUnit.Microsecond)) 181 | .Run(); 182 | } 183 | [Test, Performance] 184 | public void NewDirect() 185 | { 186 | Measure.Method(() => 187 | { 188 | [MethodImpl(MethodImplOptions.NoInlining)] 189 | static MyStruct New() => new MyStruct(); 190 | for (int i = 0; i < 1000; i++) 191 | { 192 | New(); 193 | } 194 | }) 195 | .WarmupCount(WarmupCount) 196 | .MeasurementCount(MeasurementCount) 197 | .SampleGroup(new SampleGroup("New class Direct", SampleUnit.Microsecond)) 198 | .Run(); 199 | } 200 | 201 | [Test, Performance] 202 | public void NewConstraint() 203 | { 204 | [MethodImpl(MethodImplOptions.NoInlining)] 205 | static T New() where T : new() => new T(); 206 | Measure.Method(() => 207 | { 208 | for (int i = 0; i < 1000; i++) 209 | { 210 | New(); 211 | } 212 | }) 213 | .WarmupCount(WarmupCount) 214 | .MeasurementCount(MeasurementCount) 215 | .SampleGroup(new SampleGroup("New class generic constrained", SampleUnit.Microsecond)) 216 | .Run(); 217 | } 218 | [Test, Performance] 219 | public void NewActivator() 220 | { 221 | Measure.Method(() => 222 | { 223 | [MethodImpl(MethodImplOptions.NoInlining)] 224 | static T New() where T : new() => Activator.CreateInstance(); 225 | for (int i = 0; i < 1000; i++) 226 | { 227 | New(); 228 | } 229 | }) 230 | .WarmupCount(WarmupCount) 231 | .MeasurementCount(MeasurementCount) 232 | .SampleGroup(new SampleGroup("New class generic constrained", SampleUnit.Microsecond)) 233 | .Run(); 234 | } 235 | [Test, Performance] 236 | public void NewCache() 237 | { 238 | Measure.Method(() => 239 | { 240 | [MethodImpl(MethodImplOptions.NoInlining)] 241 | static T New() => NewCache.CreateInstance(); 242 | for (int i = 0; i < 1000; i++) 243 | { 244 | 245 | New(); 246 | } 247 | }) 248 | .WarmupCount(WarmupCount) 249 | .MeasurementCount(MeasurementCount) 250 | .SampleGroup(new SampleGroup("New class cache", SampleUnit.Microsecond)) 251 | .Run(); 252 | } 253 | 254 | 255 | } 256 | public class BenchmarkStructNewWithParameter 257 | { 258 | const int WarmupCount = 5; 259 | const int MeasurementCount = 100; 260 | 261 | private struct MyStruct 262 | { 263 | public MyStruct(int a) 264 | { 265 | A = a; 266 | } 267 | 268 | public int A ; 269 | } 270 | [TearDown] 271 | public void TearDown() 272 | { 273 | GC.Collect(); 274 | } 275 | 276 | [Test, Performance] 277 | public void NewDirect() 278 | { 279 | Measure.Method(() => 280 | { 281 | [MethodImpl(MethodImplOptions.NoInlining)] 282 | static MyStruct New(int x) => new (x); 283 | for (int i = 0; i < 1000; i++) 284 | { 285 | New(1); 286 | } 287 | }) 288 | .WarmupCount(WarmupCount) 289 | .MeasurementCount(MeasurementCount) 290 | .SampleGroup(new SampleGroup("New class Direct", SampleUnit.Microsecond)) 291 | .Run(); 292 | } 293 | 294 | [Test, Performance] 295 | public void NewCache() 296 | { 297 | Measure.Method(() => 298 | { 299 | for (int i = 0; i < 1000; i++) 300 | { 301 | NewCache< MyStruct,int>.CreateInstance(1); 302 | } 303 | }) 304 | .WarmupCount(WarmupCount) 305 | .MeasurementCount(MeasurementCount) 306 | .SampleGroup(new SampleGroup("New class cache", SampleUnit.Microsecond)) 307 | .Run(); 308 | } 309 | } 310 | 311 | public class BenchmarkStaticIntField 312 | { 313 | const int WarmupCount = 5; 314 | const int MeasurementCount = 100; 315 | [TearDown] 316 | public void TearDown() 317 | { 318 | GC.Collect(); 319 | } 320 | public static int A; 321 | private FieldInfo _fieldInfo=typeof(BenchmarkStaticIntField).GetField(nameof(A),BindingFlags.Static|BindingFlags.Public); 322 | [Test, Performance] 323 | public void SetDirect() 324 | { 325 | Measure.Method(() => 326 | { 327 | [MethodImpl(MethodImplOptions.NoInlining)] 328 | static void Set(int x) => A=x; 329 | for (int i = 0; i < 1000; i++) 330 | { 331 | Set(1); 332 | } 333 | }) 334 | .WarmupCount(WarmupCount) 335 | .MeasurementCount(MeasurementCount) 336 | .SampleGroup(new SampleGroup("Set Static Int Field directly", SampleUnit.Microsecond)) 337 | .Run(); 338 | } 339 | [Test, Performance] 340 | public void GetDirect() 341 | { 342 | Measure.Method(() => 343 | { 344 | [MethodImpl(MethodImplOptions.NoInlining)] 345 | static int Get() => A; 346 | for (int i = 0; i < 1000; i++) 347 | { 348 | Get(); 349 | } 350 | }) 351 | .WarmupCount(WarmupCount) 352 | .MeasurementCount(MeasurementCount) 353 | .SampleGroup(new SampleGroup("Get Static Int Field directly", SampleUnit.Microsecond)) 354 | .Run(); 355 | } 356 | [Test, Performance] 357 | public void SetReflection() 358 | { 359 | Measure.Method(() => 360 | { 361 | 362 | var f= _fieldInfo; 363 | for (int i = 0; i < 1000; i++) 364 | { 365 | f.SetValue(null,1); 366 | } 367 | }) 368 | .WarmupCount(WarmupCount) 369 | .MeasurementCount(MeasurementCount) 370 | .SampleGroup(new SampleGroup("Set Static Int Field via FieldInfo", SampleUnit.Microsecond)) 371 | .Run(); 372 | } 373 | [Test, Performance] 374 | public void GetReflection() 375 | { 376 | Measure.Method(() => 377 | { 378 | 379 | var f= _fieldInfo; 380 | for (int i = 0; i < 1000; i++) 381 | { 382 | f.GetValue(null); 383 | } 384 | }) 385 | .WarmupCount(WarmupCount) 386 | .MeasurementCount(MeasurementCount) 387 | .SampleGroup(new SampleGroup("Get Static Int Field via FieldInfo", SampleUnit.Microsecond)) 388 | .Run(); 389 | } 390 | [Test, Performance] 391 | public void SetSetter() 392 | { 393 | Measure.Method(() => 394 | { 395 | var set =_fieldInfo.CreateStaticFieldSetter(); 396 | for (int i = 0; i < 1000; i++) 397 | { 398 | set(1); 399 | } 400 | }) 401 | .WarmupCount(WarmupCount) 402 | .MeasurementCount(MeasurementCount) 403 | .SampleGroup(new SampleGroup("Set Static Int Field via CachedSetter", SampleUnit.Microsecond)) 404 | .Run(); 405 | } 406 | [Test, Performance] 407 | public void GetGetter() 408 | { 409 | Measure.Method(() => 410 | { 411 | var getter =_fieldInfo.CreateStaticFieldGetter(); 412 | for (int i = 0; i < 1000; i++) 413 | { 414 | getter(); 415 | } 416 | }) 417 | .WarmupCount(WarmupCount) 418 | .MeasurementCount(MeasurementCount) 419 | .SampleGroup(new SampleGroup("Get Static Int Field via CachedGetter", SampleUnit.Microsecond)) 420 | .Run(); 421 | } 422 | } 423 | public class BenchmarkStaticStringField 424 | { 425 | const int WarmupCount = 5; 426 | const int MeasurementCount = 100; 427 | [TearDown] 428 | public void TearDown() 429 | { 430 | GC.Collect(); 431 | } 432 | public static string A; 433 | private FieldInfo _fieldInfo=typeof(BenchmarkStaticStringField).GetField(nameof(A),BindingFlags.Static|BindingFlags.Public); 434 | [Test, Performance] 435 | public void SetDirect() 436 | { 437 | Measure.Method(() => 438 | { 439 | [MethodImpl(MethodImplOptions.NoInlining)] 440 | static void Set(string x) => A=x; 441 | for (int i = 0; i < 1000; i++) 442 | { 443 | Set("1"); 444 | } 445 | }) 446 | .WarmupCount(WarmupCount) 447 | .MeasurementCount(MeasurementCount) 448 | .SampleGroup(new SampleGroup("Set static string field directly", SampleUnit.Microsecond)) 449 | .Run(); 450 | } 451 | [Test, Performance] 452 | public void GetDirect() 453 | { 454 | Measure.Method(() => 455 | { 456 | [MethodImpl(MethodImplOptions.NoInlining)] 457 | static string Get() => A; 458 | for (int i = 0; i < 1000; i++) 459 | { 460 | Get(); 461 | } 462 | }) 463 | .WarmupCount(WarmupCount) 464 | .MeasurementCount(MeasurementCount) 465 | .SampleGroup(new SampleGroup("Get static string field directly", SampleUnit.Microsecond)) 466 | .Run(); 467 | } 468 | [Test, Performance] 469 | public void SetReflection() 470 | { 471 | Measure.Method(() => 472 | { 473 | 474 | var f = _fieldInfo; 475 | for (int i = 0; i < 1000; i++) 476 | { 477 | f.SetValue(null,"1"); 478 | } 479 | }) 480 | .WarmupCount(WarmupCount) 481 | .MeasurementCount(MeasurementCount) 482 | .SampleGroup(new SampleGroup("Set static string field via FieldInfo", SampleUnit.Microsecond)) 483 | .Run(); 484 | } 485 | [Test, Performance] 486 | public void GetReflection() 487 | { 488 | Measure.Method(() => 489 | { 490 | 491 | var f = _fieldInfo; 492 | for (int i = 0; i < 1000; i++) 493 | { 494 | f.GetValue(null); 495 | } 496 | }) 497 | .WarmupCount(WarmupCount) 498 | .MeasurementCount(MeasurementCount) 499 | .SampleGroup(new SampleGroup("Get static string field via FieldInfo", SampleUnit.Microsecond)) 500 | .Run(); 501 | } 502 | [Test, Performance] 503 | public void SetSetter() 504 | { 505 | Measure.Method(() => 506 | { 507 | var set =_fieldInfo.CreateStaticFieldSetter(); 508 | for (int i = 0; i < 1000; i++) 509 | { 510 | set("1"); 511 | } 512 | }) 513 | .WarmupCount(WarmupCount) 514 | .MeasurementCount(MeasurementCount) 515 | .SampleGroup(new SampleGroup("Set static string field via CachedSetter", SampleUnit.Microsecond)) 516 | .Run(); 517 | } 518 | [Test, Performance] 519 | public void GetGetter() 520 | { 521 | Measure.Method(() => 522 | { 523 | var getter =_fieldInfo.CreateStaticFieldGetter(); 524 | for (int i = 0; i < 1000; i++) 525 | { 526 | getter(); 527 | } 528 | }) 529 | .WarmupCount(WarmupCount) 530 | .MeasurementCount(MeasurementCount) 531 | .SampleGroup(new SampleGroup("Get static string field via CachedGetter", SampleUnit.Microsecond)) 532 | .Run(); 533 | } 534 | } 535 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Tests/Benchmark.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82d53694bba74d12b35c243d7b35a406 3 | timeCreated: 1703479367 -------------------------------------------------------------------------------- /Assets/UniReflection/Tests/UniReflection.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UniReflection.Tests", 3 | "rootNamespace": "", 4 | "references": [ 5 | "GUID:0c0d079cb9bcd8644a539f29f8e4142c", 6 | "GUID:91e66e2e63b788444bb2dab4b253479b", 7 | "GUID:c0dd0d10738d4ad4a9de57c559d0ca1b", 8 | "GUID:27619889b8ba8c24980f49ee34dbb44a", 9 | "GUID:0acc523941302664db1f4e527237feb3" 10 | ], 11 | "includePlatforms": [], 12 | "excludePlatforms": [], 13 | "allowUnsafeCode": false, 14 | "overrideReferences": true, 15 | "precompiledReferences": [ 16 | "nunit.framework.dll" 17 | ], 18 | "autoReferenced": true, 19 | "defineConstraints": [ 20 | "UNITY_INCLUDE_TESTS" 21 | ], 22 | "versionDefines": [], 23 | "noEngineReferences": false 24 | } -------------------------------------------------------------------------------- /Assets/UniReflection/Tests/UniReflection.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e9d5c0dfefdf5941879c964e27079fe 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/UniReflection/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.akeit0.uni-reflection", 3 | "version": "0.1.0", 4 | "displayName": "UniReflection", 5 | "description": "Reflection Utilities for UnityEngin 2022.2~2023.1 including IL2CPP", 6 | "unity": "2022.2", 7 | "author": { 8 | "name": "Akeit0", 9 | "url": "https://github.com/Akeit0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Assets/UniReflection/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21643b9336e5485f8da2c1d8d149f9d7 3 | timeCreated: 1703477432 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Akeit0 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Media/StaticField.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akeit0/UniReflection/32b4dfb0a87d7019408d534707cf2cda0d3c777a/Media/StaticField.png -------------------------------------------------------------------------------- /Media/new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Akeit0/UniReflection/32b4dfb0a87d7019408d534707cf2cda0d3c777a/Media/new.png -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.burst": "1.8.11", 4 | "com.unity.collab-proxy": "2.1.0", 5 | "com.unity.feature.development": "1.0.1", 6 | "com.unity.nuget.mono-cecil": "1.11.4", 7 | "com.unity.test-framework.performance": "3.0.3", 8 | "com.unity.textmeshpro": "3.0.6", 9 | "com.unity.timeline": "1.7.5", 10 | "com.unity.ugui": "1.0.0", 11 | "com.unity.visualscripting": "1.9.1", 12 | "com.unity.modules.ai": "1.0.0", 13 | "com.unity.modules.androidjni": "1.0.0", 14 | "com.unity.modules.animation": "1.0.0", 15 | "com.unity.modules.assetbundle": "1.0.0", 16 | "com.unity.modules.audio": "1.0.0", 17 | "com.unity.modules.cloth": "1.0.0", 18 | "com.unity.modules.director": "1.0.0", 19 | "com.unity.modules.imageconversion": "1.0.0", 20 | "com.unity.modules.imgui": "1.0.0", 21 | "com.unity.modules.jsonserialize": "1.0.0", 22 | "com.unity.modules.particlesystem": "1.0.0", 23 | "com.unity.modules.physics": "1.0.0", 24 | "com.unity.modules.physics2d": "1.0.0", 25 | "com.unity.modules.screencapture": "1.0.0", 26 | "com.unity.modules.terrain": "1.0.0", 27 | "com.unity.modules.terrainphysics": "1.0.0", 28 | "com.unity.modules.tilemap": "1.0.0", 29 | "com.unity.modules.ui": "1.0.0", 30 | "com.unity.modules.uielements": "1.0.0", 31 | "com.unity.modules.umbra": "1.0.0", 32 | "com.unity.modules.unityanalytics": "1.0.0", 33 | "com.unity.modules.unitywebrequest": "1.0.0", 34 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 35 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 36 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 37 | "com.unity.modules.unitywebrequestwww": "1.0.0", 38 | "com.unity.modules.vehicles": "1.0.0", 39 | "com.unity.modules.video": "1.0.0", 40 | "com.unity.modules.vr": "1.0.0", 41 | "com.unity.modules.wind": "1.0.0", 42 | "com.unity.modules.xr": "1.0.0" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.burst": { 4 | "version": "1.8.11", 5 | "depth": 0, 6 | "source": "registry", 7 | "dependencies": { 8 | "com.unity.mathematics": "1.2.1" 9 | }, 10 | "url": "https://packages.unity.com" 11 | }, 12 | "com.unity.collab-proxy": { 13 | "version": "2.1.0", 14 | "depth": 0, 15 | "source": "registry", 16 | "dependencies": {}, 17 | "url": "https://packages.unity.com" 18 | }, 19 | "com.unity.editorcoroutines": { 20 | "version": "1.0.0", 21 | "depth": 1, 22 | "source": "registry", 23 | "dependencies": {}, 24 | "url": "https://packages.unity.com" 25 | }, 26 | "com.unity.ext.nunit": { 27 | "version": "1.0.6", 28 | "depth": 2, 29 | "source": "registry", 30 | "dependencies": {}, 31 | "url": "https://packages.unity.com" 32 | }, 33 | "com.unity.feature.development": { 34 | "version": "1.0.1", 35 | "depth": 0, 36 | "source": "builtin", 37 | "dependencies": { 38 | "com.unity.ide.visualstudio": "2.0.21", 39 | "com.unity.ide.rider": "3.0.25", 40 | "com.unity.ide.vscode": "1.2.5", 41 | "com.unity.editorcoroutines": "1.0.0", 42 | "com.unity.performance.profile-analyzer": "1.2.2", 43 | "com.unity.test-framework": "1.1.33", 44 | "com.unity.testtools.codecoverage": "1.2.4" 45 | } 46 | }, 47 | "com.unity.ide.rider": { 48 | "version": "3.0.25", 49 | "depth": 1, 50 | "source": "registry", 51 | "dependencies": { 52 | "com.unity.ext.nunit": "1.0.6" 53 | }, 54 | "url": "https://packages.unity.com" 55 | }, 56 | "com.unity.ide.visualstudio": { 57 | "version": "2.0.21", 58 | "depth": 1, 59 | "source": "registry", 60 | "dependencies": { 61 | "com.unity.test-framework": "1.1.9" 62 | }, 63 | "url": "https://packages.unity.com" 64 | }, 65 | "com.unity.ide.vscode": { 66 | "version": "1.2.5", 67 | "depth": 1, 68 | "source": "registry", 69 | "dependencies": {}, 70 | "url": "https://packages.unity.com" 71 | }, 72 | "com.unity.mathematics": { 73 | "version": "1.2.6", 74 | "depth": 1, 75 | "source": "registry", 76 | "dependencies": {}, 77 | "url": "https://packages.unity.com" 78 | }, 79 | "com.unity.nuget.mono-cecil": { 80 | "version": "1.11.4", 81 | "depth": 0, 82 | "source": "registry", 83 | "dependencies": {}, 84 | "url": "https://packages.unity.com" 85 | }, 86 | "com.unity.performance.profile-analyzer": { 87 | "version": "1.2.2", 88 | "depth": 1, 89 | "source": "registry", 90 | "dependencies": {}, 91 | "url": "https://packages.unity.com" 92 | }, 93 | "com.unity.settings-manager": { 94 | "version": "2.0.1", 95 | "depth": 2, 96 | "source": "registry", 97 | "dependencies": {}, 98 | "url": "https://packages.unity.com" 99 | }, 100 | "com.unity.test-framework": { 101 | "version": "1.1.33", 102 | "depth": 1, 103 | "source": "registry", 104 | "dependencies": { 105 | "com.unity.ext.nunit": "1.0.6", 106 | "com.unity.modules.imgui": "1.0.0", 107 | "com.unity.modules.jsonserialize": "1.0.0" 108 | }, 109 | "url": "https://packages.unity.com" 110 | }, 111 | "com.unity.test-framework.performance": { 112 | "version": "3.0.3", 113 | "depth": 0, 114 | "source": "registry", 115 | "dependencies": { 116 | "com.unity.test-framework": "1.1.31", 117 | "com.unity.modules.jsonserialize": "1.0.0" 118 | }, 119 | "url": "https://packages.unity.com" 120 | }, 121 | "com.unity.testtools.codecoverage": { 122 | "version": "1.2.4", 123 | "depth": 1, 124 | "source": "registry", 125 | "dependencies": { 126 | "com.unity.test-framework": "1.0.16", 127 | "com.unity.settings-manager": "1.0.1" 128 | }, 129 | "url": "https://packages.unity.com" 130 | }, 131 | "com.unity.textmeshpro": { 132 | "version": "3.0.6", 133 | "depth": 0, 134 | "source": "registry", 135 | "dependencies": { 136 | "com.unity.ugui": "1.0.0" 137 | }, 138 | "url": "https://packages.unity.com" 139 | }, 140 | "com.unity.timeline": { 141 | "version": "1.7.5", 142 | "depth": 0, 143 | "source": "registry", 144 | "dependencies": { 145 | "com.unity.modules.director": "1.0.0", 146 | "com.unity.modules.animation": "1.0.0", 147 | "com.unity.modules.audio": "1.0.0", 148 | "com.unity.modules.particlesystem": "1.0.0" 149 | }, 150 | "url": "https://packages.unity.com" 151 | }, 152 | "com.unity.ugui": { 153 | "version": "1.0.0", 154 | "depth": 0, 155 | "source": "builtin", 156 | "dependencies": { 157 | "com.unity.modules.ui": "1.0.0", 158 | "com.unity.modules.imgui": "1.0.0" 159 | } 160 | }, 161 | "com.unity.visualscripting": { 162 | "version": "1.9.1", 163 | "depth": 0, 164 | "source": "registry", 165 | "dependencies": { 166 | "com.unity.ugui": "1.0.0", 167 | "com.unity.modules.jsonserialize": "1.0.0" 168 | }, 169 | "url": "https://packages.unity.com" 170 | }, 171 | "com.unity.modules.ai": { 172 | "version": "1.0.0", 173 | "depth": 0, 174 | "source": "builtin", 175 | "dependencies": {} 176 | }, 177 | "com.unity.modules.androidjni": { 178 | "version": "1.0.0", 179 | "depth": 0, 180 | "source": "builtin", 181 | "dependencies": {} 182 | }, 183 | "com.unity.modules.animation": { 184 | "version": "1.0.0", 185 | "depth": 0, 186 | "source": "builtin", 187 | "dependencies": {} 188 | }, 189 | "com.unity.modules.assetbundle": { 190 | "version": "1.0.0", 191 | "depth": 0, 192 | "source": "builtin", 193 | "dependencies": {} 194 | }, 195 | "com.unity.modules.audio": { 196 | "version": "1.0.0", 197 | "depth": 0, 198 | "source": "builtin", 199 | "dependencies": {} 200 | }, 201 | "com.unity.modules.cloth": { 202 | "version": "1.0.0", 203 | "depth": 0, 204 | "source": "builtin", 205 | "dependencies": { 206 | "com.unity.modules.physics": "1.0.0" 207 | } 208 | }, 209 | "com.unity.modules.director": { 210 | "version": "1.0.0", 211 | "depth": 0, 212 | "source": "builtin", 213 | "dependencies": { 214 | "com.unity.modules.audio": "1.0.0", 215 | "com.unity.modules.animation": "1.0.0" 216 | } 217 | }, 218 | "com.unity.modules.imageconversion": { 219 | "version": "1.0.0", 220 | "depth": 0, 221 | "source": "builtin", 222 | "dependencies": {} 223 | }, 224 | "com.unity.modules.imgui": { 225 | "version": "1.0.0", 226 | "depth": 0, 227 | "source": "builtin", 228 | "dependencies": {} 229 | }, 230 | "com.unity.modules.jsonserialize": { 231 | "version": "1.0.0", 232 | "depth": 0, 233 | "source": "builtin", 234 | "dependencies": {} 235 | }, 236 | "com.unity.modules.particlesystem": { 237 | "version": "1.0.0", 238 | "depth": 0, 239 | "source": "builtin", 240 | "dependencies": {} 241 | }, 242 | "com.unity.modules.physics": { 243 | "version": "1.0.0", 244 | "depth": 0, 245 | "source": "builtin", 246 | "dependencies": {} 247 | }, 248 | "com.unity.modules.physics2d": { 249 | "version": "1.0.0", 250 | "depth": 0, 251 | "source": "builtin", 252 | "dependencies": {} 253 | }, 254 | "com.unity.modules.screencapture": { 255 | "version": "1.0.0", 256 | "depth": 0, 257 | "source": "builtin", 258 | "dependencies": { 259 | "com.unity.modules.imageconversion": "1.0.0" 260 | } 261 | }, 262 | "com.unity.modules.subsystems": { 263 | "version": "1.0.0", 264 | "depth": 1, 265 | "source": "builtin", 266 | "dependencies": { 267 | "com.unity.modules.jsonserialize": "1.0.0" 268 | } 269 | }, 270 | "com.unity.modules.terrain": { 271 | "version": "1.0.0", 272 | "depth": 0, 273 | "source": "builtin", 274 | "dependencies": {} 275 | }, 276 | "com.unity.modules.terrainphysics": { 277 | "version": "1.0.0", 278 | "depth": 0, 279 | "source": "builtin", 280 | "dependencies": { 281 | "com.unity.modules.physics": "1.0.0", 282 | "com.unity.modules.terrain": "1.0.0" 283 | } 284 | }, 285 | "com.unity.modules.tilemap": { 286 | "version": "1.0.0", 287 | "depth": 0, 288 | "source": "builtin", 289 | "dependencies": { 290 | "com.unity.modules.physics2d": "1.0.0" 291 | } 292 | }, 293 | "com.unity.modules.ui": { 294 | "version": "1.0.0", 295 | "depth": 0, 296 | "source": "builtin", 297 | "dependencies": {} 298 | }, 299 | "com.unity.modules.uielements": { 300 | "version": "1.0.0", 301 | "depth": 0, 302 | "source": "builtin", 303 | "dependencies": { 304 | "com.unity.modules.ui": "1.0.0", 305 | "com.unity.modules.imgui": "1.0.0", 306 | "com.unity.modules.jsonserialize": "1.0.0" 307 | } 308 | }, 309 | "com.unity.modules.umbra": { 310 | "version": "1.0.0", 311 | "depth": 0, 312 | "source": "builtin", 313 | "dependencies": {} 314 | }, 315 | "com.unity.modules.unityanalytics": { 316 | "version": "1.0.0", 317 | "depth": 0, 318 | "source": "builtin", 319 | "dependencies": { 320 | "com.unity.modules.unitywebrequest": "1.0.0", 321 | "com.unity.modules.jsonserialize": "1.0.0" 322 | } 323 | }, 324 | "com.unity.modules.unitywebrequest": { 325 | "version": "1.0.0", 326 | "depth": 0, 327 | "source": "builtin", 328 | "dependencies": {} 329 | }, 330 | "com.unity.modules.unitywebrequestassetbundle": { 331 | "version": "1.0.0", 332 | "depth": 0, 333 | "source": "builtin", 334 | "dependencies": { 335 | "com.unity.modules.assetbundle": "1.0.0", 336 | "com.unity.modules.unitywebrequest": "1.0.0" 337 | } 338 | }, 339 | "com.unity.modules.unitywebrequestaudio": { 340 | "version": "1.0.0", 341 | "depth": 0, 342 | "source": "builtin", 343 | "dependencies": { 344 | "com.unity.modules.unitywebrequest": "1.0.0", 345 | "com.unity.modules.audio": "1.0.0" 346 | } 347 | }, 348 | "com.unity.modules.unitywebrequesttexture": { 349 | "version": "1.0.0", 350 | "depth": 0, 351 | "source": "builtin", 352 | "dependencies": { 353 | "com.unity.modules.unitywebrequest": "1.0.0", 354 | "com.unity.modules.imageconversion": "1.0.0" 355 | } 356 | }, 357 | "com.unity.modules.unitywebrequestwww": { 358 | "version": "1.0.0", 359 | "depth": 0, 360 | "source": "builtin", 361 | "dependencies": { 362 | "com.unity.modules.unitywebrequest": "1.0.0", 363 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 364 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 365 | "com.unity.modules.audio": "1.0.0", 366 | "com.unity.modules.assetbundle": "1.0.0", 367 | "com.unity.modules.imageconversion": "1.0.0" 368 | } 369 | }, 370 | "com.unity.modules.vehicles": { 371 | "version": "1.0.0", 372 | "depth": 0, 373 | "source": "builtin", 374 | "dependencies": { 375 | "com.unity.modules.physics": "1.0.0" 376 | } 377 | }, 378 | "com.unity.modules.video": { 379 | "version": "1.0.0", 380 | "depth": 0, 381 | "source": "builtin", 382 | "dependencies": { 383 | "com.unity.modules.audio": "1.0.0", 384 | "com.unity.modules.ui": "1.0.0", 385 | "com.unity.modules.unitywebrequest": "1.0.0" 386 | } 387 | }, 388 | "com.unity.modules.vr": { 389 | "version": "1.0.0", 390 | "depth": 0, 391 | "source": "builtin", 392 | "dependencies": { 393 | "com.unity.modules.jsonserialize": "1.0.0", 394 | "com.unity.modules.physics": "1.0.0", 395 | "com.unity.modules.xr": "1.0.0" 396 | } 397 | }, 398 | "com.unity.modules.wind": { 399 | "version": "1.0.0", 400 | "depth": 0, 401 | "source": "builtin", 402 | "dependencies": {} 403 | }, 404 | "com.unity.modules.xr": { 405 | "version": "1.0.0", 406 | "depth": 0, 407 | "source": "builtin", 408 | "dependencies": { 409 | "com.unity.modules.physics": "1.0.0", 410 | "com.unity.modules.jsonserialize": "1.0.0", 411 | "com.unity.modules.subsystems": "1.0.0" 412 | } 413 | } 414 | } 415 | } 416 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /ProjectSettings/BurstAotSettings_StandaloneWindows.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "Version": 4, 4 | "EnableBurstCompilation": true, 5 | "EnableOptimisations": true, 6 | "EnableSafetyChecks": false, 7 | "EnableDebugInAllBuilds": false, 8 | "DebugDataKind": 1, 9 | "EnableArmv9SecurityFeatures": false, 10 | "CpuMinTargetX32": 0, 11 | "CpuMaxTargetX32": 0, 12 | "CpuMinTargetX64": 0, 13 | "CpuMaxTargetX64": 0, 14 | "CpuTargetsX32": 6, 15 | "CpuTargetsX64": 72, 16 | "OptimizeFor": 0 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/CommonBurstAotSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "Version": 4, 4 | "DisabledWarnings": "" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 0 9 | path: Assets/Tests3/New Scene.unity 10 | guid: 79b4517cf6a267741ad09d24138e3689 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_SerializationMode: 2 8 | m_LineEndingsForNewScripts: 0 9 | m_DefaultBehaviorMode: 0 10 | m_PrefabRegularEnvironment: {fileID: 0} 11 | m_PrefabUIEnvironment: {fileID: 0} 12 | m_SpritePackerMode: 0 13 | m_SpritePackerCacheSize: 10 14 | m_SpritePackerPaddingPower: 1 15 | m_Bc7TextureCompressor: 0 16 | m_EtcTextureCompressorBehavior: 1 17 | m_EtcTextureFastCompressor: 1 18 | m_EtcTextureNormalCompressor: 2 19 | m_EtcTextureBestCompressor: 4 20 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 21 | m_ProjectGenerationRootNamespace: 22 | m_EnableTextureStreamingInEditMode: 1 23 | m_EnableTextureStreamingInPlayMode: 1 24 | m_EnableEditorAsyncCPUTextureLoading: 0 25 | m_AsyncShaderCompilation: 1 26 | m_PrefabModeAllowAutoSave: 1 27 | m_EnterPlayModeOptionsEnabled: 1 28 | m_EnterPlayModeOptions: 3 29 | m_GameObjectNamingDigits: 1 30 | m_GameObjectNamingScheme: 0 31 | m_AssetNamingUsesSpace: 1 32 | m_InspectorUseIMGUIDefaultInspector: 0 33 | m_UseLegacyProbeSampleCount: 0 34 | m_SerializeInlineMappingsOnOneLine: 1 35 | m_DisableCookiesInLightmapper: 0 36 | m_AssetPipelineMode: 1 37 | m_RefreshImportMode: 0 38 | m_CacheServerMode: 0 39 | m_CacheServerEndpoint: 40 | m_CacheServerNamespacePrefix: default 41 | m_CacheServerEnableDownload: 1 42 | m_CacheServerEnableUpload: 1 43 | m_CacheServerEnableAuth: 0 44 | m_CacheServerEnableTls: 0 45 | m_CacheServerValidationMode: 2 46 | m_CacheServerDownloadBatchSize: 128 47 | m_EnableEnlightenBakedGI: 0 48 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_CustomRenderPipeline: {fileID: 0} 42 | m_TransparencySortMode: 0 43 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 44 | m_DefaultRenderingPath: 1 45 | m_DefaultMobileRenderingPath: 1 46 | m_TierSettings: [] 47 | m_LightmapStripping: 0 48 | m_FogStripping: 0 49 | m_InstancingStripping: 0 50 | m_LightmapKeepPlain: 1 51 | m_LightmapKeepDirCombined: 1 52 | m_LightmapKeepDynamicPlain: 1 53 | m_LightmapKeepDynamicDirCombined: 1 54 | m_LightmapKeepShadowMask: 1 55 | m_LightmapKeepSubtractive: 1 56 | m_FogKeepLinear: 1 57 | m_FogKeepExp: 1 58 | m_FogKeepExp2: 1 59 | m_AlbedoSwatchInfos: [] 60 | m_LightsUseLinearIntensity: 0 61 | m_LightsUseColorTemperature: 0 62 | m_LogWhenShaderIsCompiled: 0 63 | m_AllowEnlightenSupportForUpgradedProject: 0 64 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreReleasePackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | m_SeeAllPackageVersions: 0 20 | oneTimeWarningShown: 0 21 | m_Registries: 22 | - m_Id: main 23 | m_Name: 24 | m_Url: https://packages.unity.com 25 | m_Scopes: [] 26 | m_IsDefault: 1 27 | m_Capabilities: 7 28 | m_UserSelectedRegistryName: 29 | m_UserAddingNewScopedRegistry: 0 30 | m_RegistryInfoDraft: 31 | m_Modified: 0 32 | m_ErrorMessage: 33 | m_UserModificationsInstanceId: -830 34 | m_OriginalInstanceId: -832 35 | m_LoadAssets: 0 36 | -------------------------------------------------------------------------------- /ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "m_Dictionary": { 3 | "m_DictionaryValues": [] 4 | } 5 | } -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2022.3.11f1 2 | m_EditorVersionWithRevision: 2022.3.11f1 (d00248457e15) 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 4 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | excludedTargetPlatforms: [] 44 | - serializedVersion: 2 45 | name: Low 46 | pixelLightCount: 0 47 | shadows: 0 48 | shadowResolution: 0 49 | shadowProjection: 1 50 | shadowCascades: 1 51 | shadowDistance: 20 52 | shadowNearPlaneOffset: 3 53 | shadowCascade2Split: 0.33333334 54 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 55 | shadowmaskMode: 0 56 | blendWeights: 2 57 | textureQuality: 0 58 | anisotropicTextures: 0 59 | antiAliasing: 0 60 | softParticles: 0 61 | softVegetation: 0 62 | realtimeReflectionProbes: 0 63 | billboardsFaceCameraPosition: 0 64 | vSyncCount: 0 65 | lodBias: 0.4 66 | maximumLODLevel: 0 67 | streamingMipmapsActive: 0 68 | streamingMipmapsAddAllCameras: 1 69 | streamingMipmapsMemoryBudget: 512 70 | streamingMipmapsRenderersPerFrame: 512 71 | streamingMipmapsMaxLevelReduction: 2 72 | streamingMipmapsMaxFileIORequests: 1024 73 | particleRaycastBudget: 16 74 | asyncUploadTimeSlice: 2 75 | asyncUploadBufferSize: 16 76 | asyncUploadPersistentBuffer: 1 77 | resolutionScalingFixedDPIFactor: 1 78 | excludedTargetPlatforms: [] 79 | - serializedVersion: 2 80 | name: Medium 81 | pixelLightCount: 1 82 | shadows: 1 83 | shadowResolution: 0 84 | shadowProjection: 1 85 | shadowCascades: 1 86 | shadowDistance: 20 87 | shadowNearPlaneOffset: 3 88 | shadowCascade2Split: 0.33333334 89 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 90 | shadowmaskMode: 0 91 | blendWeights: 2 92 | textureQuality: 0 93 | anisotropicTextures: 1 94 | antiAliasing: 0 95 | softParticles: 0 96 | softVegetation: 0 97 | realtimeReflectionProbes: 0 98 | billboardsFaceCameraPosition: 0 99 | vSyncCount: 1 100 | lodBias: 0.7 101 | maximumLODLevel: 0 102 | streamingMipmapsActive: 0 103 | streamingMipmapsAddAllCameras: 1 104 | streamingMipmapsMemoryBudget: 512 105 | streamingMipmapsRenderersPerFrame: 512 106 | streamingMipmapsMaxLevelReduction: 2 107 | streamingMipmapsMaxFileIORequests: 1024 108 | particleRaycastBudget: 64 109 | asyncUploadTimeSlice: 2 110 | asyncUploadBufferSize: 16 111 | asyncUploadPersistentBuffer: 1 112 | resolutionScalingFixedDPIFactor: 1 113 | excludedTargetPlatforms: [] 114 | - serializedVersion: 2 115 | name: High 116 | pixelLightCount: 2 117 | shadows: 2 118 | shadowResolution: 1 119 | shadowProjection: 1 120 | shadowCascades: 2 121 | shadowDistance: 40 122 | shadowNearPlaneOffset: 3 123 | shadowCascade2Split: 0.33333334 124 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 125 | shadowmaskMode: 1 126 | blendWeights: 2 127 | textureQuality: 0 128 | anisotropicTextures: 1 129 | antiAliasing: 0 130 | softParticles: 0 131 | softVegetation: 1 132 | realtimeReflectionProbes: 1 133 | billboardsFaceCameraPosition: 1 134 | vSyncCount: 1 135 | lodBias: 1 136 | maximumLODLevel: 0 137 | streamingMipmapsActive: 0 138 | streamingMipmapsAddAllCameras: 1 139 | streamingMipmapsMemoryBudget: 512 140 | streamingMipmapsRenderersPerFrame: 512 141 | streamingMipmapsMaxLevelReduction: 2 142 | streamingMipmapsMaxFileIORequests: 1024 143 | particleRaycastBudget: 256 144 | asyncUploadTimeSlice: 2 145 | asyncUploadBufferSize: 16 146 | asyncUploadPersistentBuffer: 1 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Very High 151 | pixelLightCount: 3 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 2 156 | shadowDistance: 70 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 1.5 171 | maximumLODLevel: 0 172 | streamingMipmapsActive: 0 173 | streamingMipmapsAddAllCameras: 1 174 | streamingMipmapsMemoryBudget: 512 175 | streamingMipmapsRenderersPerFrame: 512 176 | streamingMipmapsMaxLevelReduction: 2 177 | streamingMipmapsMaxFileIORequests: 1024 178 | particleRaycastBudget: 1024 179 | asyncUploadTimeSlice: 2 180 | asyncUploadBufferSize: 16 181 | asyncUploadPersistentBuffer: 1 182 | resolutionScalingFixedDPIFactor: 1 183 | excludedTargetPlatforms: [] 184 | - serializedVersion: 2 185 | name: Ultra 186 | pixelLightCount: 4 187 | shadows: 2 188 | shadowResolution: 2 189 | shadowProjection: 1 190 | shadowCascades: 4 191 | shadowDistance: 150 192 | shadowNearPlaneOffset: 3 193 | shadowCascade2Split: 0.33333334 194 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 195 | shadowmaskMode: 1 196 | blendWeights: 4 197 | textureQuality: 0 198 | anisotropicTextures: 2 199 | antiAliasing: 2 200 | softParticles: 1 201 | softVegetation: 1 202 | realtimeReflectionProbes: 1 203 | billboardsFaceCameraPosition: 1 204 | vSyncCount: 1 205 | lodBias: 2 206 | maximumLODLevel: 0 207 | streamingMipmapsActive: 0 208 | streamingMipmapsAddAllCameras: 1 209 | streamingMipmapsMemoryBudget: 512 210 | streamingMipmapsRenderersPerFrame: 512 211 | streamingMipmapsMaxLevelReduction: 2 212 | streamingMipmapsMaxFileIORequests: 1024 213 | particleRaycastBudget: 4096 214 | asyncUploadTimeSlice: 2 215 | asyncUploadBufferSize: 16 216 | asyncUploadPersistentBuffer: 1 217 | resolutionScalingFixedDPIFactor: 1 218 | excludedTargetPlatforms: [] 219 | m_PerPlatformDefaultQuality: 220 | Android: 2 221 | Lumin: 5 222 | Nintendo 3DS: 5 223 | Nintendo Switch: 5 224 | PS4: 5 225 | PSP2: 2 226 | Stadia: 5 227 | Standalone: 5 228 | WebGL: 3 229 | Windows Store Apps: 5 230 | XboxOne: 5 231 | iPhone: 2 232 | tvOS: 2 233 | -------------------------------------------------------------------------------- /ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "defaultInstantiationMode": 0 8 | }, 9 | { 10 | "userAdded": false, 11 | "type": "UnityEditor.Animations.AnimatorController", 12 | "defaultInstantiationMode": 0 13 | }, 14 | { 15 | "userAdded": false, 16 | "type": "UnityEngine.AnimatorOverrideController", 17 | "defaultInstantiationMode": 0 18 | }, 19 | { 20 | "userAdded": false, 21 | "type": "UnityEditor.Audio.AudioMixerController", 22 | "defaultInstantiationMode": 0 23 | }, 24 | { 25 | "userAdded": false, 26 | "type": "UnityEngine.ComputeShader", 27 | "defaultInstantiationMode": 1 28 | }, 29 | { 30 | "userAdded": false, 31 | "type": "UnityEngine.Cubemap", 32 | "defaultInstantiationMode": 0 33 | }, 34 | { 35 | "userAdded": false, 36 | "type": "UnityEngine.GameObject", 37 | "defaultInstantiationMode": 0 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEditor.LightingDataAsset", 42 | "defaultInstantiationMode": 0 43 | }, 44 | { 45 | "userAdded": false, 46 | "type": "UnityEngine.LightingSettings", 47 | "defaultInstantiationMode": 0 48 | }, 49 | { 50 | "userAdded": false, 51 | "type": "UnityEngine.Material", 52 | "defaultInstantiationMode": 0 53 | }, 54 | { 55 | "userAdded": false, 56 | "type": "UnityEditor.MonoScript", 57 | "defaultInstantiationMode": 1 58 | }, 59 | { 60 | "userAdded": false, 61 | "type": "UnityEngine.PhysicMaterial", 62 | "defaultInstantiationMode": 0 63 | }, 64 | { 65 | "userAdded": false, 66 | "type": "UnityEngine.PhysicsMaterial2D", 67 | "defaultInstantiationMode": 0 68 | }, 69 | { 70 | "userAdded": false, 71 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 72 | "defaultInstantiationMode": 0 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 77 | "defaultInstantiationMode": 0 78 | }, 79 | { 80 | "userAdded": false, 81 | "type": "UnityEngine.Rendering.VolumeProfile", 82 | "defaultInstantiationMode": 0 83 | }, 84 | { 85 | "userAdded": false, 86 | "type": "UnityEditor.SceneAsset", 87 | "defaultInstantiationMode": 1 88 | }, 89 | { 90 | "userAdded": false, 91 | "type": "UnityEngine.Shader", 92 | "defaultInstantiationMode": 1 93 | }, 94 | { 95 | "userAdded": false, 96 | "type": "UnityEngine.ShaderVariantCollection", 97 | "defaultInstantiationMode": 1 98 | }, 99 | { 100 | "userAdded": false, 101 | "type": "UnityEngine.Texture", 102 | "defaultInstantiationMode": 0 103 | }, 104 | { 105 | "userAdded": false, 106 | "type": "UnityEngine.Texture2D", 107 | "defaultInstantiationMode": 0 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Timeline.TimelineAsset", 112 | "defaultInstantiationMode": 0 113 | } 114 | ], 115 | "defaultDependencyTypeInfo": { 116 | "userAdded": false, 117 | "type": "", 118 | "defaultInstantiationMode": 1 119 | }, 120 | "newSceneOverride": 0 121 | } -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_DashboardUrl: https://dashboard.unity3d.com 13 | m_TestInitMode: 0 14 | CrashReportingSettings: 15 | m_EventUrl: https://perf-events.cloud.unity3d.com 16 | m_Enabled: 0 17 | m_LogBufferSize: 10 18 | m_CaptureEditorExceptions: 1 19 | UnityPurchasingSettings: 20 | m_Enabled: 0 21 | m_TestMode: 0 22 | UnityAnalyticsSettings: 23 | m_Enabled: 0 24 | m_TestMode: 0 25 | m_InitializeOnStartup: 1 26 | m_PackageRequiringCoreStatsPresent: 0 27 | UnityAdsSettings: 28 | m_Enabled: 0 29 | m_InitializeOnStartup: 1 30 | m_TestMode: 0 31 | m_IosGameId: 32 | m_AndroidGameId: 33 | m_GameIds: {} 34 | m_GameId: 35 | PerformanceReportingSettings: 36 | m_Enabled: 0 37 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UniReflection 2 | Unity IL2CPP-compliant reflection acceleration library 3 | # Setup 4 | ## Requirements 5 | - Unity 2022.2 or newer (2023.3 is not tested) 6 | This library highly depends on the il2cpp runtime. 7 | Be cautious about version differences or this will cause crash. 8 | ## How to install 9 | ### Package Manager 10 | 1. Open the Package Manager by going to Window > Package Manager. 11 | 2. Click on the "+" button and select "Add package from git URL". 12 | 3. Enter the following URL: 13 | 14 | ``` 15 | https://github.com/Akeit0/UniReflection.git?path=/Assets/UniReflection 16 | ``` 17 | ### manifest.json 18 | Open `Packages/manifest.json` and add the following in the `dependencies` block: 19 | 20 | ```json 21 | "com.akeit0.uni-reflection": "https://github.com/Akeit0/UniReflection.git?path=/Assets/UniReflection" 22 | ``` 23 | # Example 24 | ## FastNew 25 | No boxing fast new 26 | ```cs 27 | class MyClass{ 28 | private int a=0; 29 | public MyClass(){ 30 | } 31 | public MyClass(int a){ 32 | this.a=a; 33 | } 34 | } 35 | //Equivalent to Activator.CreateInstance, but faster 36 | var myClass=NewCache.CreateInstance(); 37 | myClass=NewCache.CreateInstance(1); 38 | ``` 39 | ```cs 40 | class MyStruct{ 41 | private int a; 42 | public MyStruct(int a){ 43 | this.a=a; 44 | } 45 | } 46 | var myStruct=NewCache.CreateInstance(); 47 | myStruct=NewCache.CreateInstance(1); 48 | ``` 49 | 50 | ### Benchmark on il2cpp 51 | ![new ](/Media/new.png) 52 | ## Fast Field Access 53 | ```cs 54 | static int a; 55 | Action setter =fieldInfo.CreateStaticFieldSetter(); 56 | Func getter =fieldInfo.CreateStaticFieldGetter(); 57 | ``` 58 | ```cs 59 | class MyClass{ 60 | private int a=0; 61 | } 62 | var offset=fieldInfo.GetOffset(); 63 | var myclass=new MyClass(); 64 | ref var a=GetFieldReferenceFromObject(myclass,offset); 65 | ``` 66 | ### Benchmark on il2cpp 67 | ![StaticField ](/Media/StaticField.png) 68 | ## Burst Compatible Delegate 69 | InstanceAction or InstanceFunc can be called in burst compiled function. 70 | ```cs 71 | [BurstCompile] 72 | public class Foo 73 | { 74 | [BurstCompile] 75 | public static void Bar(in InstanceAction a, int i) 76 | { 77 | a.Invoke(i); 78 | } 79 | } 80 | using (var instanceAction=new InstanceAction(i => Debug.Log(i)) 81 | { 82 | Foo.Bar(instanceAction,1); 83 | } 84 | ``` 85 | Static function delegates and those containing multiple delegates are not supported. 86 | ```cs 87 | static void Log(int i)=> Debug.Log(i); 88 | 89 | Action action=Log; 90 | // Throw Exception 91 | using (var instanceAction=new InstanceAction(action) 92 | { 93 | Foo.Bar(instanceAction,1); 94 | } 95 | ``` 96 | ```cs 97 | Action action=i=>_=i; 98 | action +=i=>_=i; 99 | // Throw Exception 100 | using (var instanceAction=new InstanceAction(action) 101 | { 102 | Foo.Bar(instanceAction,1); 103 | } 104 | 105 | ``` 106 | ## IL2CPP API 107 | namespace UniReflection.IL2CPP will allow you to access il2cpp runtime internal. 108 | Il2CppApi class provides many low level apis such as `il2cpp_resolve_icall` which can get internal extern methods pointer (unmanaged[Cdecl]). 109 | ## License 110 | 111 | [MIT License](LICENSE) 112 | --------------------------------------------------------------------------------