用户工具

站点工具


侧边栏

script:unityengine:classes:transform:transform.transformpoint

Transform.TransformPoint 变换点

JavaScript ⇒ TransformPoint(position: Vector3): Vector3;
C# ⇒ Vector3 TransformPoint(Vector3 position);

Description 描述

Transforms position from local space to world space.

变换位置从局部坐标到世界坐标。

Note that the returned position is affected by scale. Use Transform.TransformDirection if you are dealing with directions.

注意,返回位置受缩放影响。如果你是处理方向使用Transform.TransformDirection。

JavaScript:

// You need to assign an object to this variable in the inspector
var someObject : GameObject;
// Instantiate an object to the right of the current object
var thePosition = transform.TransformPoint(Vector3.right * 2);
Instantiate(someObject, thePosition, someObject.transform.rotation);

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    public GameObject someObject;
    public Vector3 thePosition = transform.TransformPoint(Vector3.right * 2);
    void Example() {
        Instantiate(someObject, thePosition, someObject.transform.rotation) as GameObject;
    }
}

JavaScript ⇒ TransformPoint(x: float, y: float, z: float): Vector3;
C# ⇒ Vector3 TransformPoint(float x, float y, float z);

Description 描述

Transforms the position x, y, z from local space to world space.

变换位置 x, y, z从局部坐标到世界坐标。

Note that the returned position is affected by scale. Use Transform.TransformDirection if you are dealing with directions.

注意,返回位置受缩放影响。如果你是处理方向使用Transform.TransformDirection。

JavaScript:

// You need to assign an object to this variable in the inspector
var someObject : GameObject;
// Instantiate an object to the right of the current object
thePosition = transform.TransformPoint(2, 0, 0);
Instantiate(someObject, thePosition, someObject.transform.rotation);

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    public GameObject someObject;
    void Example() {
        thePosition = transform.TransformPoint(2, 0, 0);
        Instantiate(someObject, thePosition, someObject.transform.rotation) as GameObject;
    }
}

Transform

script/unityengine/classes/transform/transform.transformpoint.txt · 最后更改: 2016/08/02 05:37 (外部编辑)