本文介绍了UnityScript“通用函数"在Unity 5中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在其网站上浏览Unity3D教程时( http://unity3d.com/learn/tutorials/projects/roll-a-ball/moving-the-player )我遇到了通用函数".

While following through the Unity3D tutorials on their website (http://unity3d.com/learn/tutorials/projects/roll-a-ball/moving-the-player) I have come across "generic functions".

http://docs.unity3d.com/Manual/GenericFunctions.html

用C ++来说,我会称它们为模板.在他们的UnityScript中,它看起来像这样:

In C++ speak, I would have called them templates. In their UnityScript it looks like this:

var obj = GetComponent.<Rigidbody>();

我试图在网上寻找其他地方,以详细了解这些东西的工作方式以及如何编写使用它的UnityScript代码,但是我还是空了.我想知道我是否不是在寻找正确的术语.他们说UnityScript基于Javascript,但是我怀疑这是特定于Unity的UnityScript编译器.

I've tried looking elsewhere online to get a rundown of exactly how this stuff works, and how I can write UnityScript code that uses it, but I've come up empty. I wonder if I'm just not searching for the correct terms. They say that UnityScript is based off of Javascript, but I suspect that this is specific to Unity's UnityScript compiler.

通用函数"在JavaScript的ECMAScript版本中不存在,仅在Unity版本中存在.

"Generic functions" do not exist in the ECMAScript version of JavaScript, only in Unity's version.

这个问题是在Unity仍称其专有脚本语言"Javascript"时发布的,尽管现在他们似乎再次将其称为UnityScript.这本来可以避免首先提出这个问题.

This question was posted when Unity was still calling their proprietary scripting language "Javascript", although they now seem to be calling it UnityScript again. This would have prevented the question from ever being asked in the first place.

推荐答案

UnityScript和JavaScript是两种不同的语言.

UnityScript and JavaScript are two different languages.

关于泛型/模板.

来源 UnityScript与JavaScript:UnityScript具有.NET的OOP功能

另请参阅:

  • Head First into Unity with UnityScript
  • UnityScript versus JavaScript

这篇关于UnityScript“通用函数"在Unity 5中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:11