sneakyevil / IL2CPP_Resolver

A run-time API resolver for IL2CPP Unity.
https://sneakyevil.gitbook.io/il2cpp-resolver/
The Unlicense
362 stars 67 forks source link

(question) how can i change texture of material to my texture loaded from .png file #58

Closed SVO-ARBUZ closed 3 months ago

SVO-ARBUZ commented 3 months ago

What is the game you are using with IL2CPP Resolver?

SCP:SL

Details:

how can i change texture of material to my texture loaded from .png file, i tried before but i get black texture

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

extremeblackliu commented 3 months ago

this question not related to this library, you should search in google for example "how to load texture in unity" then you reimplement with il2cppresolver.

SVO-ARBUZ commented 3 months ago

I would do this with pleasure, but there is very little information in the documentation, for example, I did not understand which method performs the equivalent of this C# code new Texture2D(50,50);

extremeblackliu commented 2 months ago

il2cpp_new_object with il2cppclass

SVO-ARBUZ commented 2 months ago

I'll try not to ask any more questions like this and put everything in this comment. I don't understand how to pass arguments (50,50) and if they can be passed at all, I don't understand how to call methods in a new object to change fields, etc. I don't understand how I can assign this new object to an existing material.

extremeblackliu commented 2 months ago
auto c = (Unity::CComponent*)Unity::Object::New(your_class);
auto c1 = (Unity::CComponent*)Unity::Object::New(your_class1);

// constructor
c->CallFunction<>(".ctor");

c->SetMemberValue<your_type>("your_field", field_data);
c1->SetMemberValue<your_type1>("your_field", c);

pseducode btw dont paste that, the documentation of the library isnt even proper, but its not hard to do anything. almost everything here is just some pointer-like bullshit. you new with that cast to component and set field then put in another field... just stacking them. constructor is like .ctor() or .cctor iirc, i dont really remember, since long time without doing new thing.