当前位置:网站首页>unity3d-GameObject组件
unity3d-GameObject组件
2022-07-22 05:56:00 【MaNongSa】
GameObject组件
提示:以下是本篇文章正文内容
GameObject
class in UnityEngine/继承自:Object
- 描述
- Unity 场景中所有实体的基类。
- 注意:GameObject 类中的很多变量已被删除。例如, 要访问 csharp 中的 GameObject.renderer,请改用 GetComponent()。
- 变量
变量名 | 作用 |
---|---|
activeInHierarchy 简单使用 | 判断 GameObject 在 Scene 中是否处于活动状态。 |
activeSelf | 此 GameObject 的本地活动状态。(只读) |
isStatic 、获取并设置 GameObject 的 StaticEditorFlags。 | |
layer | 该游戏对象所在的层。 |
scene | 该 GameObject 所属的场景。 |
sceneCullingMask | Unity 用于确定在哪个场景中渲染该 GameObject 的场景剔除遮罩。 |
tag | 此游戏对象的标签。 |
transform | 附加到此 GameObject 的 Transform。 |
- 构造函数
函数名 | 作用 |
---|---|
GameObject | 创建一个名为 name 的新游戏对象。 |
- 公共函数
函数名 | 作用 |
---|---|
AddComponent | 将名为 className 的组件类添加到该游戏对象。 |
BroadcastMessage | 调用此游戏对象或其任何子项中的每个 MonoBehaviour 上名为 methodName 的方法。 |
CompareTag | 此游戏对象是否使用 tag 进行了标记? |
GetComponent | 如果游戏对象附加了类型为 type 的组件,则将其返回,否则返回 null。 |
GetComponentInChildren | 使用深度首次搜索返回 GameObject 或其任何子项中类型为 type 的组件。 |
GetComponentInParent | 获取 GameObject 或其任何父项中 Type type 的组件。 |
GetComponents | 返回 GameObject 中类型为 type 的所有组件。 |
GetComponentsInChildren | 返回 GameObject 或其任何子项中类型为 type 的所有组件。 |
GetComponentsInParent | 返回 GameObject 或其任何父项中类型为 type 的所有组件。 |
SendMessage | 调用此游戏对象中的每个 MonoBehaviour 上名为 methodName 的方法。 |
SendMessageUpwards | 调用此游戏对象中的每个 MonoBehaviour 上或此行为的每个父级上名为 methodName 的方法。 |
SetActive | 根据给定的值 true 或 /false/,激活/停用 GameObject。 |
TryGetComponent | 获取指定类型的组件(如果存在)。 |
- 静态函数
函数名 | 作用 |
---|---|
CreatePrimitive | 创建一个具有原始网格渲染器和相应碰撞体的游戏对象。 |
Find | 按 name 查找 GameObject,然后返回它。 |
FindGameObjectsWithTag | 返回标签为 tag 的活动 GameObjects 的数组。如果未找到任何 GameObject,则返回空数组。 |
FindWithTag | 返回一个标记为 tag 的活动 GameObject。如果未找到 GameObject,则返回 null。 |
继承的成员
- 变量
变量名 | 作用 |
---|---|
hideFlags | 该对象应该隐藏、随场景一起保存还是由用户修改? |
name | 对象的名称。 |
- 公共函数
函数名 | 作用 |
---|---|
GetInstanceID | 返回对象的实例 ID。 |
ToString | 返回对象的名称。 |
- 静态函数
函数名 | 作用 |
---|---|
Destroy | 移除 GameObject、组件或资源。 |
DestroyImmediate | 立即销毁对象 /obj/。强烈建议您改用 Destroy。 |
DontDestroyOnLoad | 在加载新的 Scene 时,请勿销毁 Object。 |
FindObjectOfType | 返回第一个类型为 type 的已加载的激活对象。 |
FindObjectsOfType | 返回所有类型为 type 的已加载的激活对象的列表。 |
Instantiate | 克隆 original 对象并返回克隆对象。 |
简单使用
this.gameObject.activeInHierarchy 判断是否处于激活状态
边栏推荐
- Server network performance tuning tool
- UE4 modify the default cache path
- UE4 keyboard keys realize door opening and closing
- Win11闪白屏无法控制如何解决?
- How to download and install xshell plus6
- vivo官网APP全机型UI适配方案
- 会议OA项目
- UE4 merge static mesh body
- Force deduction problem: DFS recursion to solve binary tree pruning
- tf.reduce_ sum()
猜你喜欢
Apache自带的ab压力测试工具如何实现
[C language interesting experiment]
ABAQUS realizes modal calculation of two degree of freedom vibration system
Zen administrator forgets password and retrieves password
How to download and install xshell plus6
MATLAB函数:filtfilt——零相位数字滤波
UE4 keyboard keys realize door opening and closing
Win11遇到问题需要重启怎么办?
UE4 build terrain with grayscale map
Application of workflow engine in vivo marketing automation | engine 03
随机推荐
Win11开机只有鼠标显示怎么办?
UE4 merge static mesh body
【机器学习】pytorch如何加载自定义数据集并进行数据集划分
How much do you know about hande digital platform system and trial?
[reprint] UE4 interview Basics (II)
UE4 create a project
The aboveboard water stickers come from people's perception of summer vacation
Vivo official website app full model UI adaptation scheme
14 multithread 1
Opencv supports H264 video coding
Classification of attention mechanism
keepalived
Parse numpy.random.get_ State() and numpy.random.set_ state()
PyGame electronic warfare simulation effect
JSON_EXTRACT返回不正确问题
会议OA项目
Win11终端管理员打不开解决方法
力扣刷题:dfs递归解决二叉树剪枝
QT warning: c4819: this file contains characters that cannot be represented in the current code page (936). Please save the file in Unicode format to prevent data loss
论文阅读【6】Autoaugment: Learning augmentation strategies from data