Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Transform 变换
# [Transform](Transform.html) 变换 Inherits from [Component](../Component/Component.html),IEnumerable Position, rotation and scale of an object. 物体的位置、旋转和缩放。 Every object in a scene has a Transform. It's used to store and manipulate the position, rotation and scale of the object. Every Transform can have a parent, which allows you to apply position, rotation and scale hierarchically. This is the hierarchy seen in the Hierarchy pane. They also support enumerators so you can loop through children using: 场景中的每一个物体都有一个 Transform。用于储存并操控物体的位置、旋转和缩放。每一个 Transform 可以有一个父级,允许你分层次应用位置、旋转和缩放。可以在 Hierarchy 面板查看层次关系。他们也支持计数器(enumerator),因此你可以使用循环遍历子物体。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public void Awake() { foreach (Transform child in transform) { child.position += Vector3.up * 10.0F; } } } ``` ``` // Moves all transform children 10 units upwards! //向上移动所有变换的子物体10个单位 for (var child : Transform in transform) { child.position += Vector3.up * 10.0; } ``` 参见:[Physics](../Physics/Physics.html) 类. ### Variables**变量** * [position](Transform.position.html) The position of the transform in world space. 在世界空间坐标 transform 的位置。 * [localPosition](Transform.localPosition.html) Position of the transform relative to the parent transform. 相对于父级的变换的位置。 * [eulerAngles](Transform.eulerAngles.html) The rotation as Euler angles in degrees. 旋转作为欧拉角度。 * [localEulerAngles](Transform.localEulerAngles.html) The rotation as Euler angles in degrees relative to the parent transform's rotation. 旋转作为欧拉角度,相对于父级的变换旋转角度。 * [right](Transform.right.html) The red axis of the transform in world space. 在世界空间坐标变换的红色轴。也就是 x 轴。 * [up](Transform.up.html) The green axis of the transform in world space. 在世界空间坐标变换的绿色轴。也就是 y 轴。 * [forward](Transform.forward.html) The blue axis of the transform in world space. 在世界空间坐标变换的蓝色轴。也就是 z 轴。 * [rotation](Transform.rotation.html) The rotation of the transform in world space stored as a Quaternion. 在世界空间坐标物体变换的旋转角度作为 [Quaternion](../Quaternion/Quaternion.html) 储存。 * [localRotation](Transform.localRotation.html) The rotation of the transform relative to the parent transform's rotation. 物体变换的旋转角度相对于父级的物体变换的旋转角度。 * [localScale](Transform.localScale.html) The scale of the transform relative to the parent. 相对于父级物体变换的缩放。 * [parent](Transform.parent.html) The parent of the transform. 物体变换的父级。 * [worldToLocalMatrix](Transform.worldToLocalMatrix.html) Matrix that transforms a point from world space into local space (Read Only). 矩阵变换的点从世界坐标转为自身坐标(只读)。 * [localToWorldMatrix](Transform.localToWorldMatrix.html) Matrix that transforms a point from local space into world space (Read Only). 矩阵变换的点从自身坐标转为世界坐标(只读)。 * [root](Transform.root.html) Returns the topmost transform in the hierarchy. 返回层次最高的变换。 * [childCount](Transform.childCount.html) The number of children the Transform has. 变换的子物体数量。 * [lossyScale](Transform.lossyScale.html) The global scale of the object (Read Only). 物体的全局缩放(只读)。 ### Functions**函数** * [Translate](Transform.Translate.html) Moves the transform in the direction and distance of translation. 移动 transform 在 translation 的方向和距离。 * [Rotate](Transform.Rotate.html) Applies a rotation of eulerAngles.z degrees around the z axis, eulerAngles.x degrees around the x axis, and eulerAngles.y degrees around the y axis (in that order). 应用一个欧拉角的旋转角度,eulerAngles.z 度围绕 z 轴,eulerAngles.x 度围绕 x 轴,eulerAngles.y 度围绕 y 轴(这样的顺序)。 * [RotateAround](Transform.RotateAround.html) Rotates the transform about axis passing through point in world coordinates by angle degrees. 按照 angle 度通过在世界坐标的 point 轴旋转物体。 * [LookAt](Transform.LookAt.html) Rotates the transform so the forward vector points at /target/'s current position. 旋转物体,这样向前向量指向 *target* 的当前位置。 * [TransformDirection](Transform.TransformDirection.html) Transforms direction from local space to world space. 从自身坐标到世界坐标变换方向。 * [InverseTransformDirection](Transform.InverseTransformDirection.html) Transforms a direction from world space to local space. The opposite of Transform.TransformDirection. 变换方向从世界坐标到自身坐标。和 [Transform.TransformDirection](Transform.TransformDirection.html) 相反。 * [TransformPoint](Transform.TransformPoint.html) Transforms position from local space to world space. 变换位置从自身坐标到世界坐标。 * [InverseTransformPoint](Transform.InverseTransformPoint.html) Transforms position from world space to local space. The opposite of Transform.TransformPoint. 变换位置从世界坐标到自身坐标。和 [Transform.TransformPoint](Transform.TransformPoint.html) 相反。 * [DetachChildren](Transform.DetachChildren.html) Unparents all children. 所有子物体解除父子关系。 * [Find](Transform.Find.html) Finds a child by name and returns it. 通过名字查找子物体并返回它。 * [IsChildOf](Transform.IsChildOf.html) Is this transform a child of parent? 这个变换是父级的子物体? ## Inherited members**继承成员** ### Inherited Variables**继承变量** * [transform](../Component/Component.transform.html) The [Transform](Transform.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Transform](Transform.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [rigidbody](../Component/Component.rigidbody.html) The [Rigidbody](../Rigidbod/Rigidbody.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Rigidbody](../Rigidbod/Rigidbody.html)[](Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [camera](../Component/Component.camera.html) The [Camera](../Camera/Camera.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Camera](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [light](../Component/Component.light.html) The [Light](../Light/Light.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Light](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [animation](../Component/Component.animation.html) The [Animation](../Animation/Animation.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Animation](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [constantForce](../Component/Component.constantForce.html) The [ConstantForce](../ConstantForce/ConstantForce.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [ConstantForce](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [renderer](../Component/Component.renderer.html) The [Renderer](../Renderer/Renderer.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Renderer](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [audio](../Component/Component.audio.html) The [AudioSource](../AudioSource/AudioSource.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [AudioSource](../AudioSource/AudioSource.html)[](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [guiText](../Component/Component.guiText.html) The [GUIText](../GUIText/GUIText.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [GUIText](../GUIText/GUIText.html)[](../AudioSource/AudioSource.html)[](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [networkView](../Component/Component.networkView.html) The [NetworkView](../NetworkView/NetworkView.html) attached to this [GameObject](../GameObject/GameObject.html) (Read Only). (null if there is none attached) [NetworkView](../NetworkView/NetworkView.html)[](../GUIText/GUIText.html)[](../AudioSource/AudioSource.html)[](../Renderer/Renderer.html)[](../ConstantForce/ConstantForce.html)[](../Animation/Animation.html)[](../Light/Light.html)[](../Camera/Camera.html)[](../Rigidbod/Rigidbody.html)[](Transform.html)附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(只读)(如无附加则为空)。 * [guiTexture](../Component/Component.guiTexture.html) The [GUITexture](../GUITexture/GUITexture.html) attached to this [GameObject](../GameObject/GameObject.html) (Read Only). (null if there is none attached) [GUITexture](../GUITexture/GUITexture.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(只读)(如无附加则为空)。 * [collider](../Component/Component.collider.html) The [Collider](../Collider/Collider.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [Collider](../Collider/Collider.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [hingeJoint](../Component/Component.hingeJoint.html) The [HingeJoint](../HingeJoint/HingeJoint.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [HingeJoint](../HingeJoint/HingeJoint.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [particleEmitter](../Component/Component.particleEmitter.html) The [ParticleEmitter](../ParticleEmitter/ParticleEmitter.html) attached to this [GameObject](../GameObject/GameObject.html) (null if there is none attached). [ParticleEmitter](../ParticleEmitter/ParticleEmitter.html) 附加到 [GameObject](../GameObject/GameObject.html)(游戏物体)(如无附加则为空)。 * [gameObject](../Component/Component.gameObject.html) The game object this component is attached to. A component is always attached to a game object. 组件附加的游戏物体。一个组件总是被附加到一个游戏物体。 * [tag](../Component/Component.tag.html) The tag of this game object. 游戏物体的标签。 * [name](../Object/Object.name.html) The name of the object. //物体的名字 * [hideFlags](../Object/Object.hideFlags.html) Should the object be hidden, saved with the scene or modifiable by the user? 物体是否被隐藏、保存在场景中或被用户修改? ### Inherited Functions**继承函数** * [GetComponent](../Component/Component.GetComponent.html) Returns the component of Type type if the game object has one attached, null if it doesn't. 如果游戏物体有一个附加,则返回 Type 类型的组件,如果没有则为 null。 * [GetComponent.<T>](../Component/Component.GetComponent.ltTgt.html) * [GetComponent](../Component/Component.GetComponent.html) Returns the component with name type if the game object has one attached, null if it doesn't. 如果游戏物体有一个附加,则返回名字类型组件,如果没有则为 null。 * [GetComponentInChildren](../Component/Component.GetComponentInChildren.html) Returns the component of Type type in the [GameObject](../GameObject/GameObject.html) or any of its children using depth first search. 返回 Type 类型组件,在 [GameObject](../GameObject/GameObject.html) 或它的任何子物体使用深度优先搜索,仅返回激活的组件。 * [GetComponentInChildren.<T>](../Component/Component.GetComponentInChildren.ltTgt.html) * [GetComponentsInChildren](../Component/Component.GetComponentsInChildren.html) Returns all components of Type type in the [GameObject](../GameObject/GameObject.html) or any of its children. 在 [GameObject](../GameObject/GameObject.html) 或任何它的子物体,返回全部 Type 类型组件 * [GetComponentsInChildren.<T> ](../Component/Component.GetComponentsInChildren.ltTgt.html) * [GetComponents](../Component/Component.GetComponents.html) Returns all components of Type type in the [GameObject](../GameObject/GameObject.html). 在游戏物体返回全部 Type 类型组件。 * [GetComponents.<T> ](../Component/Component.GetComponents.ltTgt.html) * [CompareTag](../Component/Component.CompareTag.html) Is this game object tagged tag? 游戏物体有被标记标签么? * [SendMessageUpwards](../Component/Component.SendMessageUpwards.html) Calls the method named methodName on every [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) in this game object and on every ancestor of the behaviour 在游戏物体每一个 [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) 和每一个 behaviour 的祖先上调用名为 methodName 的方法。 * [SendMessage](../Component/Component.SendMessage.html) Calls the method named methodName on every [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) in this game object. 在游戏物体每一个 [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) 上调用名为 methodName 的方法。 * [BroadcastMessage](../Component/Component.BroadcastMessage.html) Calls the method named methodName on every [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) in this game object or any of its children. 在游戏物体每一个 [MonoBehaviour](../MonoBehaviour/MonoBehaviour.html) 和它的全部子物体上调用名为 methodName 的方法。 * [GetInstanceID](../Object/Object.GetInstanceID.html) Returns the instance id of the object. 返回物体的实例 ID * [ToString](../Object/Object.ToString.html) Returns the name of the game object. 返回游戏物体的名称。 ### Inherited Class Functions**继承类函数** * [operator bool](../Object/Object.operator_bool.html) Does the object exist? 物体是否存在? * [Instantiate](../Object/Object.Instantiate.html) Clones the object original and returns the clone. 克隆原始物体,并返回克隆的物体 * [Instantiate.<T>](../Object/Object.Instantiate.ltTgt.html) * [Destroy](../Object/Object.Destroy.html) Removes a gameobject, component or asset. 删除一个游戏物体、组件或资源 * [DestroyImmediate](../Object/Object.DestroyImmediate.html) Destroys the object obj immediately. It is strongly recommended to use Destroy instead. 立即销毁物体 obj,强烈建议使用 Destroy 代替。 * [FindObjectsOfType](../Object/Object.FindObjectsOfType.html) Returns a list of all active loaded objects of Type type. 返回 Type 类型的所有激活的加载的物体列表 * [FindObjectOfType](../Object/Object.FindObjectOfType.html) Returns the first active loaded object of Type type. 返回 Type 类型第一个激活的加载的物体。 * [operator ==](../Object/Object.operator_eq.html) Compares if two objects refer to the same 比较如果两个物体相同 * [operator !=](../Object/Object.operator_ne.html) Compares if two objects refer to a different object 比较如果两个物体不同 * [DontDestroyOnLoad](../Object/Object.DontDestroyOnLoad.html) Makes the object target not be destroyed automatically when loading a new scene. 加载新场景的时候使目标物体不被自动销毁。
da
2022年5月23日 14:47
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码