Guest User

Untitled

a guest
Sep 14th, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. #if UNITY_EDITOR
  2. using System.IO;
  3. using UnityEditor;
  4. using UnityEditor.Callbacks;
  5. using UnityEngine;
  6. using UnityEngine.InputSystem;
  7.  
  8. namespace 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
Advertisement
Add Comment
Please, Sign In to add comment