unity实例化物体到父物体之下

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

public class Bag : MonoBehaviour {

    public GameObject weizhi;//父物体
    public GameObject shilihua;//需要实例化的prefab
	void Update () {
		if(Input.GetKeyDown(KeyCode.Q))
        {
            GameObject a = Instantiate(shilihua, transform.position, Quaternion.identity);//实例化物体
            a.transform.parent = weizhi.transform;//把实例化的物体放到父物体weizhi之下
        }
	}
}

你可能感兴趣的:(unity,unity)