Unity在一個父物體下例項化子物體
阿新 • • 發佈:2019-01-30
public GameObject hj5;
public GameObject hj10;
private GameObject GetHand;
private GameObject szhj5;
public GameObject hj10;
private GameObject GetHand;
private GameObject szhj5;
private GameObject szhj10;
public void ShowSZHJ(bool sz5)
{
GetHand = GameObject.Find("ARCamera");
if(sz5)
{
szhj5 = Instantiate(hj5);
szhj5.transform.parent = GetHand.transform;
szhj5.transform.localPosition = new Vector3(0, 0, 8);
}
if(!sz5)
{
szhj10 = Instantiate(hj10);
szhj10.transform.parent = GetHand.transform;
szhj10.transform.localPosition = new Vector3(0, 0, 3 );
}
}