Theres no problem in Build at vs, but engine works very very slow after adding these codes.
It takes 1 minutes to start game.
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "GameplayTagContainer.h"
#include "Components/BoxComponent.h"
#include "Zone.generated.h"
UCLASS()
class LOC_API AZone : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AZone();
UPROPERTY()
UBoxComponent* CollisionMesh;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Use Only once at beginplay and in Editor
UFUNCTION(BlueprintInternalUseOnly)
void SetZoneNameTag();
// TagContainer
UPROPERTY(BlueprintReadWrite)
FGameplayTagContainer tagContainer;
// Do not access and change
UPROPERTY(BlueprintReadOnly)
FString szZoneName;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "Zone.h"
// Sets default values
AZone::AZone()
:tagContainer{}
,szZoneName{}
{
// 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;
CollisionMesh = CreateDefaultSubobject<UBoxComponent>(FName("Collision Mesh"));
SetRootComponent(CollisionMesh);
}
// Called when the game starts or when spawned
void AZone::BeginPlay()
{
Super::BeginPlay();
SetZoneNameTag();
}
// Called every frame
void AZone::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// DoN Call Except RightAfter BeginPlay. This Must be call once.
void AZone::SetZoneNameTag()
{
szZoneName = "ZoneName."+this->GetName();
tagContainer.AddTag(FGameplayTag::RequestGameplayTag(FName(szZoneName)));
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, szZoneName);
}