-3

Basically, this code right here:

using BepInEx;
using BepInEx.Unity.IL2CPP;
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
using Il2CppInterop.Runtime.InteropTypes.Arrays;

namespace PleaseWorkIBegYou
{
    [BepInPlugin("org.bepinex.plugins.giftscoprecreation", "PleaseWorkIBegYou", "1.0.0.0")]
    [BepInProcess("Petscop.exe")]
    public class Plugin : BasePlugin
    {
        public Shader lo = Shader.Find("Hidden/BlitCopy");
        public Shader lo2 = Shader.Find("Custom/Main");

        public override void Load()
        {
            // Plugin startup logic
            Log.LogInfo($"Plugin PleaseWorkIBegYou is loaded!");

            // Your code starts here
            foreach (BlitRenderTexture m in         Resources.FindObjectsOfTypeAll(Il2CppType.Of<BlitRenderTexture>()).Cast<Il2CppReferenceArray<BlitRenderTexture>>())
            {
                if (m.shader == lo2)
                {
                    m.shader = lo;
                }
            }
            // Your code ends here
        }
    }
}

should work correctly, but it gives me CS0103 error in IL2Cpp type.

detailed error

How exactly can I fix this?

Asking ChatGPT, which gave me slightly different version of this code, that still doesn't work.

derHugo
  • 83,094
  • 9
  • 75
  • 115
  • `Il2CppType` is their namespace, it looks for whatever representation that type is then casts it back. Try `Resources.FindObjectsOfTypeAll().OfType()`. – aybe Aug 19 '23 at 11:04
  • No clue how this works so just to be sure .. what speaks against `Ressources.FindObjectsOfTypeAll(typeof(BlitRenderTexture)) as BlitRenderTexture[]` ? – derHugo Aug 19 '23 at 11:21
  • now it says this https://imgur.com/a/adwFBMw – mrfas12 Aug 19 '23 at 11:22
  • Was editing ^^ on the phone only so had to look up the exact signature ;) my point is .. what exactly do you need the `Il2CppType.Of` for? – derHugo Aug 19 '23 at 11:25
  • I just need do something like this: It checks through all the shaders this game has If it finds the Custom/Main shader, it replaces with Hidden/Blitcopy – mrfas12 Aug 19 '23 at 11:27
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 19 '23 at 15:15

0 Answers0