블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2731)
Unity3D (814)
Script (91)
Extensions (14)
Effect (3)
NGUI (77)
UGUI (8)
Physics (2)
Shader (36)
Math (1)
Design Pattern (2)
Xml (1)
Tips (200)
Link (22)
World (1)
AssetBundle (25)
Mecanim (2)
Plugins (68)
Trouble Shooting (68)
Encrypt (7)
LightMap (4)
Shadow (4)
Editor (8)
Crash Report (3)
Utility (9)
UnityVS (2)
Facebook SDK (2)
iTween (3)
Font (10)
Ad (14)
Photon (2)
IAP (1)
Google (8)
Android (45)
iOS (41)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (57)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (51)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
03-29 07:22

Today we’ll be talking about the Preload Audio Data option in Unity’s Audio Import Settings and why understanding this small but critical checkbox is important for your game.

So many options… How does Unity choose which audio is loaded to a scene?

Editor’s Note: Compression Formats, Load Type and the Preload Audio Data/Load in Background settings go hand in hand. We recommend reading our blog posts on all three in the following order for a complete overview:

Blog 1: Compression Formats

Blog 2: Load Types

Blog 3: Preload Audio (this post)

Blog 4: Load in Background (coming soon)

This blog post has been made as a supplement to our video tutorial on this same topic.

 
 

Introduction

After figuring out how Unity compresses your audio with the different compression formats, and primes your audio for playing with the different Load Type settings, the next question to answer is: What does the Preload Audio Data option do?

The Unity Documentation provides important information on this subject, but it doesn’t explain exactly when and how audio files are selected to be loaded in an active scene.

 

Preload Audio Data

Here’s Unity’s definition of Preload Audio Data from their manual:

If enabled, the audio clip will be pre-loaded when the scene is loaded. This is on by default to reflect standard Unity behavior where all AudioClips have finished loading when the scene starts playing.

This information is pretty clear already. If you choose this option, you want the audio priming process with the respective Load Types to take place before the scene is activated and becomes playable.

This will result in mission-critical audio files being ready to be played at all times at the expense of making the scene load time a little bit longer.

So far, so good. But there is one question left unanswered:

How does Unity decide which Audio is going to be loaded in which Scene?

 

References

Let’s imagine this situation: you’re developing a large game that has 15 hours of playtime and around 30 scenes. You have something like 1000 SFX and 2000 dialogue files. You would not want every single audio asset marked with Preload Audio Data to be loaded in every scene, would you?

Unfortunately, the documentation doesn’t address this in detail, making the process of deciding whether or not to Preload your audio assets very difficult and full of uncertainty.

Luckily, Unity is a sophisticated engine. After many tests, we concluded that Unity will scan everything in our scene and load all audio files flagged with Preload Audio Data that are referenced in the scene in any way.

Let’s take a step back here because now we have another question to answer:

What is a reference?

Let’s open up Unity and find out.

 

Testing Testing

We’ve imported 10 sound effects, 10 dialogue, and 2 music files into a Unity project. They’re all marked with Preload Audio Data to simulate a larger game. There are also two different scenes to simulate loading and unloading audio in a normal scene transition.

Let’s start with the first scene. We have a GameObject here with an AudioSource that has an AudioClip.

We hope this looks familiar.

This is already a so-called reference and this audio file will be loaded when the scene is loaded. I turned off Play on Awake for this to make sure that the audio is not played. Let’s build this and confirm with the profiler.

Our AudioClip is loaded and ready for action.

Perfect. Even though the AudioClip is not played at all, it is loaded because it has been referenced.

Note that this music file, which has “Streaming” selected as its Load Type, is only 311 bytes in the memory, unlike the 200-ish kilobytes from the last tutorial. That will change if we actually play the sound file.

Let’s now add two scripts we’ve prepared for another GameObject.

These two scripts do nothing but define a public AudioClip variable and a public AudioClip array. Let’s add an AudioClip to that and profile this.

Voilá. We have the second audio clip loaded.

For the sake of this demonstration, I will add another two AudioClips to the array and check the profiler once again.

As you might have guessed, without Preload Audio Data selected, Unity will not load the AudioClip until it is called, even though it is referenced in the scene. We’ll be going more in-depth on this in our next tutorial.

So, a reference is as simple as that. As long as you have a reference of any kind to an AudioClip, be it directly in the AudioSource, as a variable in a script, or even in a ScriptableObject, it will be loaded when the scene is loaded if you have checked Preload Audio Data.

 

