A game about forced loneliness, made by TACStudios
at master 1.3 kB view raw
1#if UNITY_EDITOR 2using System.IO; 3using UnityEditor; 4using UnityEditor.Callbacks; 5using UnityEngine; 6using UnityEngine.InputSystem; 7 8namespace UnityEngine.InputSystem 9{ 10 internal class iOSPostProcessBuild 11 { 12 [PostProcessBuild] 13 public static void UpdateInfoPList(BuildTarget buildTarget, string pathToBuiltProject) 14 { 15 if (buildTarget != BuildTarget.iOS) 16 return; 17 18 var settings = InputSystem.settings.iOS; 19 if (!settings.motionUsage.enabled) 20 return; 21 var plistPath = pathToBuiltProject + "/Info.plist"; 22 var contents = File.ReadAllText(plistPath); 23 var description = InputSystem.settings.iOS.motionUsage.usageDescription; 24#if UNITY_IOS || UNITY_TVOS 25 var plist = new UnityEditor.iOS.Xcode.PlistDocument(); 26 plist.ReadFromString(contents); 27 var root = plist.root; 28 var buildKey = "NSMotionUsageDescription"; 29 if (root[buildKey] != null) 30 Debug.LogWarning($"{buildKey} is already present in Info.plist, the value will be overwritten."); 31 32 root.SetString(buildKey, description); 33 File.WriteAllText(plistPath, plist.WriteToString()); 34#endif 35 } 36 } 37} 38 39#endif