配置文件

If you have successfully compiled a custom Unrealscript class, chances are you’ve heard about Unreal configuration files, 

and you’ve most likely already modified one. The UDN documentation on configuration files is quite thin, but a must read nevertheless.

In this article, I’ll try to provide some insight on the various config files, and the most important things to know.

Note that most of what’s written below is the result of observation and speculation of various experiments.

Config file hierarchy

If you look into the the various files in Engine and UDKGame folders, you’ll notice 4 patterns:

  • Base*.ini
  • Default*UDK.ini
  • Default*.ini (without the appended “UDK”, of course)
  • UDK*.ini

As stated in the documentation you can create a hierarchy between the config files.

 The patterns mentioned above are listed in their default order of hierarchy.

UDK*.ini

These are the files actually used by the game. They are generated when udk.exe is run (i.e. launching the game, the editor or compiling script) 

under certain conditions (which I have yet to pinpoint). It’s basically a copy of all information contained in the

 Default* counterpart of the file and its parents (using the most overridden version of the values).

Example:

  • In BaseEngine.ini, GameName is set to “Default Game Name”.
  • In DefaultGameUDK.ini (which is based on BaseEngine.ini), GameName is “Unreal Development Kit”.
  • In DefaultGame.ini (which is based on BaseEngine.ini) this property is not overridden.
  • As a result, in UDKGame.ini, DefaultGameName is “Unreal Development Kit”

As a rule of thumb, I usually avoid modifying stuff in the UDK* files as on some occasions I’ve seen the files being 

completely regenerated and my changes reverted, though I couldn’t figure out why it did this. I’d rather use the 

Default* files. However be careful when you’re upgrading to a newer version of UDK.

Another reason not to modify the UDK*.ini by hand, is that if you use SaveConfig() or SaveStaticConfig(), you 

will write into those files. So if something goes wrong with your saving algorithms, you can completely mess up your intial settings.

Custom .ini files

If you want your config variables to be stored in a new file (in the UDKGame Folder), like below:

1
class MyActor extends Actor config (MyGame);

the engine will be expecting a file named UDKMyGame.ini. If you create a DefaultMyGame.ini, the UDKMyGame.ini 

will automatically be created. Actually, provided at least one class is set to get its config values from X, the engine 

will automatically parse DefaultX.ini (if it exists in the UDKGame/Config folder) to create UDKX.ini

Arrays and structures in config files

It’s kind of implied in the documentation, but I think this may need more explicit explanations.

Arrays

If you define in your class an array and set it as config, you will be able to use the special characters to

 add or remove items. Let’s demonstrate this with a famous example:

EditorEngine.uc (UDK November 2010):

1
2
/** the list of package names to compile when building scripts */
var (Advanced) globalconfig array EditPackages;

DefaultEngine.ini (UDK November 2010):

1
2
3
[UnrealEd.EditorEngine]
+EditPackages=UTGame
+EditPackages=UTGameContent
Structures

If you define a variable whose type a structure as a config variable, there’s a special syntax to set the structure’s value in the config file:

Variable=(struct_member1=value1[,struct_member2=value2...])

Let’s take another famous example:

Input.uc (UDK November 2010):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
struct native KeyBind
{
     var config name Name;
     var config string Command;
     var config bool Control, Shift, Alt;
 
     /** if true, the bind will not be activated if the corresponding key is held down */
     var config bool bIgnoreCtrl, bIgnoreShift, bIgnoreAlt;
 
     structcpptext
     {
         FKeyBind() : Name() ,
         Control(FALSE),
         Shift(FALSE),
         Alt(FALSE),
         bIgnoreCtrl(FALSE),
         bIgnoreShift(FALSE),
         bIgnoreAlt(FALSE)
         {}
     }
};
 
var config array  Bindings;

DefaultInput.ini (UDK November 2010):

1
.Bindings=(Name= "SpaceBar" ,Command= "GBA_Jump" )
Arrays inside structures

You need to specify each element of the array as a structure member. Example:

DefaultInput.ini (UDK November 2010):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
+InputAliases=
(
     AliasName= "Generic_A" ,
     PlatformInputKeys[0]=
     (
         InputKeyData= (InputKeyName= "XboxTypeS_A" ),
         ButtonFontMarkupString= ""
     ),
     PlatformInputKeys[1]=
     (
         InputKeyData= ( InputKeyName= "XboxTypeS_A" ),
         ButtonFontMarkupString= ""
     ),
     PlatformInputKeys[2]=
     (
         InputKeyData= ( InputKeyName= "XboxTypeS_A" ),
         ButtonFontMarkupString= ""
     )
)

You can see how complex it can get.

NOTE: I indented this so it’s easier to read. However, you must write all this on the same line in the config file in order for it to work.

Example: Debug Menu config file

In the article on Canvas HUD, where I show the beginning of a Debug menu, I defined the contents 

of the menu in the default properties. This means if I want to change the contents, I need to recompile the game.

 Quite unnecessary. So, we’re going to put that in a config file. And that’s actually really easy.

First, we need to tell the Pages variable to fetch its contents in a config file, and tell the class which config files it should look in for its config values:


1
2
3
class SandboxDebugMenu extends CheatManager within PlayerController config (DebugMenu);
 
var config array Pages;


Next, we’re going to create a DefaultDebugMenu.ini file, with the following content:


1
2
3
4
[Sandbox.SandboxDebugMenu]
Pages=(PageName= "General" ,PageCommands[0]=(CmdName= "Toggle Debug Camera" ,Command= "ToggleDebugCamera" ))
Pages=(PageName= "Debug Info" ,PageCommands[0]=(CmdName= "Turn off Debug Info" ,Command= "showdebug none" ),
PageCommands[1]=(CmdName= "Toggle Pawn Debug Info" ,Command= "showdebug pawn" ),
PageCommands[2]=(CmdName= "Toggle Camera Debug Info" ,Command= "showdebug camera" ),
PageCommands[3]=(CmdName= "Toggle Pawn Weapon Info" ,Command= "showdebug weapon" ))
Pages=(PageName= "HUD" ,PageCommands[0]=(CmdName= "Toggle HUD" ,Command= "ToggleHUD" ))


And there’s nothing more to be done. Next time you launch the game, UDKDebugMenu.ini will be created, and it should just work!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值