-
[unity]C# Parent 사용 시 경고 메세지unity 2022. 7. 18. 16:23
chr_position.transform.Parent = this.transform;
위 내용을 입력 시
경고 메세지가 나온다..
텍스트로 옮기면
Parent of RectTransform is being set with parent property. Consider using the SetParent method instead, with the worldPositionStays argument set to false. This will retain local orientation and scale rather than world orientation and scale, which can prevent common UI scaling issues.
해석하면
RectTransform의 부모를 부모 속성으로 설정하고 있습니다. 대신 worldPositionStays 인수가 false로 설정된 SetParent 메서드를 사용하는 것이 좋습니다. 이렇게 하면 월드 지향 및 스케일보다는 로컬 지향 및 스케일링이 유지되므로 일반적인 UI 스케일링 문제를 방지할 수 있습니다.
라고나오는데 경고 메세지이므로 무시해도 되지만 실행할 때마다 나타날 예정이므로 보기에 좋지 않다.
그러니 시키는 대로 해주자.
parent가 있던 자리에 SetParent를 하고
SetParent는 파라미터를 갖기 때문에 조건에 맞는 파라미터를 입력하면 된다.
이번 경우에는 transform이므로 transform파라미터를 넣어 주면 해결된다.
해결된 내용은 아래와 같다.
chr_position.transform.SetParent(this.transform);
'unity' 카테고리의 다른 글
[unity]c# - struct에 대하여 (0) 2022.08.23 [unity]c# - : Selectable 상속 (0) 2022.08.23 [Unity]C# - Random에 관하여 (0) 2022.07.15 [Unity - c#]Vector3.Magnitude 활용하여 거리 구하기 (0) 2022.07.11 [unity] - [System.Serializable]은? (0) 2022.04.17