第一次提交
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#include "Utility/GMS_Log.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "Animation/AnimInstance.h"
|
||||
|
||||
|
||||
const FName GMSLog::MessageLogName{TEXTVIEW("GMS")};
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogGMS)
|
||||
DEFINE_LOG_CATEGORY(LogGMS_Animation)
|
||||
|
||||
FString GetGMSLogContextString(const UObject* ContextObject)
|
||||
{
|
||||
ENetRole Role = ROLE_None;
|
||||
FString RoleName = TEXT("None");
|
||||
FString Name = "None";
|
||||
|
||||
if (const AActor* Actor = Cast<AActor>(ContextObject))
|
||||
{
|
||||
Role = Actor->GetLocalRole();
|
||||
Name = Actor->GetName();
|
||||
}
|
||||
else if (const UActorComponent* Component = Cast<UActorComponent>(ContextObject))
|
||||
{
|
||||
Role = Component->GetOwnerRole();
|
||||
Name = Component->GetOwner()->GetName();
|
||||
}
|
||||
else if (const UAnimInstance* AnimInstance = Cast<UAnimInstance>(ContextObject))
|
||||
{
|
||||
if (AnimInstance->GetOwningActor())
|
||||
{
|
||||
Role = AnimInstance->GetOwningActor()->GetLocalRole();
|
||||
Name = AnimInstance->GetOwningActor()->GetName();
|
||||
}
|
||||
}
|
||||
else if (IsValid(ContextObject))
|
||||
{
|
||||
Name = ContextObject->GetName();
|
||||
}
|
||||
|
||||
if (Role != ROLE_None)
|
||||
{
|
||||
RoleName = (Role == ROLE_Authority) ? TEXT("Server") : TEXT("Client");
|
||||
}
|
||||
return FString::Printf(TEXT("[%s] (%s)"), *RoleName, *Name);
|
||||
}
|
||||
Reference in New Issue
Block a user