我们的轻量级游戏引擎需要保持它的二进制大小很小。
但是,我们必须在现有的引擎代码中添加一些编辑器代码。例如:
class Material {
public:
#some engine code
bool InitWithMaterialSourceCode();
public:
# some code only used in editor mode
void SetMaterialCachePath();
std::string material_source_file_path;
std::string GetMaterialSourceCode();
}
某些接口和变量仅在编辑器模式下使用。我应该如何排列这些代码?
以下是我的想法:
1、继承。在编辑器模式下使用子类,其中使用父类的所有代码行都需要修改。
2、重复。为编辑器模式编写另一个类,这似乎违反了软件工程的规则。
发布于 2021-07-19 08:54:37
这是用#define
/ #ifdef
完成的
https://stackoverflow.com/questions/68434948
复制相似问题