Created
November 26, 2025 21:30
-
-
Save stungeye/06c783f39ec3b4b28114005d2faf212c to your computer and use it in GitHub Desktop.
C++ Blueprint Function Library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Fill out your copyright notice in the Description page of Project Settings. | |
| #include "GluttonBlueprintFunctionLibrary.h" | |
| void UGluttonBlueprintFunctionLibrary::HelloSquirrel() | |
| { | |
| UE_LOG(LogTemp, Warning, TEXT("Hello Squirrel")); | |
| } | |
| void UGluttonBlueprintFunctionLibrary::HelloSquirrelNTimes(int32 N) | |
| { | |
| for (int32 i{ 0 }; i < N; i++) { | |
| UE_LOG(LogTemp, Warning, TEXT("Hello Squirrel! (%d)"), i); | |
| } | |
| } | |
| FString UGluttonBlueprintFunctionLibrary::FormatTextFromFloats(const FString& FormatString, const TArray<float>& Values) | |
| { | |
| FString Result{ FormatString }; | |
| for (int32 i{ 0 }; i < Values.Num(); i++) { | |
| FString Placeholder = FString::Printf(TEXT("{%d}"), i); // {0} {1} {2}... | |
| const FString ValueString = FString::SanitizeFloat(Values[i]); | |
| Result.ReplaceInline(*Placeholder, *ValueString); | |
| } | |
| return Result; | |
| } | |
| void UGluttonBlueprintFunctionLibrary::SortFloatArray(TArray<float>& Array) { | |
| Array.Sort(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Fill out your copyright notice in the Description page of Project Settings. | |
| #pragma once | |
| #include "CoreMinimal.h" | |
| #include "Kismet/BlueprintFunctionLibrary.h" | |
| #include "GluttonBlueprintFunctionLibrary.generated.h" | |
| /** | |
| * | |
| */ | |
| UCLASS() | |
| class FROMBPTOCPP_API UGluttonBlueprintFunctionLibrary : public UBlueprintFunctionLibrary | |
| { | |
| GENERATED_BODY() | |
| /** Prints "Hello Squirrel" to the output log. */ | |
| UFUNCTION(BlueprintCallable, Category="Glutton|Log") | |
| static void HelloSquirrel(); | |
| /** | |
| * Prints "Hello Squirrel" to the output log N times. | |
| * | |
| * @param N Specifies how many squirrels we want in our logs. | |
| */ | |
| UFUNCTION(BlueprintCallable, Category="Glutton|Log") | |
| static void HelloSquirrelNTimes(int32 N); | |
| /** | |
| * Formats a string that includes {0}, {1}, {2} placeholders. | |
| * Pulls the values for the placeholders from the input array at the indexed positions. | |
| * | |
| * @param FormatString Our string with the placeholders. | |
| * @param Values Our array of floats to insert into the string. | |
| * @return The formated string with the placeholders replaced by the indexed floats. | |
| */ | |
| UFUNCTION(BlueprintCallable, Category="Glutton|Utils") | |
| static FString FormatTextFromFloats(const FString& FormatString, const TArray<float>& Values); | |
| UFUNCTION(BlueprintCallable, Category="Glutton|Array") | |
| static void SortFloatArray(UPARAM(ref) TArray<float>& Array); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment