1.代码中定义public GameObject mySphere;
2.在Unity3D中将预制体拖至代码对应的mySphere的位置;
3.指定位置和旋转参数进行实例化;
4.具体实现代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LeapGesture : MonoBehaviour
{
public GameObject mySphere;
Vector3 a = new Vector3(0, 0, 0); //实例化预制体的position,可自定义
Quaternion b = new Quaternion(0, 0, 0, 0);//实例化预制体的rotation,可自定义
// Use this for initialization
void Start ()
{
GameObject Sphere = GameObject.Instantiate(mySphere, a, b) as GameObject;
}
// Update is called once per frame
void Update ()
{
}
}