C++ Array?

Regular GET operates on arrays created and handled by Blueprints.
If you have array in C++ you can create new class derived from UBlueprintFunctionLibrary and there write getter function for an array. For example something like this:
MyBlueprintFunctionLibrary.h:

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "MyBlueprintFunctionLibrary.generated.h"

extern int MyArray[];

UCLASS()
class TESTPROJECT_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
	
public:
	UFUNCTION(BlueprintCallable)
	static int GetElemFromMyArray(int index);
};

and

MyBlueprintFunctionLibrary.cpp:

#include "MyBlueprintFunctionLibrary.h"

int MyArray[] = { 1, 2, 3, 4 };

int UMyBlueprintFunctionLibrary::GetElemFromMyArray(int index)
{
	return MyArray[index];
}

Next in Blueprint you call GetElemFromMyArray function passing to it index you are interested in.

1 Like