# Unlit Mode in packaged game

**URL:** <https://forums.unrealengine.com/t/unlit-mode-in-packaged-game/527900>\
**Category:** Rendering\
**Tags:** unreal-engine, Rendering\
**Created:** [April 14, 2022, 5:49am UTC](https://forums.unrealengine.com/t/unlit-mode-in-packaged-game/527900 "2022-04-14T05:49:02Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![Kulagin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kulagin](https://forums.unrealengine.com/u/Kulagin)\
**Post date:** [September 12, 2024, 6:16am UTC](https://forums.unrealengine.com/t/unlit-mode-in-packaged-game/527900/16 "2024-09-12T06:16:00Z")

</div>

> [@hydr0k](#):
>
> added r.ForceDebugViewModes=1 under [/Script/Engine.RendererSettings] in DefaultEngine.ini

This was supposed to work, I guess. The console command `r.ForceDebugViewModes` is registered in the engine: [https://github.com/EpicGames/UnrealEngine/blob/40eea367040d50aadd9f030ed5909fc890c159c2/Engine/Source/Runtime/RenderCore/Private/ShaderCore.cpp#L366](https://github.com/EpicGames/UnrealEngine/blob/40eea367040d50aadd9f030ed5909fc890c159c2/Engine/Source/Runtime/RenderCore/Private/ShaderCore.cpp#L366)

But it doesn’t work, because it’s not actually used by the `viewmode` console command processing function:

[https://github.com/EpicGames/UnrealEngine/blob/40eea367040d50aadd9f030ed5909fc890c159c2/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp#L3585](https://github.com/EpicGames/UnrealEngine/blob/40eea367040d50aadd9f030ed5909fc890c159c2/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp#L3585)

Instead, what we have is:

```auto
#if UE_BUILD_TEST || UE_BUILD_SHIPPING
	Ar.Logf(TEXT("Debug viewmodes not allowed in Test or Shipping builds."));
	ViewModeIndex = VMI_Lit;
#else

```

So it just forcefully sets the view mode to lit in shipping build no matter what option you choose. So, what do we do? Well, one way is to create our own console command that actually works in all builds. Or just replicate the behavior of this Unreal function and put it in a blueprint library and call it from C++ or blueprints respectively. That’s what I intend to do now.

Here’s the solution that actually works:  
In your C++ blueprint function library(create one if you don’t already have one):  
Header:

```cpp
UFUNCTION(BlueprintCallable)
static void SetViewMode(EViewModeIndex ViewMode);

```

Source file:

```cpp
void UMyBlueprintFunctionLibrary::SetViewMode(EViewModeIndex ViewMode) {
	ApplyViewMode(ViewMode, false, GEngine->GameViewport->EngineShowFlags);
	GEngine->GameViewport->ViewModeIndex = ViewMode;
}

```

---

_[View the full topic](https://forums.unrealengine.com/t/unlit-mode-in-packaged-game/527900)._
