本文涉及的主要内容有:
1、如何写一个类
2、如何调用类中的方法
3、如何调试
1、如何写一个类
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "Student.generated.h"
/**
*
*/
UCLASS(Blueprintable)
class UNREALDEMO_API UStudent : public UObject
{
GENERATED_BODY()
public:
UStudent();
UPROPERTY(BlueprintReadWrite)
int m_age;
UFUNCTION(BlueprintCallable)
void SayHello();
};
#include "Student.h"
UStudent::UStudent()
{
}
void UStudent::SayHello()
{
}
给变量增加一个分类:Category=“xxx”
2、使用全局唯一关卡类调用类中的SayHello方法:
3、如何调试:
UE_LOG(LogTemp, Log, TEXT("hello world"));
UE_LOG(LogTemp, Warning, TEXT("hello world"));
UE_LOG(LogTemp, Error, TEXT("hello world"));
补充如果是unreal5的话,可能会不能调试,请参考:
https://zhuanlan.zhihu.com/p/582314174
win+r打开注册表,运行:regedit
重启电脑,这样就能调试了。
添加注册表,路径为:计算机\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
key:DebuggerMaxModuleMsgs
值为:2048