evehal
(evehal)
1
here is the link for USTRUCT creation.
but it works when i put the USTRUCT in a generated head file only.
for example:
#include “Class.h”
USTRUCT(BlueprintType)
struct FCraftBy
{
GENERATED_USTRUCT_BODY()
};
if i put FCraftBy in a head file that created by myself, then i got compiler errors.
maybe_ilya
(maybe_ilya)
2
Catch simple struct example. Hope it helps you
LessonOct21Struct.h
#pragma once
#include "LessonOct21Struct.generated.h"
USTRUCT(BlueprintType)
struct FLessonOct21Struct
{
GENERATED_USTRUCT_BODY()
public:
FLessonOct21Struct();
FLessonOct21Struct(float x, float y, float z);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test Struct")
float MyX;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test Struct")
float MyY;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Test Struct")
float MyZ;
static FLessonOct21Struct Add(FLessonOct21Struct A, FLessonOct21Struct B);
};
LessonOct21Struct.cpp
#include "DML_UE4_Course.h"
#include "LessonOct21Struct.h"
FLessonOct21Struct::FLessonOct21Struct()
{
MyX = 0.0f;
MyY = 0.0f;
MyZ = 0.0f;
}
FLessonOct21Struct::FLessonOct21Struct(float x, float y, float z)
{
MyX = x;
MyY = y;
MyZ = z;
}
FLessonOct21Struct FLessonOct21Struct::Add(FLessonOct21Struct A, FLessonOct21Struct B)
{
return FLessonOct21Struct(A.MyX + B.MyX, A.MyY + B.MyY, A.MyZ + B.MyZ);
}