This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Landscape Tool
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
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
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

engine.materials Functions

Warning
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.

Interface for managing loaded materials via the code. All materials existing in the project are loaded depending on the current mode and saved on world's saving or on calling the materials_save console command.

See Also#

  • C++ API sample located in the folder <UnigineSDK>/source/samples/Api/Systems/Materials

Materials Class

Members


void engine.materials.reloadMaterials ( ) #

Reloads all loaded materials.

void engine.materials.destroyTextures ( ) #

Deletes all textures used by the loaded materials.

int engine.materials.replaceMaterial ( Material material, Material new_material ) #

Replaces the material with the given one.

Arguments

  • Material material - A material to be replaced.
  • Material new_material - A replacing material.

Return value

1 if the material is replaced successfully; otherwise, 0.

Material engine.materials.findManualMaterial ( string name ) #

Searches for a manual material by the given name.

Arguments

  • string name - A manual material name.

Return value

A manual material instance.

void engine.materials.setPrecompileAllShaders ( int shaders ) #

Enables or disables shader precompilation.

Arguments

  • int shaders - 1 to enable shader precompilation, 0 - to disable it.

int engine.materials.isPrecompileAllShaders ( ) #

Returns a value indicating if shader precompilation is enabled.

Return value

1 if shader precompilation is enabled; otherwise, 0.

void engine.materials.compileShaders ( ) #

Compiles shaders for all loaded materials.

void engine.materials.createShaders ( ) #

Creates all shaders for all loaded materials.

void engine.materials.destroyShaders ( ) #

Deletes all shaders used for the loaded materials.

int engine.materials.saveMaterials ( ) #

Saves changes made for all loaded materials.

Return value

1 if materials are saved successfully; otherwise, 0.

Material engine.materials.getMaterial ( int num ) #

Returns the material by its number.

Arguments

  • int num - Material number.

Return value

A material.

Material engine.materials.findMaterialByPath ( string path ) #

Searches for a material stored by the specified path.

Arguments

  • string path - A loading path of the material (including a material's name).

Return value

A material instance.

Material engine.materials.loadMaterial ( string path ) #

Loads a material stored by the given path. The function can be used to load materials created during application execution or stored outside the data directory.

Arguments

  • string path - A path to the material (including its name).

Return value

A loaded material.

int engine.materials.isMaterialGUID ( UGUID guid ) #

Returns a value indicating if a material with the specified GUID exists.

Arguments

Return value

1 if the material with the specified GUID exists; otherwise, 0.

Material engine.materials.findMaterialByGUID ( UGUID guid ) #

Searches for a material with the given GUID.

Arguments

Return value

A material instance.

int engine.materials.getNumMaterials ( ) #

Returns the number of materials loaded for the current project.

Return value

The number of materials.

int engine.materials.removeMaterial ( UGUID guid, int remove_file = 0, int remove_children = 1 ) #

Deletes a material. If the remove_file flag is enabled, the material file will be deleted as well. If the flag is disabled, the deleted material will be loaded again on the next application start-up. If the remove_children flag is enabled, all the children of the material will be deleted as well.

Arguments

  • UGUID guid - GUID of the material to be removed.
  • int remove_file - Flag indicating if the material file will be deleted.
  • int remove_children - Flag indicating if all the children of the material will be also deleted.

Return value

1 if the material is deleted successfully; otherwise, 0.

Material engine.materials.findMaterialByFileGUID ( UGUID guid ) #

Searches for a material with the given GUID of a material file.

Arguments

Return value

A material instance.

void engine.materials.setLoadingMode ( int mode ) #

Sets loading mode for materials to be used by the Engine at startup. By default materials loading in UNIGINE is optimized to reduce spikes during run time as much as possible, as they are totally unacceptable for simulators, as well as for a lot of other applications. However, this approach may significantly increase memory consumption and loading time at Engine’s and Editor startup. This may be a problem in case of insufficient memory capacity or when it is necessary to perform a lot of iterations quickly (e.g. development stage). This option enables you to choose between low memory consumption with faster loading time and smooth spikes-free run-time operation.

Arguments

  • int mode - Materials loading mode to be used by the Engine. One of the LOADING_MODE_* values.

int engine.materials.getLoadingMode ( ) #

Returns the current loading mode for materials used by the Engine at startup. By default materials loading in UNIGINE is optimized to reduce spikes during run time as much as possible, as they are totally unacceptable for simulators, as well as for a lot of other applications. However, this approach may significantly increase memory consumption and loading time at Engine’s and Editor startup. This may be a problem in case of insufficient memory capacity or when it is necessary to perform a lot of iterations quickly (e.g. development stage). This option enables you to choose between low memory consumption with faster loading time and smooth spikes-free run-time operation.

Return value

Materials loading mode currently used by the Engine. One of the LOADING_MODE_* values.
Last update: 2022-04-11
Build: ()