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

i cant get value from UnityEngine.UI.Text #50

Closed SVO-ARBUZ closed 5 months ago

SVO-ARBUZ commented 5 months ago

What is the game you are using with IL2CPP Resolver?

SCP:SL

Details:

i need to get a text from gameconsole ui but i get nullptr for all variables I'm trying to get

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

                Unity::CComponent* sigma = Unity::GameObject::Find("GameConsole/Background/Console/Log/Text")->GetComponent("Text");
                std::string test = sigma->GetPropertyValue<std::string>("text");
                printf_s("sigma ptr: %p\n", sigma);
                printf_s("test value: %s\n", test);
extremeblackliu commented 5 months ago

better call GetComponent with fullname like e.g. UnityEngine.GameObject

sigma->GetPropertyValue<std::string>("text"); -> sigma->GetPropertyValue<Unity::System_String*>("text");

SVO-ARBUZ commented 5 months ago

thanks for the answer, it works, but there is 1 more question, how can I get a class that is in the game but is not on the object

extremeblackliu commented 5 months ago

You probably mean static classes (not attached to a gameobject as a component but persisting during gameplay), for which you can just use offset to dereference to Unity::Component*. However, @fedes1to 's commit https://github.com/sneakyevil/IL2CPP_Resolver/pull/45 added new ways to interact with static classes, you might want to check it out yourself, I haven't tried it yet.