Download LyraStarterGame/Source/LyraGame/GameFeatures/GameFeatureAction_AddWidget.h from Alexhas2/unitysamples: direct link, hf CLI and curl.
- Browser
- Download file 3.06 kB
-
https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/GameFeatures/GameFeatureAction_AddWidget.h
- Command line
-
hf download hf://datasets/Alexhas2/unitysamples/LyraStarterGame/Source/LyraGame/GameFeatures/GameFeatureAction_AddWidget.h
-
curl -L -o GameFeatureAction_AddWidget.h https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/GameFeatures/GameFeatureAction_AddWidget.h
3.06 kB
| // Copyright Epic Games, Inc. All Rights Reserved. | |
| struct FWorldContext; | |
| struct FComponentRequestHandle; | |
| USTRUCT() | |
| struct FLyraHUDLayoutRequest | |
| { | |
| GENERATED_BODY() | |
| // The layout widget to spawn | |
| UPROPERTY(EditAnywhere, Category=UI, meta=(AssetBundles="Client")) | |
| TSoftClassPtr<UCommonActivatableWidget> LayoutClass; | |
| // The layer to insert the widget in | |
| UPROPERTY(EditAnywhere, Category=UI, meta=(Categories="UI.Layer")) | |
| FGameplayTag LayerID; | |
| }; | |
| USTRUCT() | |
| struct FLyraHUDElementEntry | |
| { | |
| GENERATED_BODY() | |
| // The widget to spawn | |
| UPROPERTY(EditAnywhere, Category=UI, meta=(AssetBundles="Client")) | |
| TSoftClassPtr<UUserWidget> WidgetClass; | |
| // The slot ID where we should place this widget | |
| UPROPERTY(EditAnywhere, Category = UI) | |
| FGameplayTag SlotID; | |
| }; | |
| ////////////////////////////////////////////////////////////////////// | |
| // UGameFeatureAction_AddWidget | |
| /** | |
| * GameFeatureAction responsible for adding widgets. | |
| */ | |
| UCLASS(MinimalAPI, meta = (DisplayName = "Add Widgets")) | |
| class UGameFeatureAction_AddWidgets final : public UGameFeatureAction_WorldActionBase | |
| { | |
| GENERATED_BODY() | |
| public: | |
| //~ Begin UGameFeatureAction interface | |
| virtual void OnGameFeatureDeactivating(FGameFeatureDeactivatingContext& Context) override; | |
| virtual void AddAdditionalAssetBundleData(FAssetBundleData& AssetBundleData) override; | |
| //~ End UGameFeatureAction interface | |
| //~ Begin UObject interface | |
| virtual EDataValidationResult IsDataValid(class FDataValidationContext& Context) const override; | |
| //~ End UObject interface | |
| private: | |
| // Layout to add to the HUD | |
| UPROPERTY(EditAnywhere, Category=UI, meta=(TitleProperty="{LayerID} -> {LayoutClass}")) | |
| TArray<FLyraHUDLayoutRequest> Layout; | |
| // Widgets to add to the HUD | |
| UPROPERTY(EditAnywhere, Category=UI, meta=(TitleProperty="{SlotID} -> {WidgetClass}")) | |
| TArray<FLyraHUDElementEntry> Widgets; | |
| private: | |
| struct FPerActorData | |
| { | |
| TArray<TWeakObjectPtr<UCommonActivatableWidget>> LayoutsAdded; | |
| TArray<FUIExtensionHandle> ExtensionHandles; | |
| }; | |
| struct FPerContextData | |
| { | |
| TArray<TSharedPtr<FComponentRequestHandle>> ComponentRequests; | |
| TMap<FObjectKey, FPerActorData> ActorData; | |
| }; | |
| TMap<FGameFeatureStateChangeContext, FPerContextData> ContextData; | |
| //~ Begin UGameFeatureAction_WorldActionBase interface | |
| virtual void AddToWorld(const FWorldContext& WorldContext, const FGameFeatureStateChangeContext& ChangeContext) override; | |
| //~ End UGameFeatureAction_WorldActionBase interface | |
| void Reset(FPerContextData& ActiveData); | |
| void HandleActorExtension(AActor* Actor, FName EventName, FGameFeatureStateChangeContext ChangeContext); | |
| void AddWidgets(AActor* Actor, FPerContextData& ActiveData); | |
| void RemoveWidgets(AActor* Actor, FPerContextData& ActiveData); | |
| }; | |