Pv_log

Programming Simple Functionality: Next Steps) Lesson 6.1 - Project Optimization 본문

Unity Learn 번역/Pathway: Junior Programmer

Programming Simple Functionality: Next Steps) Lesson 6.1 - Project Optimization

Priv 2021. 7. 24. 18:16

출처

 

Lesson 6.1 - Project Optimization - Unity Learn

Overview: In this lesson, you will learn about a variety of different techniques to optimize your projects and make them more performant. You may not notice a huge difference in these small prototype projects, but when you’re exporting a larger project,

learn.unity.com


 

 

1. 변수 속성

여태까지 우리는 "public" 또는 "private" 변수만 사용했습니다. 하지만 유니티 상에는 여러분들이 익숙해지셔야 하는 정말 많은 변수 속성들이 존재합니다.

 


(영상: 링크 참조)

 

Lesson 6.1 - Project Optimization - Unity Learn

Overview: In this lesson, you will learn about a variety of different techniques to optimize your projects and make them more performant. You may not notice a huge difference in these small prototype projects, but when you’re exporting a larger project,

learn.unity.com


 

1. 여러분의 Prototype 1 프로젝트를 실행하신 뒤, PlayerController.cs 스크립트 파일을 열어주세요.

2. "private" 부분을 [SerializeField]로 바꾸시고, inspector 창에서 값을 수정해주세요.

3. FollowPlayer.cs 파일에서 [SerializeField] 속성을 Vector3 offset 변수에 추가해주세요.

4. "readonly", "const", 또는 "static" 속성들을 적용해보시고, inspector 창에서 변수들이 사라지는 효과가 나타나는지 확인해주세요.

 

 


 

2. 유니티 이벤트 함수

여태까지 우리는 기본 제공되는 Update()와 Start() 이벤트 함수만 사용했으나, 다른 상황에서 사용할 수 있는 다른 이벤트 함수들도 있습니다.

 


(영상: 링크 참조)

 

Lesson 6.1 - Project Optimization - Unity Learn

Overview: In this lesson, you will learn about a variety of different techniques to optimize your projects and make them more performant. You may not notice a huge difference in these small prototype projects, but when you’re exporting a larger project,

learn.unity.com


 

1. 메인 카메라(main Camera)를 복제(Duplicate) 하시고, 이름을 "Secondary Camera"로 바꾸신 뒤, 메인 카메라는 비활성화해주세요.

2. 보조 카메라(Secondary Camera)의 위치를 차량의 1인칭 시점(운전석 쪽)으로 조정하신 다음, offset 변수 값을 위치에 맞게 수정해주세요.

3. 프로젝트를 실행하셔서 게임이 얼마나 불안정한 지 확인해주세요.

4. PlayerController.cs 파일을 여시고, "Update"를 "FixedUpdate"로 바꿔주신 뒤, FollowPlayer.cs 파일을 열어 "Update"를 "LateUpdate"로 바꿔주세요. 이제 다시 테스트를 진행해보세요.

5. 두 스크립트 파일 모두 Start() 함수를 삭제하시고, 메인 카메라를 다시 활성화시켜주세요.

 

 


 

3. 오브젝트 풀링

지금까지의 튜토리얼 코스를 거치시면서, 여러분은 게임이 실행되는 동안 오브젝트들을 생성/파괴하는 굉장히 많은 프로토타입들을 만들었습니다. 하지만 실제로는 오브젝트 풀링(Object Pooling)이라는 더 성능이 좋고 효율적인 방법이 있습니다.

 


(영상: 링크 참조)

 

Lesson 6.1 - Project Optimization - Unity Learn

Overview: In this lesson, you will learn about a variety of different techniques to optimize your projects and make them more performant. You may not notice a huge difference in these small prototype projects, but when you’re exporting a larger project,

learn.unity.com


 

1. Prototype 2 프로젝트를 여시고 백업을 먼저 진행해주세요.

        1) DetectCollisions, PlayerController, DestroyOutOfBounds 스크립트 파일은 삭제해주세요.

2. Object Pooling 유니티 패키지를 다운로드하신 뒤, 여러분의 씬에 임포트해주세요.

3. PlayerController 스크립트를 플레이어에 다시 추가해주세요. DestroyOutOfBounds 스크립트는 동물과 음식 프리팹에, DetectCollisions 스크립트는 동물 프리팹에 추가해주세요. (음식 프리팹이 아닙니다)

4. ObjectPooler 스크립트를 Spawn Manager에 부착하시고, 음식 발사체(food projectile)를 "Objects To Pool" 변수 안으로 드래그해주세요. "Amount To Pool" 값은 20으로 설정해주세요.

5. 프로젝트를 실행하셔서 발사체들이 어떻게 활성화, 비활성화되는지 확인해주세요.

 


 

4. 내용 복습

새로 배운 개념과 기술들

- 최적화

- 직렬화 필드(Serialized Fields)

- readonly / const / static / protected

- 이벤트 함수

- FixedUpdate(), Update(), LateUpdate() 비교

- Awake(), Start() 비교

- 오브젝트 풀링(Object Pooling)

 


 


수고하셨습니다!


Comments