Get Available Screen Resolutions in Blueprints - Epic Wiki

# Get Available Screen Resolutions in Blueprints

Rate this Page:

5.00

(one vote)

Approved for Versions:4.6

# Contents

# Overview

The following Blueprint Node is based on the function provided by Rama, see Solus Options Menu: Screen Resolutions. The provided function has the limitation that you cannot use it in your own Blueprint Library. The reason is because the FScreenResolutionRHI Type is not a BlueprintType. As I required such a function for my options UMG widget I wrote it, tested it and decided to share it.

# Code

The following code is meant to be included in your own Blueprint Library. If you do not know how to make a Blueprint Library I recommend you read Rama's Guide

# Header File

First you declare the new FScreenResolutionRHI type. As mentioned in the comments it is not an exact duplicate of FScreenResolutionRHI. The reason is that when I used uint32 I was not able to use break or make nodes. My guess is that the Blueprint's Integer Type is defined as int32 in c++ and thus is not compatible with uint32. If someone can confirm this feel free to do.

/** * Screen Resolution * @remark Engine type is not meant for blueprints so we replicate the type. * @remark The Engine type uses uint32 but we need to use int32. Otherwise it won't be possible to break/make this type. */ USTRUCT(BlueprintType) struct FScreenResolutionRHIBP { GENERATED_USTRUCT_BODY()   UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ScreenResolution) int32 Width;   UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ScreenResolution) int32 Height;   UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ScreenResolution) int32 RefreshRate;   FScreenResolutionRHIBP() { Width = Height = RefreshRate = 0; } };   /** * Retrieve a sorted list of all screen resolutions supported by the player's display adapter. * * @returns the array of all supported screen resolutions. */ UFUNCTION(BlueprintPure, Category = Utility) static TArray<struct FScreenResolutionRHIBP> GetDisplayAdapterScreenResolutions();

# Cpp File

#include "RHI.h"   ...   TArray<FScreenResolutionRHIBP> YourBlueprintLibrary::GetDisplayAdapterScreenResolutions() { TArray<FScreenResolutionRHIBP> ResolutionsToReturn; FScreenResolutionArray Resolutions; if (RHIGetAvailableResolutions(Resolutions, false)) { // Preallocate just enough memory to store all elements ResolutionsToReturn.Reserve(Resolutions.Num());   for (const FScreenResolutionRHI& EachResolution : Resolutions) { FScreenResolutionRHIBP resolution; resolution.Width = EachResolution.Width; resolution.Height = EachResolution.Height; resolution.RefreshRate = EachResolution.RefreshRate;   ResolutionsToReturn.Add(resolution); } }   return ResolutionsToReturn; }

Enjoy!

--Jtpgames (talk) 13:27, 18 January 2015 (UTC)

Retrieved from "https://wiki.unrealengine.com/index.php?title=Get_Available_Screen_Resolutions_in_Blueprints&oldid=11080"

Categories:

Hidden category: