일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- Multiplay
- Unreal Engine
- DSP
- Aegis
- animation
- map design
- gas
- ability task
- 유니티
- 언리얼 엔진
- 메카님
- gameplay ability system
- ret2libc
- 유스케이스
- stride
- Delegate
- MLFQ
- Security
- unity
- 게임개발
- dirty cow
- 게임 개발
- Replication
- CTF
- gravity direction
- photon fusion2
- 언리얼엔진
- gameplay effect
- MAC
- Race condition
Archives
- Today
- Total
Replicated
[FPSScoring] 게임 저장 기능 본문
// h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "FSGameInstance.generated.h"
/**
*
*/
UCLASS()
class FPSSCORING_API UFSGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
UFSGameInstance();
void SaveGame();
void LoadGame();
FORCEINLINE int32 GetMaxScore() { return MaxScore; }
private:
int32 MaxScore;
};
// cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Game/FSGameInstance.h"
#include "Kismet/GameplayStatics.h"
#include "Game/FSSaveGame.h"
#include "Subsystem/FSScoreSubsystem.h"
#include "Blueprint/UserWidget.h"
#include "Components/TextBlock.h"
UFSGameInstance::UFSGameInstance()
{
MaxScore = 0;
}
void UFSGameInstance::SaveGame()
{
UFSSaveGame* SaveGameInstance = Cast<UFSSaveGame>(UGameplayStatics::CreateSaveGameObject(UFSSaveGame::StaticClass()));
if ( SaveGameInstance )
{
UFSScoreSubsystem* ScoreSubsystem = GetWorld()->GetSubsystem<UFSScoreSubsystem>();
if ( ScoreSubsystem )
{
if ( MaxScore < ScoreSubsystem->GetScore())
{
SaveGameInstance->Score = ScoreSubsystem->GetScore();
UGameplayStatics::SaveGameToSlot(SaveGameInstance, TEXT("PlayerSaveSlot"), 0);
}
}
}
}
void UFSGameInstance::LoadGame()
{
if ( UGameplayStatics::DoesSaveGameExist(TEXT("PlayerSaveSlot"), 0))
{
UFSSaveGame* LoadGameInstance = Cast<UFSSaveGame>(UGameplayStatics::LoadGameFromSlot(TEXT("PlayerSaveSlot"), 0));
if ( LoadGameInstance )
{
MaxScore = LoadGameInstance->Score;
UE_LOG(LogTemp, Log, TEXT("LoadGame - Score : %d"), MaxScore);
}
}
}
게임 인스턴스에서 USaveGame 상속받은 거 기반으로 만들어주면 됨
// h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/SaveGame.h"
#include "FSSaveGame.generated.h"
/**
*
*/
UCLASS()
class FPSSCORING_API UFSSaveGame : public USaveGame
{
GENERATED_BODY()
public:
UFSSaveGame();
UPROPERTY(VisibleAnywhere, Category = "SaveGame Data")
int32 Score;
};
// cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Game/FSSaveGame.h"
UFSSaveGame::UFSSaveGame()
{
Score = 0;
}
SaveGame 파생 클래스에선 저장할 데이터 넣어두면 됨
'언리얼 엔진 > Mini Projects [Unreal]' 카테고리의 다른 글
[FPSScoring] Nanite, 프로파일링 등 그 밖의 최적화 시도 (0) | 2025.02.27 |
---|---|
[FPSScoring] ** Object Pooling in Unreal Engine ** (0) | 2025.02.27 |
[FPSScoring] 총알 (0) | 2025.02.27 |
[FPSScoring] 1인칭 슈팅 스코어링 게임 (0) | 2025.02.27 |