【发布时间】:2020-10-05 07:57:37
【问题描述】:
我有一个在 Unity 中使用的 .dll(非托管代码)。我需要在 .dll 中添加一些功能,以便为 Android 设备构建 Unity 项目。
所以,在我的情况下,我需要使用预处理器功能,例如 if
我试图在我的.cpp 文件中添加它只是为了测试
DecoderStream::DecoderStream()
{
debug_in_unity("DecoderStream", "DecoderStream"); // 1 comment
#if UNITY_ANDROID && !UNITY_EDITOR
debug_in_unity("DecoderStream", "UNITY_ANDROID"); // 2 comment
#elif UNITY_EDITOR
debug_in_unity("DecoderStream", "UNITY_EDITOR"); // 3 comment
m_p_tex_decoder = new DecoderTextureFFmpeg();
#else
debug_in_unity("DecoderStream", "else"); // 4 comment
#endif
}
如果我编译这段代码并在 Unity 中运行它,我会看到 1 comment 和 4 comment 我看到预处理器条件不起作用,我的意思是它无法识别无论是 android 还是 unity 编辑器...
我做错了什么?
【问题讨论】:
-
您是否在不同的环境中重新构建(您希望设置/取消设置开关)并相应地使用生成的 dll?
标签: c++ unity3d c-preprocessor