如何使用c#在Unity场景中导入3D模型?

时间:2016-10-06 20:55:06

标签: unity3d unity5

如何使用c#导入3D模型离子统一场景?

1 个答案:

答案 0 :(得分:3)

你无法进口"导入"您的模型进入场景,但您将能够实例化包含3D模型的Unity预制件。预制件充当模板,您可以在该模板中创建场景中的新对象实例,包含您想要的每个组件(例如,MeshRenderer与您的3D模型)

看一下文档:

https://docs.unity3d.com/Manual/InstantiatingPrefabs.html

// Unityscript
// Drag & Drop your prefab in this field inside the inspector
var brick : Transform;

function Start () {
    for (var y = 0; y < 5; y++) {
        for (var x = 0; x < 5; x++) {
            Instantiate(brick, Vector3 (x, y, 0), Quaternion.identity);
        }
    }
}
// C#
// Drag & Drop your prefab in this field inside the inspector
public Transform brick;

void Start() {
    for (int y = 0; y < 5; y++) {
        for (int x = 0; x < 5; x++) {
            Instantiate(brick, new Vector3(x, y, 0), Quaternion.identity);
        }
    }
}