LoginSignup
10
8

More than 3 years have passed since last update.

[UE4]ConsoleVariables.iniの特殊性

Last updated at Posted at 2019-12-15

ConsoleVaribels.ini

例えばusfファイルなどをいじる場合、公式などに
Engine/Config/ConsoleVariables.iniのr.ShaderDevelopmentModeの行のコメントを外すべし!
と書かれていたりして、それを編集することが多いと思います。

シェーダー開発|UnrealEngineDocument

しかし、チーム開発を行う場合Engine内部のファイルはバージョンコントロールに格納されている場合が多いと思います。
そのため自分だけこのコンソール変数が弄れれば十分なのに、わざわざサーバーに送信してしまわないようにしていたり、
潔くサブミット(コミット)してしまったりということがあると思います。

iniの階層構造とConsoleVariables.ini

ドキュメントにはコンフィグファイルには階層構造があり、基底のパラメータをオーバーライドできるような記述があります。
コンフィギュレーションファイル|UnrealEngineDocument

しかしこの階層構造は ConsoleVariables.ini には存在しません
そのため、[ProjectPath]/Config/DefaultConsoleVariable.ini や [ProjectPath]/Saved/Config/[Platform]/ConsoleVariable.ini を用意しても
読み込まれません。ぐぬぬ。

※なんでそうなるかはConfigCacheIni.cppを読んでください

自分だけ設定できればいいのに・・・

ソースを見てみます。

ConfigCacheIni.cpp
void FConfigCacheIni::LoadConsoleVariablesFromINI()
{
    FString ConsoleVariablesPath = FPaths::EngineDir() + TEXT("Config/ConsoleVariables.ini");

#if !DISABLE_CHEAT_CVARS
    // First we read from "../../../Engine/Config/ConsoleVariables.ini" [Startup] section if it exists
    // This is the only ini file where we allow cheat commands (this is why it's not there for UE_BUILD_SHIPPING || UE_BUILD_TEST)
    ApplyCVarSettingsFromIni(TEXT("Startup"), *ConsoleVariablesPath, ECVF_SetByConsoleVariablesIni, true);
#endif // !DISABLE_CHEAT_CVARS

    // We also apply from Engine.ini [ConsoleVariables] section
    ApplyCVarSettingsFromIni(TEXT("ConsoleVariables"), *GEngineIni, ECVF_SetBySystemSettingsIni);

    IConsoleManager::Get().CallAllConsoleVariableSinks();
}

おっ! ConsoleVariablesとかGEngineIniとかが見えますね。
早速書いてみましょう!

Saved/Config/Windows/Engine.ini
[Core.System]
Paths=../../../Engine/Content
Paths=%GAMEDIR%Content
Paths=../../../Engine/Plugins/2D/Paper2D/Content

......

[ConsoleVariables]                 ;追加
r.ShaderDevelopmentMode=4          ;追加

そして起動!
ばっちり設定されています!

image.png

起動ログにもどんなパラメータが読まれたのか書いてあったりします。
LogConfigを探してみてください。

LogConfig: Applying CVar settings from Section [Startup] File [../../../Engine/Config/ConsoleVariables.ini]
LogConfig: Setting CVar [[r.DumpShaderDebugInfo:1]]
LogConfig: Setting CVar [[net.UseAdaptiveNetUpdateFrequency:0]]
LogConfig: Setting CVar [[p.chaos.AllowCreatePhysxBodies:1]]
LogConfig: Applying CVar settings from Section [ConsoleVariables] File [D:/dev/UE423projects/TPBP423Config/Saved/Config/Windows/Engine.ini]
LogConfig: Setting CVar [[r.ShaderDevelopmentMode:4]]

まとめ

[projectpath]/Saved/Config/Windows/DefaultEngine.ini[ConsoleVariables] セクションに設定することで、
自分の開発環境固有のコンソール変数を適用することができます。
各自の開発環境ごとにあるSavedの下に保存されたiniファイルならCIなどに取り込まれて、慌てることはありません。

逆にプロジェクトとして設定したいものに関しては、
[projectpath]/config/DefaultEngine.ini[ConsoleVariables] セクションに記述することで
ゲームの動作設定を最終ビルドに含めることができます。

10
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
8