我无法在 iOS7 上复制您的问题。但是,iOS6 上确实存在该问题。我做了一个小技巧,似乎可以在我的设备上修复它。
EveryplayMicHack.cs(将其复制到 Plugins/Everyplay/Scripts 文件夹):
using UnityEngine;
using System.Runtime.InteropServices;
public class EveryplayMicHack {
public static void EnableRecording() {
#if UNITY_IPHONE && !UNITY_EDITOR
SetPreferredSampleRate(AudioSettings.outputSampleRate);
#endif
}
#if UNITY_IPHONE && !UNITY_EDITOR
[DllImport ("__Internal")]
private static extern void SetPreferredSampleRate(int sampleRate);
#endif
}
EveryplayMicHack.h(复制到 Plugins/iOS 文件夹)
#import <AVFoundation/AVFoundation.h>
void SetPreferredSampleRate(int sampleRate);
EveryplayMicHack.m(复制到 Plugins/iOS 文件夹)
#import "EveryplayMicHack.h"
void SetPreferredSampleRate(int sampleRate) {
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setPreferredHardwareSampleRate:sampleRate error:nil];
}
在初始化麦克风之前,调用:EveryplayMicHack.EnableRecording();
// Something like this
EveryplayMicHack.EnableRecording();
myMicAudioSource.clip = null;
myMicAudioSource.clip = Microphone.Start("Built-in Microphone", ...
我希望它也对你有用! :)