Reduce string alloc

This commit is contained in:
Sinai 2021-08-06 16:02:58 +10:00
parent 3cfdd6fa43
commit 31dd54d25c

View File

@ -98,15 +98,17 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
internal delegate IntPtr d_FindObjectsOfTypeAll(IntPtr type); internal delegate IntPtr d_FindObjectsOfTypeAll(IntPtr type);
internal static readonly string[] findObjectsOfTypeAllSignatures = new[]
{
"UnityEngine.Resources::FindObjectsOfTypeAll",
"UnityEngine.ResourcesAPIInternal::FindObjectsOfTypeAll" // Unity 2020+ updated to this
};
public override UnityEngine.Object[] FindObjectsOfTypeAll(Type type) public override UnityEngine.Object[] FindObjectsOfTypeAll(Type type)
{ {
var iCall = ICallManager.GetICallUnreliable<d_FindObjectsOfTypeAll>(new[] return new Il2CppReferenceArray<UnityEngine.Object>(
{ ICallManager.GetICallUnreliable<d_FindObjectsOfTypeAll>(findObjectsOfTypeAllSignatures)
"UnityEngine.Resources::FindObjectsOfTypeAll", .Invoke(Il2CppType.From(type).Pointer));
"UnityEngine.ResourcesAPIInternal::FindObjectsOfTypeAll" // Unity 2020+ updated to this
});
return new Il2CppReferenceArray<UnityEngine.Object>(iCall.Invoke(Il2CppType.From(type).Pointer));
} }
// Scene.GetRootGameObjects(); // Scene.GetRootGameObjects();