Scene Transitions

Now: what happens if we change to another scene? Will the audio data we loaded in this scene be automatically unloaded?

Let’s go to the second scene. We’ll keep one AudioClip constant across both scenes but change the rest. Now we can build and profile this once again.

And then we’ll transition to the next scene.

We see here that all but one of our AudioClips from the first scene are already unloaded from the memory, leaving only the one that is used again in the second scene.

The unloading process took place as the scene was changed; this is a normal routine that Unity does in the background called GarbageCollection.

 

Final Words

Let’s summarize what we’ve learned:

  • Selecting Preload Audio Data means the scene will not start until all sounds with this setting are loaded into memory. This is most important for audio content that is needed right away in the scene, such as footsteps, UI, or anything synced to visual content that plays immediately upon the scene’s activation.
  • Unity determines which files to load in a scene by searching for references. If an audio file is referenced unnecessarily, for example, an AudioClip in an AudioSource that you ended up not using but didn’t delete from the scene, it will be loaded as well, even if the entire GameObject is deactivated. In that respect, it’s important to keep your scenes clear of unused references.
 

That’s it! We hope this tutorial has helped you to understand the Preload Audio Data option in Unity’s Import Settings and why this information is important for your game.

If you want to learn more about how audio functions in Unity, be sure to check out our other tutorials (linked below). If you have a question, leave it in the comments or contact us directly through our website:

 

 

[출처] https://medium.com/@made-indrayana/preload-audio-data-how-unity-decides-which-audio-assets-to-load-to-a-scene-a440a654e7e2

 

Preload Audio Data & How Unity Decides Which Audio Assets to Load to a Scene

Today we’ll be talking about the Preload Audio Data option in Unity’s Audio Import Settings and why it’s important for your game.

medium.com

 

반응형
Posted by blueasa
, |

Force To Mono

Unity 측에서 음원을 모노로 변환하여 용량을 줄여주는 설정
모바일이라고 ON하고 싶다.

인스펙터상이라면 이 설정을 ON으로 하면 Normalize옵션 설정을 선택할 수 있게 된다.
이것은 음량을 평균화해 주는 기능입니다만, 음소재측에서 음량 조정되고 있는 케이스도 있어, 「작은 소리로 하고 싶었는데 어쨌든 음량 오르지 않았어?」같은 것이 됩니다
.

그래서, 모노럴 설정은 ON으로 하면서, 노멀라이즈는 OFF로 해 두고 싶은 기분이 되네요.

 

가져오기 설정을 자동화하고 싶습니다.

수동으로 하는 것은 힘들어지므로,
AudioImporter 를 스크립트로부터 괴롭히고 어떻게든 하고 싶다.

그러나 AudioImpoter에는 forceToMono매개 변수가 있지만
Normalize관련 매개 변수가 노출되지 않았습니다.

 

결과

아래와 같이 해 주면, 해당의 파라미터를 취득해 재기입할 수 있었습니다.

 

var audioImporter = assetImporter as AudioImporter;
var serializedObject = new UnityEditor.SerializedObject(audioImporter);
var normalize = serializedObject.FindProperty("m_Normalize");
normalize.boolValue = false;

serializedObject.ApplyModifiedProperties();

audioImporter.SaveAndReimport();
UnityEditor.EditorUtility.SetDirty(audioImporter);
UnityEditor.AssetDatabase.Refresh();

 

https://answers.unity.com/questions/1016473/how-to-disable-normalize-in-audioimporter.html
https://docs.unity3d.com/ScriptReference/EditorUtility.SetDirty.html

 

 

[출처] https://qiita.com/mrhdms/items/85bd2e524a9c76e1273c

 

AudioImporter で Force to mono は有効にしつつ、Normalize だけ無効にする - Qiita

Force to mono Unity側で音源をモノラルに変換して、容量を削減してくれる設定 モバイルだとONにしたい。 インスペクタ上だと、この設定をONにすると、 Normalize というオプション設定が選択でき

qiita.com

 

[참조] https://www.jianshu.com/p/b389936ff1ad

 

Unity插件-音频参数优化

需求:需要对音频做出修改,压缩音频质量,检测是否设置为Mono与Normalize, 超过10秒LoadType设为Streaming. 思路:遍历所有的音频文件,拿到所有的...

www.jianshu.com

 

반응형
Posted by blueasa
, |

