Download LyraStarterGame/Source/LyraGame/System/LyraSystemStatics.cpp from Alexhas2/unitysamples: direct link, hf CLI and curl.
- Browser
- Download file 4.25 kB
-
https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/System/LyraSystemStatics.cpp
- Command line
-
hf download hf://datasets/Alexhas2/unitysamples/LyraStarterGame/Source/LyraGame/System/LyraSystemStatics.cpp
-
curl -L -o LyraSystemStatics.cpp https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/System/LyraSystemStatics.cpp
4.25 kB
| // Copyright Epic Games, Inc. All Rights Reserved. | |
| TSoftObjectPtr<UObject> ULyraSystemStatics::GetTypedSoftObjectReferenceFromPrimaryAssetId(FPrimaryAssetId PrimaryAssetId, TSubclassOf<UObject> ExpectedAssetType) | |
| { | |
| if (UAssetManager* Manager = UAssetManager::GetIfInitialized()) | |
| { | |
| FPrimaryAssetTypeInfo Info; | |
| if (Manager->GetPrimaryAssetTypeInfo(PrimaryAssetId.PrimaryAssetType, Info) && !Info.bHasBlueprintClasses) | |
| { | |
| if (UClass* AssetClass = Info.AssetBaseClassLoaded) | |
| { | |
| if ((ExpectedAssetType == nullptr) || !AssetClass->IsChildOf(ExpectedAssetType)) | |
| { | |
| return nullptr; | |
| } | |
| } | |
| else | |
| { | |
| UE_LOG(LogLyra, Warning, TEXT("GetTypedSoftObjectReferenceFromPrimaryAssetId(%s, %s) - AssetBaseClassLoaded was unset so we couldn't validate it, returning null"), | |
| *PrimaryAssetId.ToString(), | |
| *GetPathNameSafe(*ExpectedAssetType)); | |
| } | |
| return TSoftObjectPtr<UObject>(Manager->GetPrimaryAssetPath(PrimaryAssetId)); | |
| } | |
| } | |
| return nullptr; | |
| } | |
| FPrimaryAssetId ULyraSystemStatics::GetPrimaryAssetIdFromUserFacingExperienceName(const FString& AdvertisedExperienceID) | |
| { | |
| const FPrimaryAssetType Type(ULyraUserFacingExperienceDefinition::StaticClass()->GetFName()); | |
| return FPrimaryAssetId(Type, FName(*AdvertisedExperienceID)); | |
| } | |
| void ULyraSystemStatics::PlayNextGame(const UObject* WorldContextObject) | |
| { | |
| UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull); | |
| if (World == nullptr) | |
| { | |
| return; | |
| } | |
| const FWorldContext& WorldContext = GEngine->GetWorldContextFromWorldChecked(World); | |
| FURL LastURL = WorldContext.LastURL; | |
| // To transition during PIE we need to strip the PIE prefix from maps. | |
| LastURL.Map = UWorld::StripPIEPrefixFromPackageName(LastURL.Map, WorldContext.World()->StreamingLevelsPrefix); | |
| // Add seamless travel option as we want to keep clients connected. This will fall back to hard travel if seamless is disabled | |
| LastURL.AddOption(TEXT("SeamlessTravel")); | |
| FString URL = LastURL.ToString(); | |
| // If we don't remove the host/port info the server travel will fail. | |
| URL.RemoveFromStart(LastURL.GetHostPortString()); | |
| const bool bAbsolute = false; // we want to use TRAVEL_Relative | |
| const bool bShouldSkipGameNotify = false; | |
| World->ServerTravel(URL, bAbsolute, bShouldSkipGameNotify); | |
| } | |
| void ULyraSystemStatics::SetScalarParameterValueOnAllMeshComponents(AActor* TargetActor, const FName ParameterName, const float ParameterValue, bool bIncludeChildActors) | |
| { | |
| if (TargetActor != nullptr) | |
| { | |
| TargetActor->ForEachComponent<UMeshComponent>(bIncludeChildActors, [=](UMeshComponent* InComponent) | |
| { | |
| InComponent->SetScalarParameterValueOnMaterials(ParameterName, ParameterValue); | |
| }); | |
| } | |
| } | |
| void ULyraSystemStatics::SetVectorParameterValueOnAllMeshComponents(AActor* TargetActor, const FName ParameterName, const FVector ParameterValue, bool bIncludeChildActors) | |
| { | |
| if (TargetActor != nullptr) | |
| { | |
| TargetActor->ForEachComponent<UMeshComponent>(bIncludeChildActors, [=](UMeshComponent* InComponent) | |
| { | |
| InComponent->SetVectorParameterValueOnMaterials(ParameterName, ParameterValue); | |
| }); | |
| } | |
| } | |
| void ULyraSystemStatics::SetColorParameterValueOnAllMeshComponents(AActor* TargetActor, const FName ParameterName, const FLinearColor ParameterValue, bool bIncludeChildActors) | |
| { | |
| SetVectorParameterValueOnAllMeshComponents(TargetActor, ParameterName, FVector(ParameterValue), bIncludeChildActors); | |
| } | |
| TArray<UActorComponent*> ULyraSystemStatics::FindComponentsByClass(AActor* TargetActor, TSubclassOf<UActorComponent> ComponentClass, bool bIncludeChildActors) | |
| { | |
| TArray<UActorComponent*> Components; | |
| if (TargetActor != nullptr) | |
| { | |
| TargetActor->GetComponents(ComponentClass, /*out*/ Components, bIncludeChildActors); | |
| } | |
| return MoveTemp(Components); | |
| } | |