Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Application.ExternalCall 外部调用
# [Application](Application.html).ExternalCall 外部调用 static function *ExternalCall* (*functionName* : string, *params args* : object[]) : void *Description* 描述 Calls a function in the containing web page (Web Player only). 调用一个包含在网页中的函数(只用于 Web Player)。 This will call JavaScript function functionName in the web page that contains the web player, passing given arguments to it. Supported argument types are the primitive types (string, int, float, char) and arrays of them. Any other objects are converted to string (using ToString method) and passed as strings. 调用包含在网页中名为 functionNameJavaScript 函数,并传递给定的参数。支持原始的数据类型(string, int, float, char)和这些类型的数字。如何其他的对象被转化为字符串(使用 ToString 方法)并作为字符串传递。 The function is called non-blocking, i.e. ExternalCall immediately returns without waiting for the function that was called to complete. 这个函数调用时不会被阻塞,即 ExternalCall 立即返回的功能而不必等待被完成。 The number of passed arguments can be varying: 传递的参数数量是可变的。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public void Awake() { Application.ExternalCall("MyFunction1"); Application.ExternalCall("MyFunction2", "Hello from Unity!"); Application.ExternalCall("MyFunction3", "one", 2, 3.0F); } } ``` ``` // Calls MyFunction1 in web page with no arguments // 调用网页上的MyFunction1并不使用参数。 Application.ExternalCall ("MyFunction1"); // Calls MyFunction2 in web page with a string //调用网页上的MyFunction2并使用字符串参数。 Application.ExternalCall ("MyFunction2", "Hello from Unity!"); // Calls MyFunction3 in web page with several arguments of different types //调用网页上的MyFunction3并使用几个不同类型的参数。 Application.ExternalCall ("MyFunction3", "one", 2, 3.0); ``` The functions to be called are just declared in the HTML page using standard syntax, for example: 被调用的在 HTML 中的函数只需要使用标准的语法即可,例如: ``` <script language="JavaScript" type="text/javascript"> <!-- // Using the above call from Unity, this will receive // 使用来自Unity的调用,这将接受 // "Hello from Unity!" as the argument. // "Hello from Unity!" 做为参数 function MyFunction2( arg ) { alert( arg ); } --> </script> ``` 参见: [Application.ExternalEval](Application.ExternalEval.html).
da
2022年5月13日 22:57
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码