killapp/Assets/Editor/iOSPermissionPostProcessor.cs

27 lines
874 B
C#
Raw Normal View History

2026-04-28 16:35:51 +08:00
#if UNITY_IOS
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System.IO;
public class iOSPermissionPostProcessor
{
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
{
if (target != BuildTarget.iOS) return;
string plistPath = Path.Combine(pathToBuiltProject, "Info.plist");
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
PlistElementDict rootDict = plist.root;
// 添加摄像头权限描述
rootDict.SetString("NSCameraUsageDescription", "Camera access is used to scan the QR code on your device for pairing. For example, scan the QR code on the device body to complete the connection.");
2026-04-28 16:35:51 +08:00
File.WriteAllText(plistPath, plist.WriteToString());
}
}
#endif