Загрузка PICO Unity OpenXR Integration SDK
This commit is contained in:
@ -0,0 +1,201 @@
|
||||
/*******************************************************************************
|
||||
Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
|
||||
|
||||
NOTICE:All information contained herein is, and remains the property of
|
||||
PICO Technology Co., Ltd. The intellectual and technical concepts
|
||||
contained hererin are proprietary to PICO Technology Co., Ltd. and may be
|
||||
covered by patents, patents in process, and are protected by trade secret or
|
||||
copyright law. Dissemination of this information or reproduction of this
|
||||
material is strictly forbidden unless prior written permission is obtained from
|
||||
PICO Technology Co., Ltd.
|
||||
*******************************************************************************/
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Unity.XR.OpenXR.Features.PICOSupport
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(CompositeLayerFeature))]
|
||||
public class PICOCompositeLayerEditor : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var guiContent = new GUIContent();
|
||||
foreach (CompositeLayerFeature overlayTarget in targets)
|
||||
{
|
||||
EditorGUILayout.LabelField("Overlay Settings", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.BeginVertical("frameBox");
|
||||
guiContent.text = "Type";
|
||||
overlayTarget.overlayType = (CompositeLayerFeature.OverlayType)EditorGUILayout.EnumPopup(guiContent, overlayTarget.overlayType);
|
||||
guiContent.text = "Shape";
|
||||
overlayTarget.overlayShape = (CompositeLayerFeature.OverlayShape)EditorGUILayout.EnumPopup(guiContent, overlayTarget.overlayShape);
|
||||
guiContent.text = "Depth";
|
||||
overlayTarget.layerDepth = EditorGUILayout.IntField(guiContent, overlayTarget.layerDepth);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
EditorGUILayout.LabelField("Overlay Textures", EditorStyles.boldLabel);
|
||||
guiContent.text = "Texture Type";
|
||||
overlayTarget.textureType = (CompositeLayerFeature.TextureType)EditorGUILayout.EnumPopup(guiContent, overlayTarget.textureType);
|
||||
EditorGUILayout.Separator();
|
||||
|
||||
if (overlayTarget.textureType == CompositeLayerFeature.TextureType.StaticTexture)
|
||||
{
|
||||
overlayTarget.isDynamic = false;
|
||||
}
|
||||
else if (overlayTarget.textureType == CompositeLayerFeature.TextureType.DynamicTexture)
|
||||
{
|
||||
overlayTarget.isDynamic = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayTarget.isDynamic = false;
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField("Texture");
|
||||
EditorGUILayout.BeginVertical("frameBox");
|
||||
|
||||
var labelControlRect = EditorGUILayout.GetControlRect();
|
||||
EditorGUI.LabelField(new Rect(labelControlRect.x, labelControlRect.y, labelControlRect.width / 2, labelControlRect.height), new GUIContent("Left", "Texture used for the left eye"));
|
||||
EditorGUI.LabelField(new Rect(labelControlRect.x + labelControlRect.width / 2, labelControlRect.y, labelControlRect.width / 2, labelControlRect.height), new GUIContent("Right", "Texture used for the right eye"));
|
||||
|
||||
var textureControlRect = EditorGUILayout.GetControlRect(GUILayout.Height(64));
|
||||
overlayTarget.layerTextures[0] = (Texture)EditorGUI.ObjectField(new Rect(textureControlRect.x, textureControlRect.y, 64, textureControlRect.height), overlayTarget.layerTextures[0], typeof(Texture), false);
|
||||
overlayTarget.layerTextures[1] = (Texture)EditorGUI.ObjectField(new Rect(textureControlRect.x + textureControlRect.width / 2, textureControlRect.y, 64, textureControlRect.height), overlayTarget.layerTextures[1] != null ? overlayTarget.layerTextures[1] : overlayTarget.layerTextures[0], typeof(Texture), false);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
|
||||
|
||||
if (overlayTarget.overlayShape == CompositeLayerFeature.OverlayShape.Equirect)
|
||||
{
|
||||
guiContent.text = "Radius";
|
||||
overlayTarget.radius = EditorGUILayout.FloatField(guiContent, Mathf.Abs(overlayTarget.radius));
|
||||
}
|
||||
|
||||
if (overlayTarget.overlayShape == CompositeLayerFeature.OverlayShape.Quad || overlayTarget.overlayShape == CompositeLayerFeature.OverlayShape.Cylinder || overlayTarget.overlayShape == CompositeLayerFeature.OverlayShape.Equirect)
|
||||
{
|
||||
guiContent.text = "Texture Rects";
|
||||
overlayTarget.useImageRect = EditorGUILayout.Toggle(guiContent, overlayTarget.useImageRect);
|
||||
if (overlayTarget.useImageRect)
|
||||
{
|
||||
guiContent.text = "Source Rects";
|
||||
overlayTarget.textureRect = (CompositeLayerFeature.TextureRect)EditorGUILayout.EnumPopup(guiContent, overlayTarget.textureRect);
|
||||
|
||||
if (overlayTarget.textureRect == CompositeLayerFeature.TextureRect.Custom)
|
||||
{
|
||||
EditorGUILayout.BeginVertical("frameBox");
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Left Rect");
|
||||
EditorGUILayout.LabelField("Right Rect");
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
overlayTarget.srcRectLeft = ClampRect(EditorGUILayout.RectField(overlayTarget.srcRectLeft));
|
||||
EditorGUILayout.Space(15);
|
||||
guiContent.text = "Right";
|
||||
overlayTarget.srcRectRight = ClampRect(EditorGUILayout.RectField(overlayTarget.srcRectRight));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
else if (overlayTarget.textureRect == CompositeLayerFeature.TextureRect.MonoScopic)
|
||||
{
|
||||
overlayTarget.srcRectLeft = new Rect(0, 0, 1, 1);
|
||||
overlayTarget.srcRectRight = new Rect(0, 0, 1, 1);
|
||||
}
|
||||
else if (overlayTarget.textureRect == CompositeLayerFeature.TextureRect.StereoScopic)
|
||||
{
|
||||
overlayTarget.srcRectLeft = new Rect(0, 0, 0.5f, 1);
|
||||
overlayTarget.srcRectRight = new Rect(0.5f, 0, 0.5f, 1);
|
||||
}
|
||||
|
||||
if (overlayTarget.overlayShape == CompositeLayerFeature.OverlayShape.Quad || overlayTarget.overlayShape == CompositeLayerFeature.OverlayShape.Equirect)
|
||||
{
|
||||
guiContent.text = "Destination Rects";
|
||||
overlayTarget.destinationRect = (CompositeLayerFeature.DestinationRect)EditorGUILayout.EnumPopup(guiContent, overlayTarget.destinationRect);
|
||||
|
||||
if (overlayTarget.destinationRect == CompositeLayerFeature.DestinationRect.Custom)
|
||||
{
|
||||
EditorGUILayout.BeginVertical("frameBox");
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUILayout.LabelField("Left Rect");
|
||||
EditorGUILayout.LabelField("Right Rect");
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
overlayTarget.dstRectLeft = ClampRect(EditorGUILayout.RectField(overlayTarget.dstRectLeft));
|
||||
EditorGUILayout.Space(15);
|
||||
guiContent.text = "Right";
|
||||
overlayTarget.dstRectRight = ClampRect(EditorGUILayout.RectField(overlayTarget.dstRectRight));
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayTarget.dstRectLeft = new Rect(0, 0, 1, 1);
|
||||
overlayTarget.dstRectRight = new Rect(0, 0, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guiContent.text = "Layer Blend";
|
||||
overlayTarget.useLayerBlend = EditorGUILayout.Toggle(guiContent, overlayTarget.useLayerBlend);
|
||||
if (overlayTarget.useLayerBlend)
|
||||
{
|
||||
EditorGUILayout.BeginVertical("frameBox");
|
||||
guiContent.text = "Src Color";
|
||||
overlayTarget.srcColor = (PxrBlendFactor)EditorGUILayout.EnumPopup(guiContent, overlayTarget.srcColor);
|
||||
guiContent.text = "Dst Color";
|
||||
overlayTarget.dstColor = (PxrBlendFactor)EditorGUILayout.EnumPopup(guiContent, overlayTarget.dstColor);
|
||||
guiContent.text = "Src Alpha";
|
||||
overlayTarget.srcAlpha = (PxrBlendFactor)EditorGUILayout.EnumPopup(guiContent, overlayTarget.srcAlpha);
|
||||
guiContent.text = "Dst Alpha";
|
||||
overlayTarget.dstAlpha = (PxrBlendFactor)EditorGUILayout.EnumPopup(guiContent, overlayTarget.dstAlpha);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
guiContent.text = "Override Color Scale";
|
||||
overlayTarget.overrideColorScaleAndOffset = EditorGUILayout.Toggle(guiContent, overlayTarget.overrideColorScaleAndOffset);
|
||||
if (overlayTarget.overrideColorScaleAndOffset)
|
||||
{
|
||||
EditorGUILayout.BeginVertical("frameBox");
|
||||
|
||||
guiContent.text = "Scale";
|
||||
Vector4 colorScale = EditorGUILayout.Vector4Field(guiContent, overlayTarget.colorScale);
|
||||
|
||||
guiContent.text = "Offset";
|
||||
Vector4 colorOffset = EditorGUILayout.Vector4Field(guiContent, overlayTarget.colorOffset);
|
||||
overlayTarget.SetLayerColorScaleAndOffset(colorScale, colorOffset);
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
|
||||
if (GUI.changed)
|
||||
{
|
||||
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEngine.SceneManagement.SceneManager.GetActiveScene());
|
||||
}
|
||||
}
|
||||
private Rect ClampRect(Rect rect)
|
||||
{
|
||||
rect.x = Mathf.Clamp01(rect.x);
|
||||
rect.y = Mathf.Clamp01(rect.y);
|
||||
rect.width = Mathf.Clamp01(rect.width);
|
||||
rect.height = Mathf.Clamp01(rect.height);
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d0dfa675096f67419bbdde07d4e7b65
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,95 @@
|
||||
using Unity.XR.PXR;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.XR.OpenXR.Features.PICOSupport
|
||||
{
|
||||
[CustomEditor(typeof(PICOFeature))]
|
||||
internal class PICOFeatureEditor : Editor
|
||||
{
|
||||
void OnEnable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
PICOFeature picoFeature = (PICOFeature)target;
|
||||
PICOProjectSetting projectConfig = PICOProjectSetting.GetProjectConfig();
|
||||
EditorGUIUtility.labelWidth = 180;
|
||||
//eye tracking
|
||||
GUIStyle firstLevelStyle = new GUIStyle(GUI.skin.label);
|
||||
firstLevelStyle.alignment = TextAnchor.UpperLeft;
|
||||
firstLevelStyle.fontStyle = FontStyle.Bold;
|
||||
firstLevelStyle.fontSize = 12;
|
||||
firstLevelStyle.wordWrap = true;
|
||||
var guiContent = new GUIContent();
|
||||
guiContent.text = "Eye Tracking";
|
||||
guiContent.tooltip = "Before calling EyeTracking API, enable this option first, only for Neo3 Pro Eye , PICO 4 Pro device.";
|
||||
projectConfig.isEyeTracking = EditorGUILayout.Toggle(guiContent, projectConfig.isEyeTracking);
|
||||
if (projectConfig.isEyeTracking)
|
||||
{
|
||||
projectConfig.isEyeTrackingCalibration = EditorGUILayout.Toggle(new GUIContent("Eye Tracking Calibration"), projectConfig.isEyeTrackingCalibration);
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
EditorGUILayout.LabelField("Note: Eye Tracking is supported only on Neo 3 Pro Eye , PICO 4 Pro", firstLevelStyle);
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
projectConfig.isHandTracking = EditorGUILayout.Toggle("Hand Tracking", projectConfig.isHandTracking);
|
||||
|
||||
var displayFrequencyContent = new GUIContent();
|
||||
displayFrequencyContent.text = "Display Refresh Rates";
|
||||
projectConfig.displayFrequency = (SystemDisplayFrequency)EditorGUILayout.EnumPopup(displayFrequencyContent, projectConfig.displayFrequency);
|
||||
|
||||
// content protect
|
||||
projectConfig.useContentProtect = EditorGUILayout.Toggle("Use Content Protect", projectConfig.useContentProtect);
|
||||
if (projectConfig.useContentProtect)
|
||||
{
|
||||
projectConfig.contentProtectFlags = (SecureContentFlag)EditorGUILayout.EnumPopup("Content Protect", projectConfig.contentProtectFlags);
|
||||
}
|
||||
|
||||
//FFR
|
||||
var foveationEnableContent = new GUIContent();
|
||||
foveationEnableContent.text = "Foveated Rendering";
|
||||
projectConfig.foveationEnable = EditorGUILayout.Toggle(foveationEnableContent, projectConfig.foveationEnable);
|
||||
if (projectConfig.foveationEnable)
|
||||
{
|
||||
var foveationContent = new GUIContent();
|
||||
foveationContent.text = "Foveated Rendering Mode";
|
||||
projectConfig.foveatedRenderingMode = (FoveationFeature.FoveatedRenderingMode)EditorGUILayout.EnumPopup(foveationContent, projectConfig.foveatedRenderingMode);
|
||||
|
||||
var foveationLevel = new GUIContent();
|
||||
foveationLevel.text = "Foveated Rendering Level";
|
||||
projectConfig.foveatedRenderingLevel = (FoveationFeature.FoveatedRenderingLevel)EditorGUILayout.EnumPopup(foveationLevel, projectConfig.foveatedRenderingLevel);
|
||||
|
||||
if (projectConfig.foveatedRenderingLevel !=FoveationFeature.FoveatedRenderingLevel.Off)
|
||||
{
|
||||
var subsampledEnabledContent = new GUIContent();
|
||||
subsampledEnabledContent.text = "Subsampling";
|
||||
projectConfig.isSubsampledEnabled = EditorGUILayout.Toggle(subsampledEnabledContent, projectConfig.isSubsampledEnabled);
|
||||
}
|
||||
}
|
||||
GUILayout.BeginHorizontal();
|
||||
guiContent.text = "System Splash Screen";
|
||||
guiContent.tooltip = "";
|
||||
EditorGUILayout.LabelField(guiContent, GUILayout.Width(165));
|
||||
projectConfig.systemSplashScreen = (Texture2D)EditorGUILayout.ObjectField(projectConfig.systemSplashScreen, typeof(Texture2D), true);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
EditorGUILayout.LabelField("Note: Set the system splash screen picture in PNG format.", firstLevelStyle);
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
var MRSafeguard = new GUIContent();
|
||||
MRSafeguard.text = "MR Safeguard";
|
||||
MRSafeguard.tooltip = "MR safety, if you choose this option, your application will adopt MR safety policies during runtime. If not selected, it will continue to use VR safety policies by default.";
|
||||
projectConfig.MRSafeguard = EditorGUILayout.Toggle(MRSafeguard, projectConfig.MRSafeguard);
|
||||
|
||||
serializedObject.Update();
|
||||
if (GUI.changed)
|
||||
{
|
||||
EditorUtility.SetDirty(projectConfig);
|
||||
}
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcd29c90e0340f14d89d51672511f326
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,37 @@
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
|
||||
|
||||
namespace Unity.XR.OpenXR.Features.PICOSupport
|
||||
{
|
||||
|
||||
[OpenXRFeatureSet(
|
||||
FeatureIds = new string[] {
|
||||
PICOFeature.featureId,
|
||||
OpenXRExtensions.featureId,
|
||||
DisplayRefreshRateFeature.featureId,
|
||||
LayerSecureContentFeature.featureId,
|
||||
FoveationFeature.featureId,
|
||||
PassthroughFeature.featureId,
|
||||
PICOSpatialMesh.featureId,
|
||||
PICOSceneCapture.featureId,
|
||||
PICOSpatialAnchor.featureId,
|
||||
},
|
||||
UiName = "PICO XR",
|
||||
Description = "Feature set for using PICO XR Features",
|
||||
FeatureSetId = featureSetId,
|
||||
SupportedBuildTargets = new BuildTargetGroup[] { BuildTargetGroup.Android},
|
||||
RequiredFeatureIds = new string[]
|
||||
{
|
||||
PICOFeature.featureId,
|
||||
OpenXRExtensions.featureId,
|
||||
}
|
||||
)]
|
||||
class PICOFeatureSet
|
||||
{
|
||||
public const string featureSetId = "com.picoxr.openxr.features";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d880f62ed1684040b6a86b50393d5f0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using UnityEngine.XR.OpenXR.Features;
|
||||
|
||||
|
||||
namespace Unity.XR.OpenXR.Features.PICOSupport
|
||||
{
|
||||
internal class PICOModifyAndroidManifest : OpenXRFeatureBuildHooks
|
||||
{
|
||||
public override int callbackOrder => 1;
|
||||
public override Type featureType => typeof(PICOFeature);
|
||||
protected override void OnPreprocessBuildExt(BuildReport report) { }
|
||||
protected override void OnPostGenerateGradleAndroidProjectExt(string path)
|
||||
{
|
||||
var androidManifest = new AndroidManifest(GetManifestPath(path));
|
||||
androidManifest.AddPICOMetaData(path);
|
||||
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 ManifestElement;
|
||||
public AndroidManifest(string path) : base(path)
|
||||
{
|
||||
ManifestElement = SelectSingleNode("/manifest") as XmlElement;
|
||||
ApplicationElement = SelectSingleNode("/manifest/application") as XmlElement;
|
||||
}
|
||||
private XmlAttribute CreateOrUpdateAndroidAttribute(string key, string value)
|
||||
{
|
||||
XmlAttribute attr = CreateAttribute("android", key, AndroidXmlNamespace);
|
||||
attr.Value = value;
|
||||
return attr;
|
||||
}
|
||||
private void CreateOrUpdateAndroidPermissionData(string name)
|
||||
{
|
||||
XmlNodeList nodeList = ManifestElement.SelectNodes("uses-permission");
|
||||
foreach (XmlNode node in nodeList)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
// Update existing nodes
|
||||
if (node.Attributes != null && name.Equals(node.Attributes[0].Value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create new node
|
||||
var md = ManifestElement.AppendChild(CreateElement("uses-permission"));
|
||||
md.Attributes.Append(CreateOrUpdateAndroidAttribute("name", name.ToString()));
|
||||
}
|
||||
|
||||
private void DeleteAndroidPermissionData(string name)
|
||||
{
|
||||
XmlNodeList nodeList = ManifestElement.SelectNodes("uses-permission");
|
||||
foreach (XmlNode node in nodeList)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
// Delete existing nodes
|
||||
if (node.Attributes != null && name.Equals(node.Attributes[0].Value))
|
||||
{
|
||||
node.ParentNode?.RemoveChild(node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateOrUpdateAndroidMetaData(string name, string value)
|
||||
{
|
||||
XmlNodeList nodeList = ApplicationElement.SelectNodes("meta-data");
|
||||
foreach (XmlNode node in nodeList)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
// Update existing nodes
|
||||
if (node.Attributes != null && name.Equals(node.Attributes[0].Value))
|
||||
{
|
||||
node.Attributes[0].Value = name;
|
||||
node.Attributes[1].Value = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create new node
|
||||
var md = ApplicationElement.AppendChild(CreateElement("meta-data"));
|
||||
md.Attributes.Append(CreateOrUpdateAndroidAttribute("name", name.ToString()));
|
||||
md.Attributes.Append(CreateOrUpdateAndroidAttribute("value", value.ToString()));
|
||||
}
|
||||
|
||||
private void DeleteAndroidMetaData(string name)
|
||||
{
|
||||
XmlNodeList nodeList = ApplicationElement.SelectNodes("meta-data");
|
||||
foreach (XmlNode node in nodeList)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
// Delete existing nodes
|
||||
if (node.Attributes != null && name.Equals(node.Attributes[0].Value))
|
||||
{
|
||||
node.ParentNode?.RemoveChild(node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void AddPICOMetaData(string path)
|
||||
{
|
||||
CreateOrUpdateAndroidMetaData("pvr.app.type", "vr");
|
||||
CreateOrUpdateAndroidMetaData("pvr.sdk.version", "Unity OpenXR "+PICOFeature.SDKVersion);
|
||||
CreateOrUpdateAndroidMetaData("pxr.sdk.version_code", "5800");
|
||||
|
||||
if (PICOProjectSetting.GetProjectConfig().isHandTracking)
|
||||
{
|
||||
CreateOrUpdateAndroidPermissionData("com.picovr.permission.HAND_TRACKING");
|
||||
CreateOrUpdateAndroidMetaData("handtracking", "1");
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteAndroidPermissionData("com.picovr.permission.HAND_TRACKING");
|
||||
DeleteAndroidMetaData("handtracking");
|
||||
}
|
||||
|
||||
if (PICOProjectSetting.GetProjectConfig().isEyeTracking)
|
||||
{
|
||||
CreateOrUpdateAndroidPermissionData("com.picovr.permission.EYE_TRACKING");
|
||||
CreateOrUpdateAndroidMetaData("picovr.software.eye_tracking", "1");
|
||||
CreateOrUpdateAndroidMetaData("eyetracking_calibration", PICOProjectSetting.GetProjectConfig().isEyeTrackingCalibration ? "true" : "false");
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteAndroidPermissionData("com.picovr.permission.EYE_TRACKING");
|
||||
DeleteAndroidMetaData("picovr.software.eye_tracking");
|
||||
DeleteAndroidMetaData("eyetracking_calibration");
|
||||
}
|
||||
|
||||
var settings = OpenXRSettings.GetSettingsForBuildTargetGroup(BuildTargetGroup.Android);
|
||||
bool mrPermission = false;
|
||||
|
||||
foreach (var feature in settings.GetFeatures<OpenXRFeature>())
|
||||
{
|
||||
|
||||
if (feature is PICOSceneCapture)
|
||||
{
|
||||
if (feature.enabled)
|
||||
{
|
||||
CreateOrUpdateAndroidMetaData("enable_scene_anchor", "1");
|
||||
|
||||
mrPermission = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteAndroidMetaData("enable_scene_anchor");
|
||||
}
|
||||
}
|
||||
|
||||
if (feature is PICOSpatialAnchor)
|
||||
{
|
||||
if (feature.enabled)
|
||||
{
|
||||
CreateOrUpdateAndroidMetaData("enable_spatial_anchor", "1");
|
||||
mrPermission = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteAndroidMetaData("enable_spatial_anchor");
|
||||
}
|
||||
}
|
||||
|
||||
if (feature is PICOSpatialMesh)
|
||||
{
|
||||
if (feature.enabled)
|
||||
{
|
||||
CreateOrUpdateAndroidMetaData("enable_mesh_anchor", "1");
|
||||
mrPermission = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteAndroidMetaData("enable_mesh_anchor");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (PICOProjectSetting.GetProjectConfig().MRSafeguard)
|
||||
{
|
||||
CreateOrUpdateAndroidMetaData("enable_mr_safeguard", PICOProjectSetting.GetProjectConfig().MRSafeguard ? "1" : "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteAndroidMetaData("enable_mr_safeguard");
|
||||
}
|
||||
|
||||
if (mrPermission)
|
||||
{
|
||||
CreateOrUpdateAndroidPermissionData("com.picovr.permission.SPATIAL_DATA");
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteAndroidPermissionData("com.picovr.permission.SPATIAL_DATA");
|
||||
}
|
||||
|
||||
CreateOrUpdateAndroidMetaData("pvr.app.splash", PICOProjectSetting.GetProjectConfig().GetSystemSplashScreen(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d81cf8af565abea45b00eecb77ab4a3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "Unity.XR.OpenXR.Features.PICOSupport.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:96aa6ba065960476598f8f643e7252b6",
|
||||
"GUID:4847341ff46394e83bb78fbd0652937e",
|
||||
"GUID:d1451cc2aec4ed743adcac8be3b46381"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.unity.xr.arfoundation",
|
||||
"expression": "5.1.2",
|
||||
"define": "AR_FOUNDATION"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfc9a0c467fa3854eb85cf2dcdebef5d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user