[링크] https://overworks.github.io/unity/2018/09/22/unity-audio-clip-import-guide.html

 

유니티 오디오 클립 임포트 설정 가이드

옵션 설명

overworks.github.io

 

반응형
Posted by blueasa
, |

모바일 게임을 제작하다 보면, PC-에디터에서는 잘 나오던 게임 사운드가 핸드폰에서는 밀려 나오는 경우를 종종 겪을 수 있다.

이런 상황을 해결하기 위한 설정값을 기록해 둔다.
출처 : https://docs.unity3d.com/kr/current/Manual/class-AudioClip.html

프로젝트 세팅

Edit > Project Settings > Audio에서 DSP Buffer Size Best latency로 설정
- Best Performance : 성능이 우선 되어 출력 시 지연이 발생할 수 있음
- Best latency : 지연이 발생하지 않는 것을 우선시하여 출력 품질이 저하될 수 있음


리소스 타입별 세팅

배경음 1
- Force To Mono : 언 체크(퀄리티에 따라 가변)
- Load In Background : 체크
- Load Type : Streaming
- Preload Audio Data : 언 체크
- Compression Format : Vobis (100%)

배경음 2
- Force To Mono : 언 체크(퀄리티에 따라 가변)
- Load In Background : 체크
- Load Type : Compressed In Memory
- Preload Audio Data : 언 체크
- Compression Format : Vobis (70%)

효과음 : 작은 크기의 빈번한 출력 
- Force To Mono : 체크
- Load In Background : 언 체크
- Load Type : Decompress On Load
- Preload Audio Data : 체크
- Compression Format :  PCM

긴 효과음(보이스) : 중간 크기의 빈번한 출력
- Force To Mono : 체크
- Load In Background : 언 체크
- Load Type : Compressed In Memory
- Preload Audio Data : 체크
- Compression Format :  ADPCM

작은 크기의 가끔 발생하는 Sound
- Force To Mono : 체크
- Load In Background : 언 체크
- Load Type : Compressed In Memory
- Preload Audio Data : 언 체크
- Compression Format :  ADPCM

중간 크기의 가끔 발생하는 Sound
- Force To Mono : 체크
- Load In Background : 언체크
- Load Type : Compressed In Memory
- Preload Audio Data : 언 체크
- Compression Format :  Vobis (70%)


개별 리소스 세팅 정보

Force To Mono(모노 강제조정)
- 스테레오를 모노로 강제 조정
- 모바일이고 최적화를 중시할 경우 설정(체크) 함

Load In Background(지연된 로딩)
- 체크 시 출력 타이밍을 엄격히 지키지 않고, 느긋하게 백그라운드에서 로드
- 따라서 배경음악일 경우 사용 FX 사운드의 경우 체크 해제


Load Type
- Decompress On Load
 실행과 동시에 압축을 해제
 작은 사이즈의 FX 사운드에 유용
 많은 메모리 점유 CPU는 적게 사용

- Compressed In Memory
 메모리에 압축 상태로 저장, 실행 시 압축을 해제하여 재생
 약간의 성능상 오버헤드를 발생시킴
 보이스 사운드 등에 사용

- Streaming
 저장소에 위치한 오디오를 실시간으로 읽어냄.
 보통 배경음악에서 사용


Preload Audio Data
- 씬이 로딩될 때 씬에서 사용하는 모든 오디오 클립을 미리 로드
- 언체크시 플레이시 로드 하기에 랙 발생 됨


Compression Format
- PCM
 최고품질 / 용량 큼 / 작은 파일 크기에 적합 / FX 사운드
 Load Type은 Decompress On Load로 하자
 즉시 재생해야 하는 매우 짧은 효과음

- ADPCM
 중간 품질 / 용량 중간
 PCM대비 3.5배의 압축비, 노이즈가 포함됨
 총격 소리와 같이 무압축에 가까운 품질 까지는 필요없지만,
 지연시간 없이 자주 반복 재생 되야 하는 경우 적절

- Vobis
 최저품질 / 용량 적음 / 배경음에 적합
 압축률 설정이 가능(보통 70%로 설정)
 지연 재생 되어도 무방한 일반적인 배경음

 

 

[출처] https://jwidaegi.blogspot.com/2019/07/unity-sound.html

 

Unity Sound 설정

모바일 게임을 제작하다 보면, PC-에디터에서는 잘 나오던 게임 사운드가 핸드폰에서는 밀려 나오는 경우를 종종 겪을 수 있다. 이런 상황을 해결하기 위한 설정값을 기록해 둔다. 출처 :  https://

