This page has been translated automatically.
Setting Up Materials
Setting Up Properties
Landscape Tool
Extending Editor Functionality
World Nodes
Sound Objects
Pathfinding Objects
Usage Examples
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
Common Functionality
Controls-Related Classes
Engine-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
Content Optimization
Material Nodes Library
Art Samples


This article describes in detail the steps taken by the UNIGINE engine when the Engine::init() function is called. For other steps and general information about execution sequence, see the Execution Sequence article.本文详细介绍了UNIGINE引擎在调用Engine::init()函数时所采取的步骤。有关执行顺序的其他步骤和一般信息,请参阅执行顺序文章。

Initialization steps初始化步骤#

The engine initialization starts when the main executable application (64-bit version of the .exe file, debug or release one) loads the corresponding UNIGINE library (.dll, .so, or .dylib). From this point on, the following steps are performed:当主要的可执行应用程序(.exe 文件的 64 位版本,调试或发行版)加载相应的 UNIGINE 库(.dll, .so.dylib)时,引擎初始化开始。从现在开始,执行以下步骤:

  1. The UNIGINE memory allocator is initialized for faster and more optimal allocations compared to the default system allocator. In the engine code, it is set via the USE_MEMORY directive.与默认系统分配器相比,UNIGINE 内存分配器被初始化为更快和更优化的分配。在引擎代码中,它是通过 USE_MEMORY 指令设置的。
  2. Command-line options are parsed, namely: options that set paths to the data folder, plugin directories, log and configuration files, and also the project name.命令行选项被解析,即:设置路径到 data 文件夹的选项,插件目录,日志配置文件,还有项目名.

    Command-line values override the default values and values specified in the configuration files.命令行值覆盖默认值和指定的值配置文件.
  3. Four (4) threads are created: a sound, a world, a render, and a file system thread.创建了四个 (4) 线程:声音、世界、渲染和文件系统线程。
  4. A path to the folder where all application data will be saved by default: 默认保存所有应用程序数据的文件夹路径:

    • If you pass a project name via the command line or on engine initialization, all data (such as log files, cache, and configuration files) are stored in the user's home directory as follows:如果你通过一个项目名通过命令行或引擎初始化,所有数据(如日志文件、缓存和配置文件)都存储在用户的主目录中,如下所示:

      • On Windows, in the C:/Users/<username>/<project_name>/ folder在 Windows 上,在 C:/Users/<username>/<project_name>/ 文件夹中
      • On Linux, in the /home/<username>/.<project_name>/ folder在 Linux 上,在 /home/<username>/.<project_name>/ 文件夹中
    • Otherwise, data is stored in the application folder (<UNIGINE SDK>/bin/ with the binary executable file).否则,数据将存储在应用程序文件夹中(带有二进制可执行文件的 <UNIGINE SDK>/bin/)。
  5. A log file is created. If not specified in the command-line options, the default log file is placed in the application directory under the name log.txt.一个日志文件被创建。如果未在命令行选项中指定,默认日志文件将放置在名称为 log.txt 的应用程序目录中。
  6. Remaining command-line options are parsed (the ones that haven't been parsed previously). These options specify basic video settings, such as a graphics API to be used for rendering (DirectX or OpenGL; also you can disable the graphics API), size of the application window, and so on.其余的命令行选项被解析(那些没有被解析的之前)。这些选项指定基本的视频设置,例如用于渲染的图形 API(DirectX 或 OpenGL;您也可以禁用图形 API)、应用程序窗口的大小等。

    You can also pass any external #define directives and console variables via the command line. 您还可以传递任何外部 #define 指令和控制台变量通过命令行。

    Command-line values override the default values and values specified in the configuration files.命令行值覆盖默认值和指定的值配置文件.
  7. A path to the project *.cache files is set. Usually cache files include compiled shaders, system and Editor Logic.设置了项目 *.cache 文件的路径。通常缓存文件包括编译的着色器、系统和编辑器逻辑。
  8. External plugin libraries specified in the -extern_plugin command line option and plugin libraries stored in the plugin directories specified in the -plugin_path option are loaded.外部插件加载在 -extern_plugin 命令行选项中指定的库和存储在 -plugin_path 选项中指定的插件目录中的插件库。

    A custom plugin library can be loaded at any moment of UNIGINE run time.自定义插件库可以是加载在 UNIGINE 运行时的任何时刻。
  9. The File System is initialized. If project files are packed into UNG or ZIP archives protected by a password, the engine checks if the password coincides with the password set for the binary file (if any) and loads these archives.文件系统被初始化。如果项目文件被打包成 UNG 或 ZIP档案受密码保护,引擎检查密码是否与为二进制文件(如果有)设置的密码一致并加载这些档案。
  10. The dedicated asset management subsystem of the Engine's file system is initialized and performs scanning for all run-time files.敬业的资产管理子系统引擎的文件系统被初始化并执行扫描所有运行时文件.
  11. Render and sound managers that will automatically organize and handle rendering and sounds are initialized.将自动组织和处理渲染和声音的渲染和声音管理器被初始化。
  12. The Boot screen is shown based on the default.boot configuration file.开机画面基于 default.boot 显示配置文件.
  13. If the materials_loading_mode console variable is set to 2, all shaders in the application are compiled and cached.如果 materials_loading_mode console 变量设置为 2,则应用程序中的所有着色器都会被编译和缓存。
  14. The application window is created based on the specified settings. 根据指定的设置创建应用程序窗口。
  15. All engine subsystems (such as visualizer, physics, sound, render, pathfinding subsystems, and so on) are created.创建了所有引擎子系统(例如 visualizer、物理、声音、渲染、寻路子系统等)。
  16. Sound and file system threads are run.运行声音和文件系统线程。
  17. External definitions passed in the -extern_define command line option are set.设置了在 -extern_define 命令行选项中传递的外部定义。
  18. The init() functions of all loaded plugins are called.调用所有加载的插件的 init() 函数。
  19. Console commands from the command line are queued for further execution.控制台命令从命令行排队等待进一步执行。
  20. The Splash screen is shown if it is enabled.启动画面如果启用则显示。
  21. The System Logic is loaded and started. Basically, the System Logic performs housekeeping necessary to start and keep the UNIGINE-based application going. It stays loaded during the whole UNIGINE run time.The系统逻辑已加载并启动。基本上,系统逻辑执行启动和保持基于 UNIGINE 的应用程序运行所需的内务处理。它在整个 UNIGINE 运行时保持加载状态。

    The default system script, when initialized, does the following:默认系统脚本在初始化时执行以下操作:

    • Loads a localization file.加载本地化文件。
    • Initializes the main menu.初始化主菜单。
    • Sets the Loading screen, if necessary. It is better to set the loading screen before loading a world. In this case, displaying a loading screen will give the engine time to load resources and compile shaders. By default, a standard UNIGINE screen is shown. 设置载入画面,如有必要。最好在之前设置加载屏幕加载一个世界.在这种情况下,显示加载屏幕将使引擎有时间加载资源和编译着色器。默认情况下,显示标准 UNIGINE 屏幕。
    You can replace the default system script located in the data/core/unigine.usc with a custom one. In this script, you can set your own loading screen for the project, specify custom modules to be loaded, and so on. For large projects, it makes sense to specify the world you want to load right in your system script.您可以使用自定义脚本替换位于 data/core/unigine.usc 中的默认系统脚本。在此脚本中,您可以为项目设置自己的加载屏幕,指定要加载的自定义模块等。对于大型项目,有必要指定世界你想在你的系统脚本中加载。

    If you use a custom system script, it performs the logic you implemented.如果您使用自定义系统脚本,它会执行您实现的逻辑。

  22. Console commands from the command line that were queued previously are run.运行之前排队的命令行中的控制台命令。

    If you want to run console commands from the system script, they are run after the queued console commands.如果您想从系统脚本运行控制台命令,它们将在排队的控制台命令之后运行。
  23. If the render_shaders_preload console variable is specified in the command line, shaders used in the world to be loaded are compiled and cached.如果render_shaders_preload 在命令行中指定console变量,加载世界中使用的shader被编译缓存.

    However, a shader cache file is large and its loading on engine initialization drops performance.但是,着色器缓存文件很大并且它在引擎初始化时的加载会降低性能。

If the initialization is completed successfully, a non-zero value is returned, and the execution process continues.如果初始化成功完成,则返回一个非零值,并继续执行过程。

最新更新: 2021-06-24
Build: ()