transform.DetachChildren 은 부모와 자식간의 연결을 끊는다. using UnityEngine; using System.Collections; public class example : MonoBehaviour{ void Awake(){ transform.DetachChildren(); Destroy(gameObject); } } 위 코드는 부모만 제거하고 자식들은 유지하기 원하는 경우 사용할수 있다. Transform.Parent 는 부모를 변환한다. using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Transform cameraTransform = Camera.main.transform; void Awake() { cameraTransform.parent = transform; cameraTransform.localPosition = -Vector3.forward * 5; cameraTransform.LookAt(transform); } } 또는 transform.parent = null;로 사용할 수 있다.
댓글
댓글 쓰기