jwidaegi.blogspot.com

 

반응형
Posted by blueasa
, |

[링크] https://ijemin.com/blog/%EC%9C%A0%EB%8B%88%ED%8B%B0-2d-%EA%B2%8C%EC%9E%84-%EB%B9%8C%EB%93%9C-%EC%B5%9C%EC%A0%81%ED%99%94-%ED%8C%81/

 

유니티 (Unity) 2D 모바일 게임 최적화 팁 & 체크리스트 – I_Jemin

업데이트 2018/02/10 가독성 개선 2017/12/13 가독성 개선 2017/6/26 레퍼런스 추가 로깅/ GC, 필수 작업/ 퀄리티 세팅 추가 2017/5/26 유니티 5.6에 맞추어 갱신 레퍼런스 https://divillysausages.com/2016/01/21/performanc

ijemin.com

 

반응형
Posted by blueasa
, |

[링크] https://drehzr.tistory.com/1022

 

Unity)Android Gradle Version Change

Unity Android Gradle Version Change Unity 에서 Android의 Gradle의 버전을 변경을 해야하는 경우가 생겨서 이렇게 포스팅하게 되었다. Project Setting 의 Android - Publishing Settings에 보면 Build 항목에서 Custom Base Gradl

drehzr.tistory.com

 

[Gradle/Plugin 버전 참고] https://daldalhanstory.tistory.com/268

 

TIL # 65 androidStudio / plugin과 gradle 버전 맞추기 (feat. offlineMode)/ No cached version of com.android.tools.build:gra

코딩을 하다 보면 배우고 싶거나 모르는 라이브러리에 대한 소스코드를 찾아다니게 된다. 나 같은 경우는 githup에서 소스코드를 찾는 경우가 있는데, 깃 헙 홈페이지에서 소스를 참고하면서 라

daldalhanstory.tistory.com

 

반응형
Posted by blueasa
, |

[사용엔진] Unity 2021.3.14f1

-----------------------------

 

크래시 레포트를 보다보니 HUAWEI 폰에서 Vulkan 관련 크래시 레포트가 있어서

 

 생각해보니 Auto Graphics API를 활성화 해뒀다.

 

그래서 궁금해진 게 Auto Graphics API를 활성화하면 Vulkan이 적용되는가? 였는데..

Unity Document에 보니, Auto Graphics API를 활성화하면 Vulkan이 기본 적용하는 것 같다.

https://docs.unity3d.com/2021.3/Documentation/Manual/class-PlayerSettingsAndroid.html

[참조] https://forum.unity.com/threads/will-the-auto-graphics-api-automatically-enable-the-vulkan-api-when-available.625807/

 

Will the "Auto Graphics API" automatically enable the Vulkan API when available?

I have a Samsung galaxy S7 Edge, and I heard this phone can support Vulkan. So, just ticking "Auto Graphics API" in the Other Settings of Project...

forum.unity.com

 

-----------------------------

추가적으로 Vulkan 관련 이슈는 아래와 같이 2가지 내용이 보인다.

 

1. Unity에서 Vulkan 사용 시, 중국 폰에서 크래시가 꽤 많이 나온다고 한다.

 

[참조] https://cafe.naver.com/indiedev/64061?art=ZXh0ZXJuYWwtc2VydmljZS1uYXZlci1zZWFyY2gtY2FmZS1wcg.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjYWZlVHlwZSI6IkNBRkVfVVJMIiwiY2FmZVVybCI6ImluZGllZGV2IiwiYXJ0aWNsZUlkIjo2NDA2MSwiaXNzdWVkQXQiOjE2NjU5ODQwOTc3NDR9.hM-F6wmQ16ZhOGQkwPUh6iO0V4WO3GtgGUIobx8Qyjo 

 

샤오미 폰 크래시 이슈 (유니티 불칸이슈)

서비스 운영 후 꽤 많은 크래시 리포트를 받았는데 대부분은 샤오미 폰이였습니다. 특히 홍미노트 9s가 많이 팔린 폰이였는지 이 폰에서 문제가 많았습니다. 특히나 최근 글로벌로...

cafe.naver.com

 

2. 그리고, 성능 저하 이슈도 있다.

[참조] https://rainyrizzle.github.io/kr/AdvancedManual/AD_VulkanIssues.html

 

