blob: 6c1757d3b2ff3c914e809a49f400c15d00e9aaed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
using UnityEngine;
public class CopyChildren : MonoBehaviour
{
public GameObject target;
public void DoUpdate()
{
for (int num = base.transform.childCount - 1; num >= 0; num--)
{
Object.Destroy(base.transform.GetChild(num).gameObject);
}
for (int i = 0; i < target.transform.childCount; i++)
{
Transform child = target.transform.GetChild(i);
Object.Instantiate(child.gameObject, base.transform.TransformPoint(child.localPosition), Quaternion.identity, base.transform).transform.localScale = child.localScale;
}
}
private void Update()
{
DoUpdate();
}
}
|