How to get texture 2d array size in blueprint?

It seems that there is no blueprint accessible logic for accessing the size, but it does exist in C++ as int32 GetArraySize() const;

You can make this accessible to blueprints via a BlueprintFunctionLibrary like so:

	UFUNCTION(BlueprintCallable, BlueprintPure, Category="Texture2DArray", meta=(CompactNodeTitle="Length"))
	static UPARAM(DisplayName=" ") int32 GetTexture2DArrayLength(const UTexture2DArray* Texture2DArray)
	{
		return Texture2DArray->GetArraySize();
	}

or without the frills:

	UFUNCTION(BlueprintCallable)
	static int32 GetTexture2DArrayLength(const UTexture2DArray* Texture2DArray)
	{
		return Texture2DArray->GetArraySize();
	}

It doesn’t have to be in a blueprint function library, but it makes most sense to put it in one.


For those who don’t have C++ set up, below are instructions on how to quickly do that, no experience needed.

Follow this video guide, but when he says to select none when adding the C++ class, instead scroll down and add a blueprint function library.


Additionally, when he does “Advanced build actions → rebuild selected projects,” you can just press the play icon or hammer icon, whichever you can find in visual studio.
https://www.youtube.com/watch?v=tW1_rD0Geiw

Add in the code, and it should look something like this (YETANOTHERTESTING_API will be different for you)