Vulkan 빌드시 성능 저하 문제

AnyPortrait > 메뉴얼 > Vulkan 빌드시 성능 저하 문제 Vulkan 빌드시 성능 저하 문제 이 페이지에서는 그래픽스 API 중 하나인 Vulkan을 이용해서 안드로이드 플랫폼으로 빌드를 했을 경우, 일부 기기에서

rainyrizzle.github.io

 

[결론]

결과적으로 Vulkan은 현재 적용하기 애매한가 싶어서 빼기로 했다.

Auto Graphics API를 비활성화 하고, 리스트에서 Vulkan을 없앴다.

OpenGLES2는 아직 지원하는 기기가 있을 것 같아서 일단 넣어 둠.

(아래 참조 링크에 보면 2020년 기준이긴 하지만 OpenGLES 2가 약 12% 있다.)

[참조] https://forum.unity.com/threads/is-opengl-es-2-is-still-needed-in-unity-for-android.976809/

 

Is OpenGL ES 2 is still needed in Unity for Android?

I've noticed that Unity 2019.4 LTS includes graphical API's: OpenGLES 3 and Vulkan. OpenGLES 2 is missing in player settings by default. I'm trying to...

forum.unity.com

 

[추가]

현재 프로젝트의 Android Minimum APL Level이 Android 6.0(API level 23)이기 때문에, OpenGL ES 2.0은 안써도 될 것 같아서 뺌

결과적으로 OpenGLES3만 남았다.

 

[참조] https://brunch.co.kr/@mystoryg/102

 

OpenGL ES 2.0 예제

3D 사각뿔 그리기 | OpenGL ES는 3차원 컴퓨터 그래픽스 API인 OpenGL(Open Graphic Library)의 임베디드 시스템을 위한 버전이다. ES가 Embaedded System을 의미한다. OpenGL은 다양한 API를 제공하며 해당 API들을 통

brunch.co.kr

 

반응형
Posted by blueasa
, |

Integrated Success 팀은 유니티 고객들이 복잡한 기술적 문제를 해결할 수 있도록 지원합니다. 유니티의 선임 소프트웨어 엔지니어로 구성된 이 팀과 함께 모바일 게임 최적화에 관한 전문적인 지식을 공유하는 자리를 마련했습니다.

유니티의 엔진 소스 코드를 완벽하게 파악하고 있는 Accelerate Solutions 팀은 Unity 엔진을 최대한 활용할 수 있도록 수많은 고객을 지원합니다. 팀은 크리에이터 프로젝트를 심도 있게 분석하여 속도, 안정성, 효율성 등을 향상시키기 위해 최적화할 부분을 파악합니다.

모바일 게임 최적화에 관한 인사이트를 공유하기 시작하면서, 원래 계획한 하나의 블로그 포스팅에 담기에는 너무나 방대한 정보가 있다는 사실을 알게 되었습니다. 따라서 이 방대한 지식을 한 권의 전자책(여기에서 다운로드 가능)과 75가지 이상의 실용적인 팁을 담은 블로그 포스팅 시리즈를 통해 제공하기로 했습니다.

이번 시리즈의 두 번째 포스팅에서는 UI, 물리, 오디오 설정을 통해 성능을 개선하는 방법을 자세히 살펴봅니다. 이전 포스팅에서는 프로파일링, 메모리, 코드 아키텍처에 대해 다뤘으며, 다음 포스팅에서는 에셋, 프로젝트 구성, 그래픽스에 대해 다룰 예정입니다. 

시리즈 전체 내용을 지금 바로 확인하고 싶다면 무료로 전자책을 다운로드하세요.

그럼 시작하겠습니다.

물리

Unity의 빌트인 물리(Nvidia PhysX)를 모바일에서 사용하려면 많은 리소스가 소요될 수 있지만, 다음 팁을 참고하면 초당 프레임 수를 늘릴 수 있습니다.

설정 최적화

가능하다면 항상 PlayerSettings에서 Prebake Collision Meshes를 선택합니다.

 
Prebake Collision Meshes 활성화확장

가능하다면 항상 물리 설정(Project Settings > Physics)을 편집하여 Layer Collision Matrix를 단순화합니다. 

Auto Sync Transforms를 비활성화하고 Reuse Collision Callbacks를 활성화합니다.

 
물리 프로젝트 설정을 수정하여 성능 향상확장
 
프로파일러의 Physics 모듈을 살펴 성능 문제 확인확장
콜라이더 단순화

