ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## Transform类提供了查找变换组件、改变位置、角度、大小功能 ### Variables变量 * **position** 在世界空间坐标transform的位置。 * **localPosition** 相对于父级的变换的位置。 * **eulerAngles** 旋转作为欧拉角度。 * **localEulerAngles** 旋转作为欧拉角度,相对于父级的变换旋转角度。 * **right** 在世界空间坐标变换的红色轴。也就是x轴。 * **up** 在世界空间坐标变换的绿色轴。也就是y轴。 * **forward** 在世界空间坐标变换的蓝色轴。也就是z轴。 * **rotation** 在世界空间坐标物体变换的旋转角度作为Quaternion储存。 * **localRotation** 物体变换的旋转角度相对于父级的物体变换的旋转角度。 * **localScale** 相对于父级物体变换的缩放。 * **parent** 物体变换的父级。 * **worldToLocalMatrix** 矩阵变换的点从世界坐标转为自身坐标(只读)。 * **localToWorldMatrix** 矩阵变换的点从自身坐标转为世界坐标(只读)。 * **root** 返回层次最高的变换。 * **childCount** 变换的子物体数量。 * **lossyScale** 物体的全局缩放(只读)。 ## **Functions函数** * Translate 移动transform在translation的方向和距离。 * Rotate 应用一个欧拉角的旋转角度,eulerAngles.z度围绕z轴,eulerAngles.x度围绕x轴,eulerAngles.y度围绕y轴(这样的顺序)。 * RotateAround 按照angle度通过在世界坐标的point轴旋转物体。 * LookAt 旋转物体,这样向前向量指向*target*的当前位置。 * TransformDirection 从自身坐标到世界坐标变换方向。 * InverseTransformDirection 变换方向从世界坐标到自身坐标。和[Transform.TransformDirection](Transform.TransformDirection.html)相反。 * TransformPoint 变换位置从自身坐标到世界坐标。 * InverseTransformPoint 变换位置从世界坐标到自身坐标。和[Transform.TransformPoint](Transform.TransformPoint.html)相反。 * DetachChildren 所有子物体解除父子关系。 * Find 通过名字查找子物体并返回它。 * IsChildOf 这个变换是父级的子物体? Transform 变换 $(function() { $("ul.tabs").tabs("> .panes", {initialIndex: 1}); }); ## 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.](../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.](../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.](../Component/Component.GetComponentsInChildren.ltTgt.html) * [GetComponents](../Component/Component.GetComponents.html) Returns all components of Type type in the [GameObject](../GameObject/GameObject.html). 在游戏物体返回全部Type类型组件。 * [GetComponents.](../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.](../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. 加载新场景的时候使目标物体不被自动销毁。