#include <Windows.h>
#define __NARESOLVER_ONLY_API
#include "../NaResolver.h"
#define LOGGER_FUNCTION(level) ([](std::string m, ...)->void\
{\
m = #level " [NaResolver] " + m + "\n";\
va_list args;\
va_start(args, m);\
vprintf(m.c_str(), args);\
va_end(args);\
})
// per-register the class, it will init in init period
// the first parameter: Assembly
// secondly: namespace
// thirdly: class name ( including declarative name of class )
// fourth: inherit ( pay attention: you need have a ":" before your inheritable class )
NA_RESOLVER_REGISTER_CLASS(UnityEngine.CoreModule, UnityEngine, GameObject, : public std::string)
{
public:
void* get_transform();
};
// in a similar way
// firstly: which class's namespace it comes from
// secondly: which class it comes from
// thirdly: signature
// fourth: return type
// fifth: function name
// ...: parameters (type)
NA_RESOLVER_REGISTER_METHOD(UnityEngine, GameObject, "UnityEngine.Transform get_transform()", void*, get_transform, )
{
// __{ namespace }_{ class }_Class_{ function }_Method__
// As<{ return type }, { self class }, { the last parameter must is a MethodInfo }, ...>()
// Attention: If this function's return type is the void, you need to ues the VoidInvode.
__UnityEngine_GameObject_Class_get_transform_Method__.As<void*, GameObject*, GeneralMethodInfo*>().
Invoke(this, nullptr);
}
// Suggestion: add the function in cpp
int WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hinstDLL);
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
try
{
NaResolver::Config config;
config.enableLogger = true;
config.logger.debug = LOGGER_FUNCTION([Debug]);
config.logger.info = LOGGER_FUNCTION([Info]);
// i delete the error and fatal log, there will be export with the NaResolver::Exception
if (!Il2CppResolver->Setup(config))
printf("Failed to setup I2Hrame!\n");
}
catch (const NaResolver::Exception& e)
{
// Everything registered will be handled in Setup, so here is a 'try' to catch the error
printf("[NaResolver] %s\n", e.message.c_str());
}
// content is ptr of it ( all same )
printf("(Il2CppResolver->GetClass) Class: %p\n", __UnityEngine_GameObject_Class__.content);
printf("(Il2CppResolver->GetMethod) Method: %p\n", __UnityEngine_GameObject_Class_get_transform_Method__.content);
Il2CppResolver->Destroy();
free(Il2CppResolver);
FreeConsole();
FreeLibrary(hinstDLL);
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【项目说明】 1.项目代码均经过功能验证ok,确保稳定可靠运行。欢迎下载食用体验! 2.主要针对各个计算机相关专业,包括计算机科学、信息安全、数据科学与大数据技术、人工智能、通信、物联网等领域的在校学生、专业教师、企业员工。 3.项目具有丰富的拓展空间,不仅可作为入门进阶,也可直接作为毕设、课程设计、大作业、初期项目立项演示等用途。 4.当然也鼓励大家基于此进行二次开发。在使用过程中,如有问题或建议,请及时沟通。 5.期待你能在项目中找到乐趣和灵感,也欢迎你的分享和反馈! 【资源介绍】 基于C++实现的轻量化的Unity游戏插件开发框架源码.zip基于C++实现的轻量化的Unity游戏插件开发框架源码.zip基于C++实现的轻量化的Unity游戏插件开发框架源码.zip基于C++实现的轻量化的Unity游戏插件开发框架源码.zip基于C++实现的轻量化的Unity游戏插件开发框架源码.zip基于C++实现的轻量化的Unity游戏插件开发框架源码.zip基于C++实现的轻量化的Unity游戏插件开发框架源码.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于C++实现的轻量化的Unity游戏插件开发框架源码.zip (8个子文件)
项目说明.md 2KB
.gitattributes 26B
example
example.sln 1KB
example.vcxproj.user 168B
main.cpp 3KB
example.vcxproj 7KB
example.vcxproj.filters 966B
NaResolver.h 33KB
共 8 条
- 1
资源评论
北航程序员小C
- 粉丝: 2222
- 资源: 1823
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功