메시 콜라이더는 많은 리소스를 요합니다. 복잡한 메시 콜라이더를 기본 또는 단순화된 메시 콜라이더로 대체하여 원래 모양을 대략적으로 표현하세요.

 
콜라이더에 기본 또는 단순화된 메시 사용확장
물리 메서드를 사용하여 리지드바디 이동

MovePosition 또는 AddForce와 같은 클래스 메서드를 사용하면 Rididbody 오브젝트를 이동할 수 있습니다. 트랜스폼 컴포넌트를 직접 변환하면 물리 월드에서 다시 계산하게 되어, 복잡한 씬의 경우 리소스를 많이 소모합니다. Update 대신 FixedUpdate에서 물리 바디를 이동시킵니다.

Fixed Timestep 고정

Project Settings에서 Fixed Timestep의 기본값은 0.02(50Hz)입니다. 이를 목표 프레임 속도와 일치하도록 변경합니다(예: 30fps는 0.03). 

만약 런타임에서 프레임 속도가 하락하면 Unity가 프레임당 FixedUpdate를 여러 번 호출하게 되어 물리가 많이 사용된 콘텐츠에서 CPU 성능 문제를 유발할 수 있습니다.

Maximum Allowed Timestep은 프레임 속도가 하락하는 경우 물리 계산 및 FixedUpdate 이벤트가 사용할 수 있는 시간의 양을 제한합니다. 이 값을 낮추면 성능 문제 발생 시 물리 및 애니메이션이 느려지도록 하여 프레임 속도에 미치는 영향을 줄일 수 있습니다.

 
Fixed Timestep을 목표 프레임 속도와 일치하도록 수정하고 Maximum Allowed Timestep를 낮춰 성능 결함 방지확장
Physics Debugger를 통한 시각화

Physics Debug 창(Windows > Analysis > Physics Debugger)을 사용하면 콜라이더나 불일치로 인한 문제를 해결할 수 있습니다. 이 창은 서로 충돌할 수 있는 게임 오브젝트를 색으로 구별하여 표시합니다.

 
물리 오브젝트의 상호 작용을 시각화하는 Physics Debug 툴확장

자세한 내용은 Unity 기술 자료의 Physics Debug Visualization을 참조하세요.

사용자 인터페이스

UGUI(Unity UI)는 성능 문제의 원인이 되는 경우가 많습니다. Canvas 컴포넌트는 UI 요소에 대한 메시를 생성 및 업데이트하고 GPU에 드로우 콜을 보냅니다. 이러한 기능은 리소스를 많이 소모할 수 있으므로 UGUI를 사용할 때 다음 사항을 기억하세요.

Canvas 나누기

수천 개의 요소가 포함된 하나의 대형 Canvas에서는 UI 요소를 하나만 업데이트해도 전체 Canvas가 강제로 업데이트되므로 CPU 스파이크가 발생할 수 있습니다. 

다수의 Canvas를 지원하는 UGUI의 기능을 활용하세요. 새로 고침해야 하는 빈도에 따라 UI 요소를 나눕니다. 정적 UI 요소는 별도의 Canvas에 두고, 동시에 업데이트되는 동적 요소는 보다 작은 하위 Canvas에 둡니다.

각 Canvas 내의 모든 UI 요소가 동일한 Z 값, 머티리얼, 텍스처를 갖도록 해야 합니다.

보이지 않는 UI 요소 숨기기

게임에서 간헐적으로만 나타나는 UI 요소(예: 캐릭터가 대미지를 입었을 때 나타나는 체력 표시줄)가 있을 수 있습니다. 보이지 않는 UI 요소가 활성화된 경우에도 드로우 콜을 사용할 수 있습니다. 보이지 않는 UI 컴포넌트를 명시적으로 비활성화하고 필요할 때 다시 활성화합니다.

Canvas의 가시성만 해제하면 되는 경우 게임 오브젝트 대신 Canvas 컴포넌트를 비활성화합니다. 이렇게 하면 메시와 버텍스를 재구성하지 않아도 됩니다.

GraphicRaycaster를 제한하고 Raycast Target 비활성화하기

GraphicRaycaster 컴포넌트는 화면 터치나 클릭과 같은 입력 이벤트에 필요합니다. 이 컴포넌트는 화면의 각 입력 지점을 순환하며 입력 지점이 UI의 RectTransform 내에 있는지 확인합니다. 

