728x90
반응형
https://dreamaz.tistory.com/1118
이 자체가 변수값인듯 하다. 대신 해당 스크립트 파일이 지정된 게임 오브젝트에 대한 Rect값을 가져온다.
GetComponent.<RectTransform>().rect.width
GetComponent.<RectTransform>().rect.height
공식 문서 예시
HingeJoint hinge = gameObject.GetComponent( typeof(HingeJoint) ) as HingeJoint;
Start()함수에서 또는 Awake()함수에서 미리 할당해놓아야 함.
Script명이 타입명이 될 수도 있다. 대신 같은 컴포넌트에 지정되어 있어야 하는 것 같다.
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=wjsdldks&logNo=220379134983
728x90
반응형
'농장 > Unity·C#' 카테고리의 다른 글
Unity C# script에서 Sprite 이미지 사이즈 구하기 (0) | 2021.06.14 |
---|---|
Unity build error 해결 / android sdk does not include your target sdk of 26 (0) | 2021.06.08 |
Visual Studio (2019) 한글 깨짐 해결 Unity3d 유니티 Scripts C# (0) | 2021.02.28 |
유니티 Unity TMP 폰트 사용하기/한글폰트사용하기/원하는 폰트 사용하기 (3) | 2020.12.29 |
유니티 Collaborate에 사용자 팀원 추가하기 (0) | 2020.12.26 |