MyObject.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "MyObject.generated.h"
/**
*
*/
UCLASS(Blueprintable) //可生成蓝图的
class FIRSTDEMO_API UMyObject : public UObject
{
GENERATED_BODY()
public:
//构造函数
UMyObject();
//成员变量
UPROPERTY(BlueprintReadWrite,Category="My Viriables")
float test;
//成员函数
UFUNCTION(BlueprintCallable,Category="My Functions")
void Myfunction();
};
MyObject.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyObject.h"
#include "Logging/LogMacros.h"
#include "Engine/Engine.h"
UMyObject::UMyObject() //构造函数实现,在构造函数中初始化成员变量的值
{
test = 0.0f;
}
void UMyObject::Myfunction()
{
//日志打印信息
//Log 不能大写,大写的话是另一个枚举参数
UE_LOG(LogTemp, Log, TEXT("Hello World !"));
UE_LOG(LogTemp, Warning, TEXT("Hello World !"));
UE_LOG(LogTemp, Error, TEXT("Hello World !"));
//在屏幕上打印输出信息
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Black, TEXT("Hello World !"));
}