Unity 场景中所有实体的基类。
Note: Many variables in the GameObject class have been removed. To access GameObject.renderer in csharp, for example, use GetComponent<Renderer>() instead.
Additional resources: Component.
activeInHierarchy | 定义 GameObject 在 Scene 中是否处于活动状态。 |
activeSelf | 此 GameObject 的本地活动状态。(只读) |
isStatic | 获取并设置 GameObject 的 StaticEditorFlags。 |
layer | The layer the GameObject is in. |
scene | 该 GameObject 所属的场景。 |
sceneCullingMask | Unity 用于确定在哪个场景中渲染该 GameObject 的场景剔除遮罩。 |
tag | The tag of this GameObject. |
transform | 附加到此 GameObject 的 Transform。 |
GameObject | Creates a new GameObject, named name. |
AddComponent | Adds a component class of type componentType to the GameObject. C# Users can use a generic version. |
BroadcastMessage | Calls the method named methodName on every MonoBehaviour in this GameObject or any of its children. |
CompareTag | Is this GameObject tagged with tag ? |
GetComponent | Gets a reference to a component of type T on the specified GameObject. |
GetComponentInChildren | Gets a reference to a component of type T on the specified GameObject, or any child of the GameObject. |
GetComponentInParent | Gets a reference to a component of type T on the specified GameObject, or any parent of the GameObject. |
GetComponents | Gets references to all components of type T on the specified GameObject. |
GetComponentsInChildren | Gets references to all components of type T on the specified GameObject, and any child of the GameObject. |
GetComponentsInParent | Gets references to all components of type T on the specified GameObject, and any parent of the GameObject. |
SendMessage | Calls the method named methodName on every MonoBehaviour in this GameObject. |
SendMessageUpwards | Calls the method named methodName on every MonoBehaviour in this GameObject and on every ancestor of the behaviour. |
SetActive | 根据给定的值 true 或 /false/,激活/停用 GameObject。 |
TryGetComponent | 获取指定类型的组件(如果存在)。 |
CreatePrimitive | Creates a GameObject with a primitive mesh renderer and appropriate collider. |
Find | 按 name 查找 GameObject,然后返回它。 |
FindGameObjectsWithTag | 返回标签为 tag 的活动 GameObjects 的数组。如果未找到任何 GameObject,则返回空数组。 |
FindWithTag | 返回一个标记为 tag 的活动 GameObject。如果未找到 GameObject,则返回 null。 |
GetScene | Returns the Scene of a GameObject given by instance ID. |
InstantiateGameObjects | Instantiate a GameObject multiple times by instance ID and populate NativeArrays containing the new GameObjects by instance ID and their corresponding Transforms by instance ID. |
SetGameObjectsActive | Activates/Deactivates the GameObjects by instance ID, depending on the given true or false value. |
GetInstanceID | Gets the instance ID of the object. |
ToString | 返回对象的名称。 |
Destroy | 移除 GameObject、组件或资源。 |
DestroyImmediate | 立即销毁对象 /obj/。强烈建议您改用 Destroy。 |
DontDestroyOnLoad | 在加载新的 Scene 时,请勿销毁 Object。 |
FindAnyObjectByType | Retrieves any active loaded object of Type type. |
FindFirstObjectByType | Retrieves the first active loaded object of Type type. |
FindObjectsByType | Retrieves a list of all loaded objects of Type type. |
Instantiate | 克隆 original 对象并返回克隆对象。 |
bool | 该对象是否存在? |
operator != | 比较两个对象是否引用不同的对象。 |
operator == | 比较两个对象引用,判断它们是否引用同一个对象。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.