UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
编程
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes

Return语句

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
最新更新: 2018-08-10