1. GETag 저장용 클래스생성(싱글톤)
싱글톤만드는법 : static getter, setter 만듬
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameplayTagContainer.h"
/**
* AuraGameplayTags
*
* 싱글톤, 포함하는 native GETags
*/
struct FAuraGameplayTags
{
public:
static const FAuraGameplayTags& Get(){ return GameplayTags; }
static void InitializeNativeGameplayTags(); //@Setter
protected:
private:
static FAuraGameplayTags GameplayTags;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "AuraGameplayTags.h"
#include "GameplayTagsManager.h"
FAuraGameplayTags FAuraGameplayTags::GameplayTags; //전역변수
void FAuraGameplayTags::InitializeNativeGameplayTags()
{
//단순히 태그를 추가
UGameplayTagsManager::Get().AddNativeGameplayTag(FName("Attributes.Secondary.Armor"),FString("Reduces damage taken, improves Block Chance"));
}
프로젝트세팅에서 태그추가하는 작업이랑 똑같음!
* 커스텀 에셋매니저 만들기
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/AssetManager.h"
#include "AuraAssetManager.generated.h"
/**
*
*/
UCLASS()
class AURA_API UAuraAssetManager : public UAssetManager
{
GENERATED_BODY()
public:
const UAuraAssetManager& Get();
protected:
virtual void StartInitialLoading() override;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "AuraAssetManager.h"
#include "AuraGameplayTags.h"
const UAuraAssetManager& UAuraAssetManager::Get()
{
check(GEngine);
UAuraAssetManager* AuraAssetManager = Cast<UAuraAssetManager>(GEngine->AssetManager);
return *AuraAssetManager;
}
void UAuraAssetManager::StartInitialLoading() //게임 에셋들 초기세팅하는 함수
{
Super::StartInitialLoading();
//Tag들 추가 하기 최적의 장소!
FAuraGameplayTags::InitializeNativeGameplayTags();
//할일 : AuraAssetManager를 AssetManager로 설정
}
* 에셋매니저를 커스텀으로 설정
* cpp native tag를 만드는 방법은 알겠는데, 이미 만든속성을 cpp native로 만드는방법은?
1. DT지우고 다시 설정하면됨 ㅋㅋ
* cpp에서 GETag는 어떻게 사용?
1. 일단 특정 태그를 Tag변수에 저장해둠
struct FAuraGameplayTags
{
public:
static const FAuraGameplayTags& Get(){ return GameplayTags; }
static void InitializeNativeGameplayTags(); //@Setter
FGameplayTag Attributes_Secondary_Armor;
FAuraGameplayTags FAuraGameplayTags::GameplayTags; //전역변수
void FAuraGameplayTags::InitializeNativeGameplayTags()
{
//단순히 태그를 추가
GameplayTags.Attributes_Secondary_Armor = UGameplayTagsManager::Get().AddNativeGameplayTag(FName("Attributes.Secondary.Armor"),FString("Reduces damage taken, improves Block Chance"));
}
2. Test위치를 설정하고, Get한다음, 디버그찍어봄
void UAuraAbilitySystemComponent::AbilityActorInfoSet()
{
OnGameplayEffectAppliedDelegateToSelf.AddUObject(this,&UAuraAbilitySystemComponent::EffectApplied);
const FAuraGameplayTags& GameplayTags= FAuraGameplayTags::Get();
//GameplayTags.Attributes_Secondary_Armor.ToString();
GEngine->AddOnScreenDebugMessage(
-1,10.f,FColor::Orange,FString::Printf(TEXT("Tag : %s"),*GameplayTags.Attributes_Secondary_Armor.ToString()))
}
cpp에서 각 태그변수만들고, 저장하면 되겠다.
*실습
struct FAuraGameplayTags
{
public:
static const FAuraGameplayTags& Get(){ return GameplayTags; }
static void InitializeNativeGameplayTags(); //@Setter
FGameplayTag Attributes_Primary_Strength;
FGameplayTag Attributes_Primary_Intelligence;
FGameplayTag Attributes_Primary_Resilience;
FGameplayTag Attributes_Primary_Vigor;
FGameplayTag Attributes_Secondary_Armor;
FGameplayTag Attributes_Secondary_ArmorPenetration;
FGameplayTag Attributes_Secondary_BlockChance;
FGameplayTag Attributes_Secondary_CriticalHitChance;
FGameplayTag Attributes_Secondary_CriticalHitDamage;
FGameplayTag Attributes_Secondary_CriticalHitResistance;
FGameplayTag Attributes_Secondary_HealthRegeneration;
FGameplayTag Attributes_Secondary_ManaRegeneration;
FGameplayTag Attributes_Secondary_MaxHealth;
FGameplayTag Attributes_Secondary_MaxMana;
cpp에서 추가할속성 변수 노가다
// Fill out your copyright notice in the Description page of Project Settings.
#include "AuraGameplayTags.h"
#include "GameplayTagsManager.h"
FAuraGameplayTags FAuraGameplayTags::GameplayTags; //전역변수
void FAuraGameplayTags::InitializeNativeGameplayTags()
{
/*
* Primary Attributes
*/
GameplayTags.Attributes_Primary_Strength = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Primary.Strength"),
FString("Increases physical damage")
);
GameplayTags.Attributes_Primary_Intelligence = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Primary.Intelligence"),
FString("Increases magical damage")
);
GameplayTags.Attributes_Primary_Resilience = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Primary.Resilience"),
FString("Increases Armor and Armor Penetration")
);
GameplayTags.Attributes_Primary_Vigor = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Primary.Vigor"),
FString("Increases Health")
);
/*
* Secondary Attributes
*/
GameplayTags.Attributes_Secondary_Armor = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Secondary.Armor"),
FString("Reduces damage taken, improves Block Chance")
);
GameplayTags.Attributes_Secondary_ArmorPenetration = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Secondary.ArmorPenetration"),
FString("Ignores Percentage of enemy Armor, increases Critical Hit Chance")
);
GameplayTags.Attributes_Secondary_BlockChance = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Secondary.BlockChance"),
FString("Chance to cut incoming damage in half")
);
GameplayTags.Attributes_Secondary_CriticalHitChance = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Secondary.CriticalHitChance"),
FString("Chance to double damage plus critical hit bonus")
);
GameplayTags.Attributes_Secondary_CriticalHitDamage = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Secondary.CriticalHitDamage"),
FString("Bonus damage added when a critical hit is scored")
);
GameplayTags.Attributes_Secondary_CriticalHitResistance = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Secondary.CriticalHitResistance"),
FString("Reduces Critical Hit Chance of attacking enemies")
);
GameplayTags.Attributes_Secondary_HealthRegeneration = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Secondary.HealthRegeneration"),
FString("Amount of Health regenerated every 1 second")
);
GameplayTags.Attributes_Secondary_ManaRegeneration = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Secondary.ManaRegeneration"),
FString("Amount of Mana regenerated every 1 second")
);
GameplayTags.Attributes_Secondary_MaxHealth = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Secondary.MaxHealth"),
FString("Maximum amount of Health obtainable")
);
GameplayTags.Attributes_Secondary_MaxMana = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Secondary.MaxMana"),
FString("Maximum amount of Mana obtainable")
);
}
실제로 에디터에 태그 추가 노가다 && 변수에 넣기
'UE5 > Attribute Menu' 카테고리의 다른 글
[UE5] 메뉴 위젯 컨트롤러 구현, BP내 사용가능한 위젯컨트롤러 게터 만들기, BP 상속안될때 해결방법, MVC 정리 (0) | 2024.06.08 |
---|---|
[UE5] 속성정보 관련(구조체,탐색) 클래스구현, 속성입력 (0) | 2024.06.08 |
[UE5] 위젯에 실제 데이터 바인딩 설계 (0) | 2024.06.07 |
[UE5] 버튼클릭시, 속성위젯 띄우기 구현 // 위젯위치 조정방법 (0) | 2024.06.07 |
[UE5] 속성메뉴 설계, 속성위젯 디자인 구현 (0) | 2024.06.07 |