Detect if Custom Depth is Enabled with Stencil from Blueprints

I am working on an asset for the marketplace that requires the Custom Depth - Stencil pass to be set to Enabled with Stencil.

I would like to implement some sort of error message for users to warn them if they haven’t activated this option.

Is there a way to detect if the setting is properly set from blueprint?

header file

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

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

/**
 * 
 */
UCLASS()
class YOUR_API UPluginCheck : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
	
	UFUNCTION(BlueprintCallable)
	static bool CheckStencil();
};

.cpp

// Fill out your copyright notice in the Description page of Project Settings.


#include "PluginCheck.h"
#include "Framework/Notifications/NotificationManager.h"
#include "EditorStyleSet.h"
#include "Widgets/Notifications/SNotificationList.h"

bool UPluginCheck::CheckStencil() 
{

	if (!GConfig) return false;

	FString CustomDepth;
	GConfig->GetString(TEXT("/Script/Engine.RendererSettings"), TEXT("r.CustomDepth"), CustomDepth, GEngineIni);

	if (CustomDepth == "0")
	{
		FNotificationInfo Info(FText::FromString("Custom stencil disabled"));  //LOCTEXT("CustomStencilDisabled", "Custom stencil disabled") 
		Info.Image = FEditorStyle::GetBrush(TEXT("LevelEditor.RecompileGameCode"));
		Info.FadeInDuration = 2.1f;
		Info.FadeOutDuration = 2.5f;
		Info.ExpireDuration = 2.5f;
		Info.bUseThrobber = false;
		Info.bUseSuccessFailIcons = true;
		Info.bUseLargeFont = true;
		Info.bFireAndForget = false;
		Info.bAllowThrottleWhenFrameRateIsLow = false;
		auto NotificationItem = FSlateNotificationManager::Get().AddNotification(Info);
		NotificationItem->SetCompletionState(SNotificationItem::CS_Fail);
		NotificationItem->ExpireAndFadeout();
		//GEditor->PlayEditorSound(CompileSuccessSound);
	}
	//CustomDepth 0 = off

	return CustomDepth != "0";
}

You are going to need “slate” and “EditorStyle” in your plugin build file.

EditorStyle might be engine only so you may need to split your include to an editor only part with the check

Hook up the function to your plugin start up if editor.


Full project with custom plugin split Game / Editor (UE 5.4)

Edit removed binaries in plugin to reduce size

stencilChecker5_4.zip (33.5 KB)

The editor / runtime split can be a bit complex as the editor part should never be cooked into the project otherwise it would cause build errors.