계층 구조의 맨 위쪽 Canvas에서 기본 GraphicRaycaster를 제거하세요. 대신, 상호 작용이 필요한 개별 요소(버튼, Scrollrect 등)에만 GraphicRaycaster를 추가합니다.

 
기본적으로 활성화되어 있는 Ignore Reversed Graphics 비활성화확장

아울러 모든 UI 텍스트 및 이미지에서 불필요하게 활성화된 Raycast Target도 비활성화합니다. UI에 많은 요소가 있어 복잡한 경우 이와 같이 간단히 설정을 변경하여 불필요한 계산을 줄일 수 있습니다.

 
가능한 경우 Raycast Target 비활성화확장
Layout Group

Layout Group은 비효율적으로 업데이트되므로 반드시 필요할 때만 사용하세요. 콘텐츠가 동적이지 않은 경우 Layout Group을 아예 사용하지 말고, 비율 레이아웃에 앵커를 대신 사용하시기 바랍니다. 그 밖의 경우에는 UI 설정을 마친 후 커스텀 코드를 생성하여 Layout Group 컴포넌트를 비활성화합니다.

동적 요소에 Layout Group(Horizontal, Vertical, Grid)을 사용해야 하는 경우, 중첩되지 않도록 하여 성능을 개선합니다.

 
중첩된 경우 특히 성능을 하락시키는 Layout Group확장
대형 리스트 뷰와 그리드 뷰 사용 시 주의

대형 리스트 뷰와 그리드 뷰는 많은 리소스를 소모합니다. 대형 리스트 또는 그리드 뷰(예: 수백 개의 항목이 있는 인벤토리 화면)를 만들어야 하는 경우 항목마다 UI 요소를 만드는 대신 소규모 UI 요소의 풀을 재사용하는 것이 좋습니다. 샘플 GitHub 프로젝트를 통해 실제 작동 모습을 확인하세요.

요소의 과도한 레이어링 주의

다수의 UI 요소를 레이어링하면(예: 카드 시합 게임에서 쌓여 있는 카드) 오버드로우가 발생합니다. 코드를 커스터마이즈하여 런타임에 레이어링된 요소를 병합하여 요소나 배치(batch)의 수를 줄이세요.

다양한 해상도 및 종횡비 사용

현재 모바일 기기에서 사용 중인 해상도와 화면 크기가 매우 다양하므로, 각 기기에서 최상의 경험을 제공하는 대체 버전의 UI를 만드세요.

Device Simulator를 사용하여 지원되는 다양한 기기의 UI를 미리 볼 수 있습니다. XCode Android Studio에서 가상 기기를 만들 수도 있습니다.

 
Device Simulator를 사용하여 다양한 화면 형식 미리 보기확장
전체 화면 UI 사용 시 기타 요소 모두 숨기기

일시 중지 화면이나 시작 화면이 씬의 나머지 부분을 모두 가리는 경우, 3D 씬을 렌더링하는 카메라를 비활성화합니다. 마찬가지로 맨 위쪽 Canvas에 가려진 배경 Canvas 요소도 모두 비활성화합니다.

60fps에서는 업데이트할 필요가 없으므로 전체 화면 UI 사용 시에는 Application.targetFrameRate를 낮게 설정하는 것이 좋습니다.

World Space 및 Camera Space Canvas 카메라 설정

Event 또는 Render Camera 필드를 공백으로 두면 Unity가 자동으로 Camera.main을 채워 넣어 불필요한 리소스가 소모됩니다. 

가능한 경우 Canvas의 RenderMode에 카메라가 필요 없는 Screen Space – Overlay를 사용하는 것이 좋습니다.

 
World Space Render Mode 사용 시 Event Camera 설정 확인확장
오디오

오디오는 일반적인 성능 저하 원인은 아니지만 최적화를 통해 메모리를 절약할 수 있습니다.

 
AudioClip의 Import Settings 최적화확장
가능한 경우 압축되지 않은 원본 WAV 파일을 소스 에셋으로 사용

압축된 형식(예: MP3 또는 Vorbis)을 사용하는 경우 Unity에서 압축을 푼 뒤 빌드 시간 동안 재압축해야 합니다. 그 결과 손실이 두 번 발생하여 최종 품질이 저하됩니다.

클립을 압축하고 압축 비트레이트 낮추기

