up
This commit is contained in:
@@ -4,9 +4,7 @@ using System.Text;
|
||||
using System.Xml;
|
||||
using UnityEditor.Android;
|
||||
using UnityEditor.Callbacks;
|
||||
#if UNITY_IOS
|
||||
using UnityEditor.iOS.Xcode;
|
||||
#endif
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -25,6 +23,9 @@ public class UnityWebViewPostprocessBuild
|
||||
var changed = false;
|
||||
var androidManifest = new AndroidManifest(GetManifestPath(basePath));
|
||||
changed = (androidManifest.SetHardwareAccelerated(true) || changed);
|
||||
#if UNITYWEBVIEW_ANDROID_USES_CLEARTEXT_TRAFFIC
|
||||
changed = (androidManifest.SetUsesCleartextTraffic(true) || changed);
|
||||
#endif
|
||||
#if UNITYWEBVIEW_ANDROID_ENABLE_CAMERA
|
||||
changed = (androidManifest.AddCamera() || changed);
|
||||
#endif
|
||||
@@ -71,6 +72,9 @@ public class UnityWebViewPostprocessBuild
|
||||
var changed = false;
|
||||
var androidManifest = new AndroidManifest(manifest);
|
||||
changed = (androidManifest.SetHardwareAccelerated(true) || changed);
|
||||
#if UNITYWEBVIEW_ANDROID_USES_CLEARTEXT_TRAFFIC
|
||||
changed = (androidManifest.SetUsesCleartextTraffic(true) || changed);
|
||||
#endif
|
||||
#if UNITYWEBVIEW_ANDROID_ENABLE_CAMERA
|
||||
changed = (androidManifest.AddCamera() || changed);
|
||||
#endif
|
||||
@@ -86,8 +90,6 @@ public class UnityWebViewPostprocessBuild
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_IOS
|
||||
if (buildTarget == BuildTarget.iOS) {
|
||||
string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
|
||||
PBXProject proj = new PBXProject();
|
||||
@@ -99,7 +101,6 @@ public class UnityWebViewPostprocessBuild
|
||||
#endif
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +155,16 @@ internal class AndroidManifest : AndroidXmlDocument {
|
||||
nsMgr);
|
||||
}
|
||||
|
||||
internal bool SetUsesCleartextTraffic(bool enabled) {
|
||||
// android:usesCleartextTraffic
|
||||
bool changed = false;
|
||||
if (ApplicationElement.GetAttribute("usesCleartextTraffic", AndroidXmlNamespace) != ((enabled) ? "true" : "false")) {
|
||||
ApplicationElement.SetAttribute("usesCleartextTraffic", AndroidXmlNamespace, (enabled) ? "true" : "false");
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
internal bool SetHardwareAccelerated(bool enabled) {
|
||||
bool changed = false;
|
||||
var activity = GetActivityWithLaunchIntent() as XmlElement;
|
||||
|
||||
Reference in New Issue
Block a user