Comments (4)
You're supposed to pass il2cppObject as type not create new object, the game creates it for you.
The issue why GameObject::Find
causes fps drop is based on the game and how many objects are in the scene, you should either cache the object ptr or itter through all objects and use hash name check or different approach to obtain the object.
from il2cpp_resolver.
Thank you for your answer! Could you please clarify what you mean by "You're supposed to pass il2cppObject as type"?
from il2cpp_resolver.
Thank you for your answer! Could you please clarify what you mean by "You're supposed to pass il2cppObject as type"?
AddComponent takes il2cppObject pointer and the argument is called "SystemType" so you will need to use this to get the type:
Line 50 in 9cb0706
from il2cpp_resolver.
I rewrited my code, but now it always prints "component not found" even if I add it in the same update.
void ourmain() {
static auto start = std::chrono::high_resolution_clock::now();
auto cur = std::chrono::high_resolution_clock::now();
if (std::chrono::duration<double, std::milli>(cur - start).count() > 1000) {
start = cur;
auto ptr = Unity::GameObject::Find("Default Camera");
if (ptr) {
Unity::il2cppClass* cptr = IL2CPP::Class::Find("UnityEngine.Light");
if (cptr) {
auto pt = ptr->GetComponent("UnityEngine.Light");
if (!pt) {
ptr->AddComponent(IL2CPP::Class::GetSystemType(cptr));
pt = ptr->GetComponent("UnityEngine.Light");
}
if (pt) {
pt->SetPropertyValue("intensity", 1000.f);
std::cout << pt->GetPropertyValue<float>("intensity") << '\n';
}
else {
std::cout << "component not found\n";
}
}
}
}
}
EDIT:fixed by changing component name in getter from "UnityEngine.Light" to "Light"
from il2cpp_resolver.
Related Issues (20)
- Issue finding methods and method name HOT 3
- Access violation when trying to get field value HOT 14
- wish support android arm IL2CPP::Callback::Initialize HOT 1
- Calling any of game functions?
- Dealing with Unicode obfuscated class names HOT 1
- Crash on GetTransform
- Crash On FindObjectsOfType HOT 5
- Android??
- Game crash on m_pObject->GetName() call. HOT 2
- Game Crashes at GetName function HOT 2
- i cant get value from UnityEngine.UI.Text HOT 3
- Methods resolve to NULL on Unity 6000.0.5f1
- Class::Find method doesn't find the class I need it return null_ptr HOT 1
- FetchFields results in an empty vector HOT 3
- error handling
- Game crashes when i call GetColor("_BaseColor") HOT 1
- Getting Class/MethodPointer & Callback Initializtion crashes
- (question) how can i change texture of material to my texture loaded from .png file
- Issuse with ->FetchMethods(&methods);
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from il2cpp_resolver.