This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm (Experimental)
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine.Config Class

The Config class is used to read values (settings) from the application configuration file (configs/default.config by default) and write them back to it.

Use the appropriate methods depending on the type of the target item. For example, to get the values of the following items, you should use the getInt() and getString() methods respectively:

Source code (XML)
...
<item name="show_fps" type="int">1</item>
<item name="system_script" type="string">unigine_project/unigine.usc</item>
...

Usage Example#

By using the Config class, you can save custom settings to the configuration file and then restore it when required. For example:

AppSystemLogic.cs

Source code (C#)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Unigine;

namespace UnigineApp
{
	class AppSystemLogic : SystemLogic
	{

        private string player_avatar;
        private int skip_cutscenes;
        private int blood_enabled;
        private int bulletshell_lifetime;

		public override bool Init()
		{
	        // read custom user-defined settings from the configuration file
	        player_avatar = Config.GetString("player_avatar", "usa_soldier1");
	        skip_cutscenes = Config.GetBool("skip_cutscenes", 0);
	        blood_enabled = Config.GetBool("blood_enabled", 0);
	        bulletshell_lifetime = Config.GetInt("bulletshell_lifetime", 100);

			return true;
		}
		
		public override bool Shutdown()
		{
            // automatically save the configuration file at shutdown
			Config.IsAutosave = true;

	        // write the custom settings to the configuration file
	        Config.SetString("player_avatar", player_avatar);
	        Config.SetBool("skip_cutscenes", skip_cutscenes);
	        Config.SetBool("blood_enabled", blood_enabled);
	        Config.SetInt("bulletshell_lifetime", bulletshell_lifetime);
	        // save data to the custom configuration file, which is different from the default one
			Config.Path = "unigine_project/data/configs/my.config";
			Config.Save();

			return true;
		}
	}
}

See Also#

Config Class

Properties

bool Autosave#

Console: config_autosave
Value indicating if current Engine configuration settings are automatically saved to the corresponding config file on loading, closing, and saving the world, as well as on the Engine shutdown.
set
Sets a value indicating if current Engine configuration settings are automatically saved to the corresponding config file on loading, closing, and saving the world, as well as on the Engine shutdown.
set value - true to enable automatic saving of current Engine configuration settings; false — to disable it.

string Path#

Console: config
Path to the Engine config file (default: configs/default.config). This parameter is stored in the following configuration file: *.boot.
set
Sets a new path to the Engine config file (default: configs/default.config). The path can be specified as an absolute path or relative to the -data_path or <project_name> folder if the -project_name is set.
set value - New path to the Engine configuration file to be set.

Members


static void SetBool ( string name, bool value ) #

Sets a value of the given boolean setting. If the setting with this name already exists, its value is overwritten.

Arguments

  • string name - Name of the setting.
  • bool value - Boolean value (0 or 1). 0 stands for false, 1 stands for true.

static bool GetBool ( string name ) #

Reads the value of the given boolean setting.

Arguments

  • string name - Name of the setting.

Return value

Boolean value (0 or 1) of the setting. 0 stands for false, 1 stands for true.

static bool GetBool ( string name, bool value ) #

Reads the value of the given boolean setting. Returns the value specified as the second argument if the setting isn't found.

Arguments

  • string name - Name of the setting.
  • bool value - Custom value to be returned if the setting isn't found.

Return value

Boolean value (0 or 1) of the setting. 0 stands for false, 1 stands for true.

static bool IsExist ( string name ) #

Checks if the setting with the given name exists.

Arguments

  • string name - Name of the setting.

Return value

1 if the setting exists; otherwise, 0.

static void SetFloat ( string name, float value ) #

Sets a value of the given float setting. If the setting with this name already exists, its value is overwritten.

Arguments

  • string name - Name of the setting.
  • float value - Float value of the setting.

static float GetFloat ( string name, float value ) #

Reads the value of the given float setting. Returns the value specified as the second argument if the setting isn't found.

Arguments

  • string name - Name of the setting.
  • float value - Custom value to be returned if the setting isn't found.

Return value

Float value of the setting.

static float GetFloat ( string name ) #

Reads the value of the given float setting.

Arguments

  • string name - Name of the setting.

Return value

Float value of the setting.

static void SetInt ( string name, int value ) #

Sets a value of the given integer setting. If the setting with this name already exists, its value is overwritten.

Arguments

  • string name - Name of the setting.
  • int value - Integer value of the setting.

static int GetInt ( string name ) #

Reads the value of the given integer setting.

Arguments

  • string name - Name of the setting.

Return value

Integer value of the setting.

static int GetInt ( string name, int value ) #

Reads the value of the given integer setting. Returns the value specified as the second argument if the setting isn't found.

Arguments

  • string name - Name of the setting.
  • int value - Custom value to be returned if the setting isn't found.

Return value

Integer value of the setting.

static void SetString ( string name, string value ) #

Sets a value of the given string setting. If the setting with this name already exists, its value is overwritten.

Arguments

  • string name - Name of the setting.
  • string value - String value of the setting.

static string GetString ( string name, string value ) #

Reads the value of the given string setting. Returns the value specified as the second argument if the setting isn't found.

Arguments

  • string name - Name of the setting.
  • string value - Custom value to be returned if the setting is found.

Return value

String value of the setting.

static string GetString ( string name ) #

Reads the value of the given string setting.

Arguments

  • string name - Name of the setting.

Return value

String value of the setting.

static bool Load ( ) #

Console: config_load
Loads config from the file. To change the path to the configuration file use the setPath() method.

Return value

true if the config is successfully loaded from the file; otherwise, false.

static void Remove ( string name ) #

Removes the setting with the given name from the configuration file.

Arguments

  • string name - Name of the setting.

static bool Save ( ) #

Console: config_save
Saves the current configuration to the file. To change the path to the configuration file use the setPath() method.

Return value

true if the current configuration is successfully saved to the file; otherwise, false.
Last update: 2021-02-17
Build: ()