압축을 통해 클립의 크기와 메모리 사용량을 줄이세요. 

  • 대부분의 사운드에 Vorbis(반복 재생 목적이 아닌 경우에는 MP3)를 사용하세요.
  • 자주 사용하는 짧은 소리(예: 발자국 소리, 총소리)에 ADPCM을 사용하세요. 이렇게 하면 압축되지 않은 PCM에 비해 파일이 줄지만 재생 중 디코딩은 빨라집니다.

모바일 기기에서의 음향 효과는 최대 22,050Hz여야 합니다. 낮은 설정을 사용해도 최종 품질에 미치는 영향은 일반적으로 매우 적으므로 직접 듣고 판단하세요.

적절한 로드 유형 선택

클립 크기에 따라 설정이 달라집니다.

  • 작은 클립(< 200kb) 로드 시 압축 해제되어야 합니다. 이는 사운드를 가공되지 않은 16비트 PCM 오디오 데이터로 압축 해제하여 CPU 비용과 메모리 사용을 발생시키므로 짧은 사운드에만 적합합니다.
  • 중간 클립(>= 200kb) 메모리에서 압축된 상태여야 합니다.
  • 대용량 파일(배경 음악)  스트리밍으로 설정해야 합니다. 그렇지 않으면 전체 에셋이 메모리에 한 번에 로드됩니다.
메모리에서 음소거된 AudioSource 언로드

음소거 버튼을 구현할 때 볼륨을 0으로 설정하지 마세요. 플레이어가 해당 기능을 자주 켜거나 끌 필요가 없다면 AudioSource 컴포넌트를 삭제하여 메모리에서 언로드할 수 있습니다.

전체 모바일 성능 팁 다운로드

다음 블로그 포스팅에서는 그래픽과 에셋에 대해 자세히 알아보겠습니다. 팀에서 제공하는 유용한 팁 목록을 모두 보고 싶다면 여기에서 전자책을 다운로드하시기 바랍니다.

 
확장

전자책 다운로드

통합 지원 서비스에 대해 자세히 알아보고 엔지니어, 전문가 조언 및 프로젝트에 맞는 베스트 프랙티스 가이드를 이용하려면 여기에서 유니티의 성공 플랜을 확인해 보세요.

더 많은 성능 팁 제공 예정

유니티는 Unity 애플리케이션이 최상의 성능을 발휘할 수 있도록 지원하기 위해 최선을 다하고 있습니다. 자세히 알고 싶은 최적화 주제가 있다면 댓글을 통해 알려 주시기 바랍니다.

2021년 7월 13일 테크놀로지 | 13 분 소요

 

 

[출처] https://blog.unity.com/kr/technology/optimize-your-mobile-game-performance-get-expert-tips-on-physics-ui-and-audio-settings

 

모바일 게임 성능 최적화: 물리, UI, 오디오 설정에 대한 전문가 팁 | Unity Blog

MovePosition 또는 AddForce와 같은 클래스 메서드를 사용하면 Rididbody 오브젝트를 이동할 수 있습니다. 트랜스폼 컴포넌트를 직접 변환하면 물리 월드에서 다시 계산하게 되어, 복잡한 씬의 경우 리소

blog.unity.com

 

반응형
Posted by blueasa
, |

[링크] https://blog.naver.com/ckdduq2507/222113891105

 

유니티(Unity) 사운드 최적화 가이드

  1. 3D Sound Settings 사운드 파일이나 Audio Source 컴포넌트를 붙이게 되면 3D Sound Set...

blog.naver.com

 

반응형
Posted by blueasa
, |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
 
public class Scene_Intro : MonoBehaviour 
{
	public VideoPlayer vid;
  
	void Start()
    {
    	vid.loopPointReached += CheckOver;
    }
 
    void CheckOver(UnityEngine.Video.VideoPlayer vp)
    {
         print  ("Video Is Over");
    }
}

 

 

[출처] https://mentum.tistory.com/170

 

VideoPlayer 끝난건지 확인하기.

출처 : https://forum.unity.com/threads/how-to-know-video-player-is-finished-playing-video.483935/ 1234567891011121314151617using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.Video; public class Scene_Intro : Mon

mentum.tistory.com

[참조] https://forum.unity.com/threads/how-to-know-video-player-is-finished-playing-video.483935/

 

Video - How to Know video player is finished playing video?

I want to have callback when video player is finished playing video. If i use videoplayer.isPlaying , this won't work because this will send call back...

forum.unity.com

 

반응형
Posted by blueasa
, |