Hello there,
I am trying to create a hierarchical data read/write system and i will not expose this data classes to engine editor. So i want to use a basic c++ class (not a UObject).
i have three classes:
DataNodeM (basic c++ class, means not derived from anything)
UDataBoardM (derived from UObject)
AMyActor (derived from AActor)
even tho i dont expose anything from DataNodeM class, i keep getting engine crash.
MyActor.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
class UDataBoardM;
UCLASS()
class EMPTYCLASSTEST_API AMyActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyActor();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
// Called every frame
virtual void Tick(float DeltaSeconds) override;
UFUNCTION(Category = DataBoard, BlueprintCallable)
UDataBoardM* GetDataBoard() { return FDataBoard; }
private:
UDataBoardM* FDataBoard = NULL;
};
MyActor.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "EmptyClassTest.h"
#include "DataBoardM.h"
#include "MyActor.h"
// Sets default values
AMyActor::AMyActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
FDataBoard = CreateDefaultSubobject<UDataBoardM>(TEXT("DataBoard"));
}
// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
Super::BeginPlay();
}
void AMyActor::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
Super::EndPlay(EndPlayReason);
FDataBoard->Clear();
}
// Called every frame
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
DataBoardM.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "UObject/NoExportTypes.h"
#include "DataBoardM.generated.h"
class DataNodeM;
UCLASS(meta = (BlueprintSpawnableComponent))
class EMPTYCLASSTEST_API UDataBoardM : public UObject
{
GENERATED_BODY()
public:
UDataBoardM();
//static TCHAR NodeSeperator;
//UFUNCTION(Category = DataBoard, BlueprintCallable)
// static TCHAR GetNodeSeperator() { return UDataBoardM::NodeSeperator; }
//UFUNCTION(Category = Grip, BlueprintCallable)
// static void SetNodeSeperator(TCHAR newNodeSeperator) { UDataBoardM::NodeSeperator = newNodeSeperator; }
UFUNCTION(Category = DataBoard, BlueprintCallable)
void Clear();
protected:
DataNodeM* GetRoot(bool create);
DataNodeM* GetRoot() { return GetRoot(true); }
private:
DataNodeM* FRoot = NULL;
};
DataBoardM.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "EmptyClassTest.h"
#include "DataNodeM.h"
#include "DataBoardM.h"
//TCHAR UDataBoardM::NodeSeperator = '.';
UDataBoardM::UDataBoardM()
{
FRoot = NULL;
}
DataNodeM* UDataBoardM::GetRoot(bool create)
{
//if (create && (FRoot == NULL))
// FRoot = new DataNodeM();
return FRoot;
}
void UDataBoardM::Clear()
{
DataNodeM* root = GetRoot(false);
if (root != NULL)
root->Clear();
}
DataNodeM.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
/**
*
*/
class EMPTYCLASSTEST_API DataNodeM
{
public:
DataNodeM();
~DataNodeM();
void Clear() {}
};
DataNodeM.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "EmptyClassTest.h"
#include "DataNodeM.h"
DataNodeM::DataNodeM()
{
}
DataNodeM::~DataNodeM()
{
}
Level blueprint:
whenever i push play, engine crashes.
any help would be appreciated.