#pragma once #include "CoreMinimal.h" #include "WingServer.h" #include "WingHandler.h" #include "WingFetcher.h" #include "WingUtils.h" #include "WingPackageMaker.h" #include "Animation/Skeleton.h" #include "Animation/BlendSpace.h" #include "BlendSpace_Create.generated.h" // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- UCLASS() class UWing_BlendSpace_Create : public UObject, public IWingHandler { GENERATED_BODY() public: UPROPERTY(meta=(Description="Full asset path for the new Blend Space (e.g. '/Game/BlendSpaces/BS_Locomotion')")) FString AssetPath; UPROPERTY(meta=(Description="Skeleton asset package path")) FString Skeleton; virtual FString GetDescription() const override { return TEXT("Create a new 2D Blend Space asset with a specified skeleton."); } virtual void Handle() override { WingPackageMaker Maker(AssetPath); if (!Maker.Ok()) return; // Resolve skeleton. WingFetcher SkeletonFetcher; USkeleton* SkeletonObj = SkeletonFetcher.Asset(Skeleton).Cast(); if (!SkeletonObj) return; // Create the package and Blend Space. if (!Maker.Make()) return; UBlendSpace* NewBS = NewObject(Maker.Package(), FName(*Maker.Name()), RF_Public | RF_Standalone); if (!NewBS) { UWingServer::Print(TEXT("ERROR: Failed to create Blend Space object\n")); return; } // Set skeleton. NewBS->SetSkeleton(SkeletonObj); NewBS->MarkPackageDirty(); UWingServer::Printf(TEXT("Created %s\n"), *NewBS->GetPathName()); UWingServer::Printf(TEXT("Skeleton: %s\n"), *SkeletonObj->GetPathName()); } };