Newer
Older
undead-universal-patch-mono / Patches / UWRPatch-Str-Str-Rx-Tx.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Reflection;
using System.Security.Policy;
using HarmonyLib;
using UnityEngine;

namespace undead_universal_patch.Patches
{
    [HarmonyPatch]
    class UWR_Str_Str_Rx_Tx_Patch
    {
        const string TargetTypeName = "UnityEngine.Networking.UnityWebRequest";
        const string UWRParams = "(Str-Str-Rx-Tx)";
        static readonly Type targetType = AccessTools.TypeByName(TargetTypeName);

        static bool Prepare() => UWRPatchNoArg.Prepare();

        static MethodBase TargetMethod()
        {
            Type rxType = AccessTools.TypeByName("UnityEngine.Networking.DownloadHandler");
            Type txType = AccessTools.TypeByName("UnityEngine.Networking.UploadHandler");
            return AccessTools.Constructor(targetType, [ typeof(string), typeof(string), rxType, txType ]);
        }

        [HarmonyPostfix]
        static void Postfix(object __instance) => UWRPatchNoArg.InPostfix(__instance, UWRParams);
    }
}