This page has been translated automatically.
Видеоуроки
Interface
Essentials
Advanced
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Professional (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Players
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Materials and Shaders
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
Containers
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
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Сэмплы материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine.NodeLayer Class

Inherits from: Node

A layer node is a zero-sized node that has no visual representation and enables to save all its child nodes into a separate .node file. Layer nodes should be used to split the world into several logical parts and save each of them in a .node file so that each layer and its child nodes can be edited without affecting the source .world file.

Notice
The layer node itself is not stored in the .node file.

Creating a Layer#

Create an instance of the NodeLayer class. You can also specify such settings as a name, transformation and so on.

NodeLayerClass.cs

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

[Component(PropertyGuid = "ca7e3fdc0ec5d98b0fbb616e3582b9f5331702d0")]
public class NodeLayerClass : Component
{
	private void Init()
	{
			// create a layer node
			NodeLayer layer = new NodeLayer("nodes/layer_0.node");
			// set a name for the node
			layer.Name = "layer_0";

			return 1;
		}
	}
}

Editing a Layer#

Editing a layer node includes adding, deleting, modifying its child nodes. For example, you can add new nodes as follows:

NodeLayerClass.cs

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

[Component(PropertyGuid = "ca7e3fdc0ec5d98b0fbb616e3582b9f5331702d0")]
public class NodeLayerClass : Component
{
	private void Init()
	{
		// create a layer node
		NodeLayer layer = new NodeLayer("nodes/layer_0.node");
		// set a name for the node
		layer.Name = "layer_0";

		// create child nodes
		for (int y = -10; y <= 10; y++)
		{
			for (int x = -10; x <= 10; x++)
			{

				// create a mesh
				Mesh mesh = new Mesh();
				mesh.AddBoxSurface("box_0", new vec3(1.0f));
				// create a node (e.g. an instance of the ObjectMeshDynamic class)
				ObjectMeshDynamic node = new ObjectMeshDynamic(mesh);
				
				// set node transformation
				node. WorldTransform = MathLib.Translate(new vec3(x * 2.0f, y * 2.0f, 0.0f));
				// set a name for the node
				node.Name = String.Format("mesh_{0}_{1}", x + 10, y + 10);

				// add the node as a child to the layer node
				layer.AddWorldChild(node);
			}
		}
	}
}

Saving a Layer#

Changes made in the child nodes of the layer node can be saved into the .node file by using the World.SaveNodes() function:

NodeLayerClass.cs

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

[Component(PropertyGuid = "ca7e3fdc0ec5d98b0fbb616e3582b9f5331702d0")]
public class NodeLayerClass : Component
{
	private void Init()
	{

		// create a layer node
		NodeLayer layer = new NodeLayer("nodes/layer_0.node");
		// set a name for the node
		layer.Name = "layer_0";

		// create child nodes
		for (int y = -10; y <= 10; y++)
		{
			for (int x = -10; x <= 10; x++)
			{
				// create a mesh
				Mesh mesh = new Mesh();
				mesh.AddBoxSurface("box_0", new vec3(1.0f));
				// create a node (e.g. an instance of the ObjectMeshDynamic class)
				ObjectMeshDynamic node = new ObjectMeshDynamic(mesh);
				
				// set node transformation
				node. WorldTransform = MathLib.Translate(new vec3(x * 2.0f, y * 2.0f, 0.0f));
				// set a name for the node
				node.Name = String.Format("mesh_{0}_{1}", x + 10, y + 10);

				// add the node as a child to the layer node
				layer.AddWorldChild(node);
			}
		}

		// declare a list of nodes
		List<Node> nodes_list = new List<Node>();
		// add child nodes of the layer to the declared list
		for (int i = 0; i < layer.NumChildren; i++) {
			nodes_list.Add(layer.GetChild(i));
		}
		// convert the list to Unigine.Node[] array so that nodes can be saved to a file later
		Node[] nodes = nodes_list.ToArray();

		// save nodes to the .node file
		if (World.SaveNodes(layer.NodePath, nodes) == 0) {
			Log.Error("Layer hasn't been saved\n");
		}
	}
}

See Also#

NodeLayer Class

Properties

string NodePath#

The path to the node layer: a path to a .node file where child nodes of the layer are stored.

Members


NodeLayer ( string name ) #

Constructor. Creates a node layer with specified file name to store it.

Arguments

  • string name - Name of the layer.

static int type ( ) #

Returns the type of the node.

Return value

NodeLayer type identifier.
Last update: 14.12.2022
Build: ()