上传YomovSDK
This commit is contained in:
8
Packages/com.unity.xr.openxr/OculusQuest/Editor.meta
Normal file
8
Packages/com.unity.xr.openxr/OculusQuest/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 189d4c2cb18ba5243a86711b1f8fb031
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using UnityEditor.Build.Reporting;
|
||||
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using UnityEngine.XR.OpenXR.Features.OculusQuestSupport;
|
||||
|
||||
namespace UnityEditor.XR.OpenXR.Features.OculusQuestSupport
|
||||
{
|
||||
[Obsolete("OpenXR.Features.OculusQuestSupport.ModifyAndroidManifestOculus is deprecated. Please use OpenXR.Features.MetaQuestSupport.ModifyAndroidManifestMeta instead.", false)]
|
||||
internal class ModifyAndroidManifestOculus : OpenXRFeatureBuildHooks
|
||||
{
|
||||
public override int callbackOrder => 1;
|
||||
|
||||
public override Type featureType => typeof(OculusQuestFeature);
|
||||
|
||||
protected override void OnPreprocessBuildExt(BuildReport report)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnPostGenerateGradleAndroidProjectExt(string path)
|
||||
{
|
||||
var androidManifest = new AndroidManifest(GetManifestPath(path));
|
||||
androidManifest.AddOculusMetaData();
|
||||
androidManifest.Save();
|
||||
}
|
||||
|
||||
protected override void OnPostprocessBuildExt(BuildReport report)
|
||||
{
|
||||
}
|
||||
|
||||
private string _manifestFilePath;
|
||||
|
||||
private string GetManifestPath(string basePath)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_manifestFilePath)) return _manifestFilePath;
|
||||
|
||||
var pathBuilder = new StringBuilder(basePath);
|
||||
pathBuilder.Append(Path.DirectorySeparatorChar).Append("src");
|
||||
pathBuilder.Append(Path.DirectorySeparatorChar).Append("main");
|
||||
pathBuilder.Append(Path.DirectorySeparatorChar).Append("AndroidManifest.xml");
|
||||
_manifestFilePath = pathBuilder.ToString();
|
||||
|
||||
return _manifestFilePath;
|
||||
}
|
||||
|
||||
private class AndroidXmlDocument : XmlDocument
|
||||
{
|
||||
private string m_Path;
|
||||
protected XmlNamespaceManager nsMgr;
|
||||
public readonly string AndroidXmlNamespace = "http://schemas.android.com/apk/res/android";
|
||||
|
||||
public AndroidXmlDocument(string path)
|
||||
{
|
||||
m_Path = path;
|
||||
using (var reader = new XmlTextReader(m_Path))
|
||||
{
|
||||
reader.Read();
|
||||
Load(reader);
|
||||
}
|
||||
|
||||
nsMgr = new XmlNamespaceManager(NameTable);
|
||||
nsMgr.AddNamespace("android", AndroidXmlNamespace);
|
||||
}
|
||||
|
||||
public string Save()
|
||||
{
|
||||
return SaveAs(m_Path);
|
||||
}
|
||||
|
||||
public string SaveAs(string path)
|
||||
{
|
||||
using (var writer = new XmlTextWriter(path, new UTF8Encoding(false)))
|
||||
{
|
||||
writer.Formatting = Formatting.Indented;
|
||||
Save(writer);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
private class AndroidManifest : AndroidXmlDocument
|
||||
{
|
||||
private readonly XmlElement ApplicationElement;
|
||||
private readonly XmlElement ActivityIntentFilterElement;
|
||||
private readonly XmlElement ActivityElement;
|
||||
private readonly XmlElement ManifestElement;
|
||||
|
||||
public AndroidManifest(string path) : base(path)
|
||||
{
|
||||
ApplicationElement = SelectSingleNode("/manifest/application") as XmlElement;
|
||||
ActivityIntentFilterElement = SelectSingleNode("/manifest/application/activity/intent-filter") as XmlElement;
|
||||
ActivityElement = SelectSingleNode("manifest/application/activity") as XmlElement;
|
||||
ManifestElement = SelectSingleNode("/manifest") as XmlElement;
|
||||
}
|
||||
|
||||
private XmlAttribute CreateAndroidAttribute(string key, string value)
|
||||
{
|
||||
XmlAttribute attr = CreateAttribute("android", key, AndroidXmlNamespace);
|
||||
attr.Value = value;
|
||||
return attr;
|
||||
}
|
||||
|
||||
private void UpdateOrCreateAttribute(XmlElement xmlParentElement, string tag, string name, params (string name, string value)[] attributes)
|
||||
{
|
||||
var xmlNodeList = xmlParentElement.SelectNodes(tag);
|
||||
XmlElement targetNode = null;
|
||||
|
||||
// Check all XmlNodes to see if a node with matching name already exists.
|
||||
foreach (XmlNode node in xmlNodeList)
|
||||
{
|
||||
XmlAttribute nameAttr = (XmlAttribute)node.Attributes.GetNamedItem("name", AndroidXmlNamespace);
|
||||
if (nameAttr != null && nameAttr.Value.Equals(name))
|
||||
{
|
||||
targetNode = (XmlElement)node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If node exists, update the attribute values if they are present or create new ones as requested. Else, create new XmlElement.
|
||||
if (targetNode != null)
|
||||
{
|
||||
for (int i = 0; i < attributes.Length; i++)
|
||||
{
|
||||
XmlAttribute attr = (XmlAttribute)targetNode.Attributes.GetNamedItem(attributes[i].name, AndroidXmlNamespace);
|
||||
if (attr != null)
|
||||
{
|
||||
attr.Value = attributes[i].value;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetNode.SetAttribute(attributes[i].name, AndroidXmlNamespace, attributes[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlElement newElement = CreateElement(tag);
|
||||
newElement.SetAttribute("name", AndroidXmlNamespace, name);
|
||||
for (int i = 0; i < attributes.Length; i++)
|
||||
newElement.SetAttribute(attributes[i].name, AndroidXmlNamespace, attributes[i].value);
|
||||
xmlParentElement.AppendChild(newElement);
|
||||
}
|
||||
}
|
||||
|
||||
internal void AddOculusMetaData()
|
||||
{
|
||||
OpenXRSettings androidOpenXRSettings = OpenXRSettings.GetSettingsForBuildTargetGroup(BuildTargetGroup.Android);
|
||||
var questFeature = androidOpenXRSettings.GetFeature<OculusQuestFeature>();
|
||||
|
||||
string supportedDevices = "quest|quest2";
|
||||
if (questFeature != null)
|
||||
{
|
||||
List<string> deviceList = new List<string>();
|
||||
if (questFeature.targetQuest)
|
||||
deviceList.Add("quest");
|
||||
if (questFeature.targetQuest2)
|
||||
deviceList.Add("quest2");
|
||||
|
||||
if (deviceList.Count > 0)
|
||||
{
|
||||
supportedDevices = String.Join("|", deviceList.ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
supportedDevices = null;
|
||||
UnityEngine.Debug.LogWarning("No target devices selected in Oculus Quest Support Feature. No devices will be listed as supported in the application Android manifest.");
|
||||
}
|
||||
}
|
||||
|
||||
UpdateOrCreateAttribute(ActivityIntentFilterElement,
|
||||
"category", "com.oculus.intent.category.VR"
|
||||
);
|
||||
|
||||
UpdateOrCreateAttribute(ActivityElement,
|
||||
"meta-data", "com.oculus.vr.focusaware",
|
||||
new (string name, string value)[]
|
||||
{
|
||||
("value", "true")
|
||||
});
|
||||
|
||||
UpdateOrCreateAttribute(ApplicationElement,
|
||||
"meta-data", "com.oculus.supportedDevices",
|
||||
new (string name, string value)[]
|
||||
{
|
||||
("value", supportedDevices)
|
||||
});
|
||||
|
||||
UpdateOrCreateAttribute(ManifestElement,
|
||||
"uses-feature", "android.hardware.vr.headtracking",
|
||||
new (string name, string value)[]
|
||||
{
|
||||
("required", "true"),
|
||||
("version", "1")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcc6b4166e9f34796961494bd96da33f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
using UnityEngine.XR.OpenXR.Features.OculusQuestSupport;
|
||||
|
||||
namespace UnityEditor.XR.OpenXR.Features.OculusQuestSupport
|
||||
{
|
||||
[CustomEditor(typeof(OculusQuestFeature))]
|
||||
[Obsolete("OpenXR.Features.OculusQuestSupport.OculusQuestFeatureEditor is deprecated. Please use OpenXR.Features.MetaQuestSupport.MetaQuestFeatureEditor instead.", false)]
|
||||
internal class OculusQuestFeatureEditor : Editor
|
||||
{
|
||||
private SerializedProperty targetQuest;
|
||||
private SerializedProperty targetQuest2;
|
||||
|
||||
static GUIContent s_TargetQuestLabel = EditorGUIUtility.TrTextContent("Quest");
|
||||
static GUIContent s_TargetQuest2Label = EditorGUIUtility.TrTextContent("Quest 2");
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
targetQuest = serializedObject.FindProperty("targetQuest");
|
||||
targetQuest2 = serializedObject.FindProperty("targetQuest2");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.LabelField("Target Devices", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(targetQuest, s_TargetQuestLabel);
|
||||
EditorGUILayout.PropertyField(targetQuest2, s_TargetQuest2Label);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f316b232939c924daedd509e9595466
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Unity.XR.OpenXR.Features.OculusQuestSupport.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:96aa6ba065960476598f8f643e7252b6",
|
||||
"GUID:4847341ff46394e83bb78fbd0652937e",
|
||||
"GUID:a9582160ded7e3c46829c5005bf42835"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c66676bdb1cd68648a487fd6c7ea0937
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Packages/com.unity.xr.openxr/OculusQuest/Runtime.meta
Normal file
8
Packages/com.unity.xr.openxr/OculusQuest/Runtime.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 679871b1ded4cd64885463c8ec940007
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
using UnityEngine.XR.OpenXR.Features.Interactions;
|
||||
using UnityEngine.XR.OpenXR.Features.MetaQuestSupport;
|
||||
#endif
|
||||
|
||||
namespace UnityEngine.XR.OpenXR.Features.OculusQuestSupport
|
||||
{
|
||||
/// <summary>
|
||||
/// Enables the Oculus mobile OpenXR Loader for Android, and modifies the AndroidManifest to be compatible with Quest.
|
||||
/// </summary>
|
||||
#if UNITY_EDITOR
|
||||
[OpenXRFeature(UiName = "Oculus Quest Support",
|
||||
Desc = "Necessary to deploy an Oculus Quest compatible app.",
|
||||
Company = "Unity",
|
||||
DocumentationLink = "https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk/",
|
||||
OpenxrExtensionStrings = "XR_OCULUS_android_initialize_loader",
|
||||
Version = "1.0.0",
|
||||
BuildTargetGroups = new[] {BuildTargetGroup.Android},
|
||||
FeatureId = featureId,
|
||||
Hidden = true
|
||||
)]
|
||||
#endif
|
||||
[Obsolete("OpenXR.Features.OculusQuestSupport.OculusQuestFeature is deprecated. Please use OpenXR.Features.MetaQuestSupport.MetaQuestFeature instead.", false)]
|
||||
public class OculusQuestFeature : OpenXRFeature
|
||||
{
|
||||
/// <summary>
|
||||
/// The feature id string. This is used to give the feature a well known id for reference.
|
||||
/// </summary>
|
||||
public const string featureId = "com.unity.openxr.feature.oculusquest";
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Quest entry to the supported devices list in the Android manifest.
|
||||
/// </summary>
|
||||
public bool targetQuest = true;
|
||||
/// <summary>
|
||||
/// Adds a Quest 2 entry to the supported devices list in the Android manifest.
|
||||
/// </summary>
|
||||
public bool targetQuest2 = true;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void GetValidationChecks(List<ValidationRule> rules, BuildTargetGroup targetGroup)
|
||||
{
|
||||
rules.Add(new ValidationRule(this)
|
||||
{
|
||||
message = "Oculus Quest Feature for Android platform is deprecated, please enable Meta Quest Feature instead.",
|
||||
checkPredicate = () => !this.enabled,
|
||||
error = true,
|
||||
errorEnteringPlaymode = true,
|
||||
fixIt = () =>
|
||||
{
|
||||
var settings = OpenXRSettings.GetSettingsForBuildTargetGroup(targetGroup);
|
||||
if (null == settings)
|
||||
return;
|
||||
this.enabled = false;
|
||||
var metaQuestFeature = settings.GetFeature<MetaQuestFeature>();
|
||||
if (metaQuestFeature != null)
|
||||
{
|
||||
metaQuestFeature.enabled = true;
|
||||
if (metaQuestFeature.targetDevices.Count == 0)
|
||||
{
|
||||
MetaQuestFeature.TargetDevice questDevice = new MetaQuestFeature.TargetDevice { manifestName = "quest", visibleName = "Quest", enabled = this.targetQuest, active = true};
|
||||
metaQuestFeature.targetDevices.Add(questDevice);
|
||||
MetaQuestFeature.TargetDevice quest2Device = new MetaQuestFeature.TargetDevice { manifestName = "quest2", visibleName = "Quest 2", enabled = this.targetQuest2, active = true};
|
||||
metaQuestFeature.targetDevices.Add(quest2Device);
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < metaQuestFeature.targetDevices.Count; i++)
|
||||
{
|
||||
if (metaQuestFeature.targetDevices[i].manifestName == "quest")
|
||||
{
|
||||
metaQuestFeature.targetDevices[i] = new MetaQuestFeature.TargetDevice() {manifestName = "quest", visibleName = "Quest", enabled = this.targetQuest, active = true};
|
||||
}
|
||||
if (metaQuestFeature.targetDevices[i].manifestName == "quest2")
|
||||
{
|
||||
metaQuestFeature.targetDevices[i] = new MetaQuestFeature.TargetDevice() {manifestName = "quest2", visibleName = "Quest 2", enabled = this.targetQuest2, active = true};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Obsolete("OpenXR.Features.OculusQuestSupport.OculusQuestFeatureEditorWindow is deprecated.", false)]
|
||||
internal class OculusQuestFeatureEditorWindow : EditorWindow
|
||||
{
|
||||
private Object feature;
|
||||
private Editor featureEditor;
|
||||
|
||||
public static EditorWindow Create(Object feature)
|
||||
{
|
||||
var window = EditorWindow.GetWindow<OculusQuestFeatureEditorWindow>(true, "Oculus Quest Feature Configuration", true);
|
||||
window.feature = feature;
|
||||
window.featureEditor = Editor.CreateEditor(feature);
|
||||
return window;
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
featureEditor.OnInspectorGUI();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ef793c31862a37448e907829482ef80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "Unity.XR.OpenXR.Features.OculusQuestSupport",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:4847341ff46394e83bb78fbd0652937e",
|
||||
"GUID:95054a9710b0f114a85f6ced6b7f891c"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9582160ded7e3c46829c5005bf42835
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user