This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

USC Interpreter

The stand-alone interpreter (called USC due to its script file extension) allows for making Unigine scripts into executable programs that are run directly from the environment or from the command-line. As the interpreter works independently, it offers an easy way for developers to extend the functionality and solve the specific or recurring tasks for which it is not necessary to create a separate executable application.

Source code of the stand-alone interpreter can be found under <UnigineSDK>/source/tools/Interpreter.

What Can It Be Used for?

Core library The stand-alone interpreter includes the Core library and can be used to read/write files, parse XML files, handle images, perform mathematical calculations, etc.
Meshes Load and save a mesh, modify or clear all its data. You can add and set transformation to mesh surfaces, as well as change position, normal vectors and texture coordinates for separate vertices.
Skinned meshes Just like in case with simple meshes, you can get access and modify surface and vertex data for skinned meshes. Data on bones of the rig is also exposed.
Command line arguments Pass any number of arguments to the executable script via the command line. (See examples below.)
Logging Print notify messages, warnings and errors to track progress of script execution, if necessary.

How to Run USC

Running USC on Windows

To use Interpreter on Windows, follow these steps:

  1. Create a script to be executed and save it with *.usc extension.
  2. Associate usc files with <UnigineSDK>/bin/usc_*.exe. Depending on the postfix, it can be either 32-bit (_86) or 64-bit, debug (d) or release (no postfix) version of the Interpreter.

Running USC on Linux or Mac OS X

To use Interpreter on Linux or Mac OS X, follow these steps:

  1. Add a path to <UnigineSDK>/bin/usc_*.exe to environment variables. Depending on the postfix, you can use either 32-bit (_86) or 64-bit, debug (d) or release (no postfix) version of the Interpreter.
  2. In the first line line of your script, use the following:
    Shell commands
    #!/usr/bin/env usc
    

How to Create USC Script

To create USC script (written in UnigineScript), use main() function as an entry point:

Source code (UnigineScript)
void main()
{
  // Code
}

Below are given examples how to pass command-line arguments to the USC script.

Example 1. Printing All Command-line Arguments

Source code (UnigineScript)
#!/usr/bin/env usc

/*
 */
void main() {
	forloop(int i = 0; getNumArgs()) {
		log.message("Arg [%d]: %s\n",i,getArg(i));
	}
}

Example 2. Setting Variables Passed via the Command Line

Source code (UnigineScript)
#!/usr/bin/env usc

int value1 = 0;
int value2 = 0;

/*
 */
void main() {
	for(int i = 0; i < getNumArgs(); i++) {
		string arg = getArg(i);
		
		if(arg == "-set_value_1") {
			if(i + 1 >= getNumArgs()) {
				continue;
			}
			value1 = int(getArg(++i));
			continue;
		}
		
		if(arg == "-set_value_2") {
			if(i + 1 >= getNumArgs()) {
				continue;
			}
			value2 = int(getArg(++i));
			continue;
		}
	}
	
	log.message("value1: %d\nvalue2: %d\n",value1,value2);
}
Last update: 2017-07-03
Build: ()