Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Object.FindObjectsOfType 查找 Type 物体
# [Object](Object.html "Go to Object scripting documentation").FindObjectsOfType 查找 Type 物体 static function *FindObjectsOfType* (*type* : Type) : Object[] *Description* 描述 Returns a list of all active loaded objects of Type type. 返回 Type 类型的所有激活的加载的物体列表 It will return no assets (meshes, textures, prefabs, ...) or inactive objects. 它将返回任何资源(网格,纹理,预设,...)或激活的物体。 Please note that this function is very slow. It is not recommended to use this function every frame. In most cases you can use the singleton pattern instead. 请注意这个函数是非常慢的。不推荐在每帧使用这个函数,大多数情况下你可以使用单例模式代替。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { void OnMouseDown() { HingeJoint[] hinges = FindObjectsOfType(typeof(HingeJoint)) as HingeJoint[]; foreach (HingeJoint hinge in hinges) { hinge.useSpring = false; } } } ``` ``` // When clicking on the object, it will disable all springs on all hinges in the scene. //当点击物体,它将禁用场景中所有铰链中的弹簧 function OnMouseDown () { var hinges : HingeJoint[] = FindObjectsOfType(HingeJoint) as HingeJoint[]; for (var hinge : HingeJoint in hinges) { hinge.useSpring = false; } } ```
da
2022年5月23日 14:12
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码