Skip to content

Instantly share code, notes, and snippets.

@stungeye
Created November 26, 2025 21:30
Show Gist options
  • Select an option

  • Save stungeye/06c783f39ec3b4b28114005d2faf212c to your computer and use it in GitHub Desktop.

Select an option

Save stungeye/06c783f39ec3b4b28114005d2faf212c to your computer and use it in GitHub Desktop.
C++ Blueprint Function Library
// 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();
}
// 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