Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create an instance and call a method? #14

Closed
ballsofsoul opened this issue May 17, 2024 · 4 comments
Closed

How to create an instance and call a method? #14

ballsofsoul opened this issue May 17, 2024 · 4 comments

Comments

@ballsofsoul
Copy link

For example, we have a DirectoryInfo class in mscorlib, which methods take an its instance as first argument, which in-game being created using .ctor method and passing in it the needed path for later usage.

GetFiles, for example:

image

How to process that using UnityResolve?

@issuimo
Copy link
Owner

issuimo commented Jun 1, 2024

UnityResolveClass* pClass;
DirectoryInfo* ptr = pClass->New<DirectoryInfo*>();
ptr->GetFiles(...)

@issuimo
Copy link
Owner

issuimo commented Jun 1, 2024

UnityResolve::Class* pClass;
UnityResolve::Method* ptr = pClass->GetUnityResolve::Class("GetFiles");
ptr->Invoke<ReturnType*>(instance, UnityResolve::UnityType::String::New("file"), 0);

@ballsofsoul
Copy link
Author

ballsofsoul commented Jun 1, 2024

UnityResolveClass* pClass; DirectoryInfo* ptr = pClass->New<DirectoryInfo*>(); ptr->GetFiles(...)

Assuming i have implemented DirectoryInfo type?

UnityResolve::Method* ptr = pClass->GetUnityResolve::Class("GetFiles");

You meant UnityResolve::Method* ptr = pClass->Get<UnityResolve::Method>("GetFiles");?

@issuimo
Copy link
Owner

issuimo commented Jun 2, 2024

yeah

@issuimo issuimo closed this as completed Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants