UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
编程
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
应用程序接口
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

Return语句

警告
UnigineScript已过时,将在以后的版本中删除。请考虑切换到C#/ C ++,因为这些API是首选。无法保证UnigineScipt中新引擎功能的可用性,因为当前的支持水平仅假设解决关键问题。

return语句终止函数的执行并返回一个值和程序控制给调用程序,即返回到代码行,函数正是从此行得到调用。

语法#

源代码 (UnigineScript)
return value;

部分#

  • value为返回的值。此为可选选项。

示例#

源代码 (UnigineScript)
int foo(int a) {
	return a * a;
}
log.message("%d\n",foo(3));

// 结果为: 9

如果函数返回的是一个数组,矢量或矩阵,可使用下列方法访问每个元素:

源代码 (UnigineScript)
vec3 foo() {
	return vec3(1.0f,2.0f,3.0f);
}

log.message("%f %f\n",foo().x,foo()[2]);

//输出为: 1.0 3.0
返回元素值的搅和也可用:
源代码 (UnigineScript)
log.message("%f %f\n",translate(1.0f,2.0f,3.0f).m23,translate(1.0f,2.0f,3.0f)[14]);

// 结果为: 3.0 3.0
最新更新: 2017-07-03