본문 바로가기
유니티 공부/Unity

Unity - LineRenderer(프로퍼티와 메서드 알아보기)

by 코딩하는 돼징 2024. 1. 7.
반응형

LineRenderer

LineRenderer를 사용해서 선 또는 다양한 모양의 그림을 렌더링할 수 있다.

 

프로퍼티

01 PositionCount

선의 점의 개수

public int positionCount { get; set; }

positionCount가 0인경우 없음

없음

positionCount가 1인경우 점

positionCount가 2인경우 선

●────●

02 startWidth

선이 그려지기 시작하는 지점에서의 너비를 조절할 때 사용

public float startWidth { get; set; }

03 endWidth

선의 끝 부분의 너비를 조절할때 사용 그러므로 값이 크면 끝 부분이 두꺼워지고 작으면 얇아진다.

public float endWidth { get; set; }

 

startWidth가 크고 endWidth가 작은 경우

startWidth가 작고 endWidth가 큰 경우


메서드

01 SetPosition

LineRenderer의 특정 인덱스에 해당하는 점의 위치를 설정하는데 사용된다.

public void SetPosition(int index, Vector3 position);

매개 변수

index : 설정하려는 점의 인덱스

position : 해당 인덱스에 설정할 새로운 위치이다.


02 SetWidth

선의 너비 변경

public void SetWidth(float start, float end);

매개 변수

start : 시작 너비

end : 끝 너비

 

코드 예시

lineRenderer.SetWidth(0.1f, 0.3f);

03 SetColors

선의 색상 변경

public void SetColors(Color start, Color end);

매개 변수

start : 시작 색상

end : 끝 색상

 

코드 예시

lineRenderer.SetColors(Color.green, Color.yellow);

 

 

 

 

반응형

댓글