Hololens2代码创建3D物体

创建一个空物体,然后将下面代码挂在上就行了:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Creratsphere : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);//type还有好几种
        sphere.transform.position = new Vector3(-0.5f, 0.5f, 1);
        sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
        sphere.name = "one";
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_44345862/article/details/123308410
今日推荐