开发环境配置与源码安装使用
安装VS2022与虚幻引擎源代码下载
- 参考上篇文章:虚幻引擎源码版安装以及可能出现的错误参考解决方案
安装PJ版小番茄插件
- 首先检测是否之前安装过不同版本的VAX,如果有一定要删除
- 点击下载好的VAX,小番茄插件百度网盘下载链接:提取码:jpyd
- 开始安装
- 安装完成
- 然后开始PJ流程
Crack
目录下的x64中的DLL文件只能用于VS 2022及更新的版本,X86目录下的DLL文件用于除2022外的如2019,2017,2015,2012等等- 针对
VS2022
及以后的版本,在VAX软件安装后,搜索和替换VA_X64.dll
。针对VS 2019/2017
等,在VAX软件安装后,搜索和替换VA_X.dll
。这些dll文件一般存在于C盘的自己用户的AppData/VisualStudio目录
- 替换成功后打开VS2022,在“扩展”菜单下有VASSIX菜单项,在VAX菜单中找到Help->Register
- 复制
www.board4all.biz (1-user license) Support ends 2030.12.31 00001T-N3XPDN-2C9EN3-B0RMX7-ZBUUZA-8FR7TV-17XPRG-U5RB1Q-X9B2XM-Z8NCUX-3UAMG8
到第一行然后点是,后继续复制
- 这样就说明注册成功了
- 如果提示KEY无效,检查扩展中的VAX版本是否与现在这个版本一样,如果之前安装过VAX,则需要删除干净之前安装的软件,甚至清一下注册表。删除注册表
HKEY_CURRENT_USER\Software\Whole Tomato HKEY_LOCAL_MACHINE\SOFTWARE\Whole Tomato
虚幻源码的编译模式
- 四种编译模式:Debug、DebugGame、Development、Shipping
- Debug:为开发人员调试源代码的模式,对性能有影响,因为会额外生成一下调试信息
- DebugGame:用于开发与测试的编译模式,相对于Debug模式有性能优化,常用于开发阶段,内部测试,方便开发人员进行调试。
- Development:更高的性能与优化,比DebugGame更节省性能,会禁用一些生成信息
- Shipping:最终发布的编译模式,面向用户,最终版本的游戏发布编译模式
- 四中编译模式中的三小类:Client、Editor、Server
- Client:客户端包
- Editor:引擎编译器里面运行的
- Server:服务器包
- 打开源码,编译可能需要1个多小时,之后启动新实例就可以打开源码版虚幻了
UE_LOG语句
- UE_LOG(CategoryName,Verbosity,Format,_VA_ARGS _);
- CategoryName:标签,一般引擎默认的是LogTemp,也可以自定义
- Verbosity:输出等级,一般常用Log、Warning、Error
UE_LOG(LogTemp,Log,TEXT("Hello World"));
UE_LOG(LogTemp,Warning,TEXT("Hello World"));
UE_LOG(LogTemp,Error,TEXT("Hello World"));
- 输出结果
- 虚幻的常用变量输出
FString str = "XiaoGua";
UE_LOG(LogTemp, Warning, TEXT("Name is %s"), *str);
int32 Num = 21;
UE_LOG(LogTemp, Warning, TEXT("Num is %d"),Num);
double XiaoGuaLength = 1.78;
UE_LOG(LogTemp, Warning, TEXT("Lenght is %lf"), XiaoGuaLength);
FVector vec = FVector(8, 8, 8);
UE_LOG(LogTemp, Warning, TEXT("Vec is %s"), *vec.ToString());
FRotator rot = FRotator(9, 9, 9);
UE_LOG(LogTemp, Warning, TEXT("Rot is %s"), *rot.ToString());
FName Name = FName(TEXT("xiaogua"));
UE_LOG(LogTemp, Warning, TEXT("Name is %s"), *Name.ToString());
FText text = FText::FromString(TEXT("xiaoguagua"));
UE_LOG(LogTemp, Warning, TEXT("text is %s"), *text.ToString());
-
输出结果
-
面试题:FString、FText、FName区别
- 待补全
-
UE_LOG自定义标签,首先在.h文件中声明自定义标签,使用宏定义
DECLARE_LOG_CATEGORY_EXTERN
-
定义一个自定义标签
DECLARE_LOG_CATEGORY_EXTERN(LOGCustom, Log, All);
DefaultVerbosity
的参数如下- NoLogging:禁用日志记录
- Fatal:总是打印一个致命的错误
- Error:将打印错误信息
- Warning:一些警告潜在问题不会崩毁程序
- Display:一般性的信息输出
- Log:常规的信息输出
- Verbose:详细信息打印到日志
- VeryVerbose:非常详细的日志记录
- All:允许所有级别日志输出
- BreakOnLog:在日志输出时触发断点用于调试
- 以下是源码:
namespace ELogVerbosity
{
enum Type : uint8
{
/** Not used */
NoLogging = 0,
/** Always prints a fatal error to console (and log file) and crashes (even if logging is disabled) */
Fatal,
/**
* Prints an error to console (and log file).
* Commandlets and the editor collect and report errors. Error messages result in commandlet failure.
*/
Error,
/**
* Prints a warning to console (and log file).
* Commandlets and the editor collect and report warnings. Warnings can be treated as an error.
*/
Warning,
/** Prints a message to console (and log file) */
Display,
/** Prints a message to a log file (does not print to console) */
Log,
/**
* Prints a verbose message to a log file (if Verbose logging is enabled for the given category,
* usually used for detailed logging)
*/
Verbose,
/**
* Prints a verbose message to a log file (if VeryVerbose logging is enabled,
* usually used for detailed logging that would otherwise spam output)
*/
VeryVerbose,
// Log masks and special Enum values
All = VeryVerbose,
NumVerbosity,
VerbosityMask = 0xf,
SetColor = 0x40, // not actually a verbosity, used to set the color of an output device
BreakOnLog = 0x80
};
}
Compile Time Verbosity
:编译的等级- 一般自定义标签使用就是,
自定义名字和Log和All
DECLARE_LOG_CATEGORY_EXTERN(LOGCustom, Log, All);
- 然后在.cpp文件中进行声明一下
DEFINE_LOG_CATEGORY
加上自己定义的名字
DEFINE_LOG_CATEGORY(LOGCustom);
- 运行