コード例 #1
0
        public void OnPostprocessBuild(BuildTarget InTarget, string InPath)
        {
            if (InTarget == BuildTarget.iOS)
            {
#if UNITY_IOS
                string plistPath = Path.Combine(InPath, "Info.plist");
                UnityEditor.iOS.Xcode.PlistDocument plist = new UnityEditor.iOS.Xcode.PlistDocument();

                plist.ReadFromFile(plistPath);
                plist.root.SetString("GADApplicationIdentifier", AdManager.AD_APP_ID);
                File.WriteAllText(plistPath, plist.WriteToString());
#endif
            }
        }
コード例 #2
0
        public static void UpdateInfoPList(BuildTarget buildTarget, string pathToBuiltProject)
        {
            if (buildTarget != BuildTarget.iOS)
                return;

            var settings = InputSystem.settings.iOS;
            if (!settings.motionUsage.enabled)
                return;
            var plistPath = pathToBuiltProject + "/Info.plist";
            var contents = File.ReadAllText(plistPath);
            var description = InputSystem.settings.iOS.motionUsage.usageDescription;
#if UNITY_IOS || UNITY_TVOS
            var plist = new UnityEditor.iOS.Xcode.PlistDocument();
            plist.ReadFromString(contents);
            var root = plist.root;
            var buildKey = "NSMotionUsageDescription";
            if (root[buildKey] != null)
                Debug.LogWarning($"{buildKey} is already present in Info.plist, the value will be overwritten.");

            root.SetString(buildKey, description);
            File.WriteAllText(plistPath, plist.WriteToString());
#endif
        }