Skip to content

Instantly share code, notes, and snippets.

@arumani
Last active September 12, 2018 04:04
Show Gist options
  • Save arumani/deb11e450cded21c605ae73846eaa696 to your computer and use it in GitHub Desktop.
Save arumani/deb11e450cded21c605ae73846eaa696 to your computer and use it in GitHub Desktop.
UnityでiOSプロジェクトを書き出した際に、iOS 10でカメラを使う場合に必須の記述をInfo.plistに追加するスクリプト。/Assets/Editor/ 以下に置く
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.IO;
using UnityEditor.iOS.Xcode;
public class AddCameraUsageToInfoPlist {
[PostProcessBuildAttribute(99)]
public static void OnPostprocessBuild(BuildTarget target, string buildPath) {
if (target != BuildTarget.iOS) {
return;
}
var plist = new PlistDocument ();
var filePath = Path.Combine (buildPath, "Info.plist");
plist.ReadFromFile(filePath);
plist.root.SetString ("NSCameraUsageDescription", "");
plist.WriteToFile (filePath);
Debug.Log ("Info.plist replaced.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment