[IOS] FULLSCREENMOVIECONTROLMODE.CANCELONINPUT DOES NOT WORK ON IOS11
https://issuetracker.unity3d.com/issues/ios-fullscreenmoviecontrolmode-dot-canceloninput-does-not-work-on-ios11
Unity 2017.3 で直る模様。
PostProcessBuild で FullScreenVideoPlayer.mm ファイルに追記するサンプル。
Editor フォルダ配下に配置してビルド。
FullScreenVideoPlayerForIOS11.cs
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
namespace BuildScripts
{
public class FullScreenVideoPlayerForIOS11
{
private const string TEXT = @"
@interface UIWindow (VideoPlay)
@end
@implementation UIWindow(VideoPlay)
- (void)touchesBegan:(NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
{
[super touchesBegan: touches withEvent: event];
NSString *version = [UIDevice currentDevice].systemVersion;
if(version.doubleValue >= 11 && UnityIsFullScreenPlaying())
{
UnityStopFullScreenVideoIfPlaying();
}
}
@end";
[PostProcessBuild(100)]
public static void OnPostProcessBuild(BuildTarget target, string path)
{
if (target == BuildTarget.iOS)
{
var filePath = Path.Combine(path, "Classes/Unity/FullScreenVideoPlayer.mm");
if (!File.Exists(filePath))
{
throw new FileNotFoundException("Unity で生成されるはずのファイルが存在しません。", filePath);
}
using (var streamWriter = new StreamWriter(filePath, true))
{
streamWriter.WriteLine();
streamWriter.Write(TEXT);
}
}
}
}
}