본문 바로가기

Programming/유니티

유니티(Unity) iOS 진동모드 일때 소리가 안나오는 현상

ㄴ실내에서 취미로 생이새우 키우기
ㄴ자작 이탄 디퓨저를 사용할 때 고려해야 하는 것
ㄴ생이새우 어항 LED조명과 다이소 조명 비교
ㄴ생이새우 포란 환경과 수온
ㄴ생이새우와 수초어항 이산화탄소의 필요성
ㄴ상아쿠아 수초 및 유목 등 구입기

----

----

해결방법

Unity-iPhone -> Classes -> UnityAppController.mm 파일에 코드를 추가

- (void)startUnity:(UIApplication*)application
{
    NSAssert(_unityAppReady == NO, @"[UnityAppController startUnity:] called after Unity has been initialized");

    UnityInitApplicationGraphics();

#if !PLATFORM_VISIONOS
    // we make sure that first level gets correct display list and orientation
    [[DisplayManager Instance] updateDisplayListCacheInUnity];
#endif

    UnityLoadApplication();
    Profiler_InitProfiler();

    [self showGameUI];
    [self createDisplayLink];

    UnitySetPlayerFocus(1);

    AVAudioSession* audioSession = [AVAudioSession sharedInstance];
    
    //-------소리안나는 현상 추가한 코드-------//
    [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
    [audioSession setActive:YES error:nil];
    //-------소리안나는 현상 추가한 코드-------//
    
    // If Unity audio is disabled, we set the category to ambient to make sure we don't mute other app's audio. We set the audio session
    // to active so we can get outputVolume callbacks. If Unity audio is enabled, FMOD should have already handled all of this AVAudioSession init.
    if (!UnityIsAudioManagerAvailableAndEnabled())
    {
        [audioSession setCategory: AVAudioSessionCategoryAmbient error: nil];
        [audioSession setActive: YES error: nil];
    }
    [audioSession addObserver: self forKeyPath: @"outputVolume" options: 0 context: nil];
    UnityUpdateMuteState([audioSession outputVolume] < 0.01f ? 1 : 0);

#if UNITY_REPLAY_KIT_AVAILABLE
    void InitUnityReplayKit();  // Classes/Unity/UnityReplayKit.mm

    InitUnityReplayKit();
#endif
}