Tanoda
QRCodePostProcessBuild.cs
Go to the documentation of this file.
1#if UNITY_IOS
2using UnityEditor;
3using UnityEditor.Callbacks;
4using System.IO;
5using UnityEditor.iOS.Xcode;
6#endif
7
9{
10 private const bool ENABLED = true;
11
12 private const string PHOTO_LIBRARY_USAGE_DESCRIPTION = "Save media to Photos";
13 private const string CAMERA_USAGE_DESCRIPTION = "Open Camera to get data of devicecamera !";
14
15#if UNITY_IOS
16#pragma warning disable 0162
17 [PostProcessBuild]
18 public static void OnPostprocessBuild( BuildTarget target, string buildPath )
19 {
20 if( !ENABLED )
21 return;
22
23 if( target == BuildTarget.iOS )
24 {
25 string pbxProjectPath = PBXProject.GetPBXProjectPath( buildPath );
26 string plistPath = Path.Combine( buildPath, "Info.plist" );
27
28
29 PlistDocument plist = new PlistDocument();
30 plist.ReadFromString( File.ReadAllText( plistPath ) );
31
32 PlistElementDict rootDict = plist.root;
33 rootDict.SetString( "NSPhotoLibraryUsageDescription", PHOTO_LIBRARY_USAGE_DESCRIPTION );
34 rootDict.SetString( "NSPhotoLibraryAddUsageDescription", PHOTO_LIBRARY_USAGE_DESCRIPTION );
35 rootDict.SetString( "NSCameraUsageDescription", CAMERA_USAGE_DESCRIPTION );
36
37
38 File.WriteAllText( plistPath, plist.WriteToString() );
39 }
40 }
41#pragma warning restore 0162
42#endif
43}