Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
40 changes: 31 additions & 9 deletions com.htc.upm.vive.openxr/Editor/AndroidManifestProcess.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright HTC Corporation All Rights Reserved.
using System;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Xml;
Expand All @@ -12,7 +13,6 @@
using UnityEngine.XR.OpenXR;
using UnityEngine.XR.OpenXR.Features;
using UnityEngine.XR.OpenXR.Features.Interactions;
using VIVE.OpenXR.FacialTracking;
using VIVE.OpenXR.Hand;
using VIVE.OpenXR.Tracker;

Expand Down Expand Up @@ -152,7 +152,7 @@ public static void PerformAction(bool enabled)

m_IsEnabled = enabled;

sb.Clear().Append(LOG_TAG).Append(m_IsEnabled ? "Enable " : "Disable ").Append("Simultaneous Interaction."); DEBUG(sb);
//sb.Clear().Append(LOG_TAG).Append(m_IsEnabled ? "Enable " : "Disable ").Append("Simultaneous Interaction."); DEBUG(sb);
}

[MenuItem(MENU_NAME, validate = true, priority = 601)]
Expand Down Expand Up @@ -255,6 +255,10 @@ internal void AddOpenXRFeatures()
bool enableTracker = false;
bool enableEyetracking = false;
bool enableLipexpression = false;
const string kHandTrackingExtension = "XR_EXT_hand_tracking";
const string kFacialTrackingExtension = "XR_HTC_facial_tracking";
const string kHandInteractionHTC = "XR_HTC_hand_interaction";
const string kHandInteractionEXT = "XR_EXT_hand_interaction";

var settings = OpenXRSettings.GetSettingsForBuildTargetGroup(BuildTargetGroup.Android);
if (null == settings)
Expand All @@ -279,14 +283,32 @@ internal void AddOpenXRFeatures()

foreach (var feature in settings.GetFeatures<OpenXRFeature>())
{
if (feature is ViveHandTracking && feature.enabled)
{
enableHandtracking = true;
}
if (feature is ViveFacialTracking && feature.enabled)
if (!feature.enabled) { continue; }

FieldInfo fieldInfoOpenXrExtensionStrings = typeof(OpenXRFeature).GetField(
"openxrExtensionStrings",
BindingFlags.NonPublic | BindingFlags.Instance);
if (fieldInfoOpenXrExtensionStrings != null)
{
enableEyetracking = true;
enableLipexpression = true;
var openXrExtensionStringsArray =
((string)fieldInfoOpenXrExtensionStrings.GetValue(feature)).Split(' ');

foreach (string stringItem in openXrExtensionStringsArray)
{
if (string.IsNullOrEmpty(stringItem)) { continue; }

if (stringItem.Equals(kHandTrackingExtension) ||
stringItem.Equals(kHandInteractionHTC) ||
stringItem.Equals(kHandInteractionEXT))
{
enableHandtracking = true;
}
if (stringItem.Equals(kFacialTrackingExtension))
{
enableEyetracking = true;
enableLipexpression = true;
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ public class CompositionLayerEditor : Editor
static GUIContent Label_IsDynamicLayer = new GUIContent("Dynamic Layer", "Specify whether Layer needs to be updated each frame or not.");
SerializedProperty Property_IsDynamicLayer;

static string PropertyName_IsCustomRects = "isCustomRects";
static GUIContent Label_IsCustomRects = new GUIContent("Customize Rects", "Using a single texture as a stereo image");
SerializedProperty Property_IsCustomRects;

static string PropertyName_CustomRects = "customRects";
static GUIContent Label_CustomRects = new GUIContent("Customize Rects Type", "Specify the customize rects type of the left texture.");
SerializedProperty Property_CustomRects;


static string PropertyName_ApplyColorScaleBias = "applyColorScaleBias";
static GUIContent Label_ApplyColorScaleBias = new GUIContent("Apply Color Scale Bias", "Color scale and bias are applied to a layer color during composition, after its conversion to premultiplied alpha representation. LayerColor = LayerColor * colorScale + colorBias");
SerializedProperty Property_ApplyColorScaleBias;
Expand Down Expand Up @@ -114,15 +123,18 @@ public class CompositionLayerEditor : Editor

private bool showLayerParams = true, showColorScaleBiasParams = true;

private bool showExternalSurfaceParams = false;

//private bool showExternalSurfaceParams = false;

Rect FullRect = new Rect(0, 0, 1, 1);
Rect LeftRightRect = new Rect(0, 0, 0.5f, 1);
Rect TopDownRect = new Rect(0, 0.5f, 1, 0.5f);
public override void OnInspectorGUI()
{
if (Property_LayerType == null) Property_LayerType = serializedObject.FindProperty(PropertyName_LayerType);
if (Property_CompositionDepth == null) Property_CompositionDepth = serializedObject.FindProperty(PropertyName_CompositionDepth);
if (Property_LayerShape == null) Property_LayerShape = serializedObject.FindProperty(PropertyName_LayerShape);
if (Property_LayerVisibility == null) Property_LayerVisibility = serializedObject.FindProperty(PropertyName_LayerVisibility);
if (Property_CustomRects == null) Property_CustomRects = serializedObject.FindProperty(PropertyName_CustomRects);
if (Property_LockMode == null) Property_LockMode = serializedObject.FindProperty(PropertyName_LockMode);
if (Property_QuadWidth == null) Property_QuadWidth = serializedObject.FindProperty(PropertyName_QuadWidth);
if (Property_QuadHeight == null) Property_QuadHeight = serializedObject.FindProperty(PropertyName_QuadHeight);
Expand All @@ -134,6 +146,7 @@ public override void OnInspectorGUI()
if (Property_ExternalSurfaceWidth == null) Property_ExternalSurfaceWidth = serializedObject.FindProperty(PropertyName_ExternalSurfaceWidth);
if (Property_ExternalSurfaceHeight == null) Property_ExternalSurfaceHeight = serializedObject.FindProperty(PropertyName_ExternalSurfaceHeight);
if (Property_IsDynamicLayer == null) Property_IsDynamicLayer = serializedObject.FindProperty(PropertyName_IsDynamicLayer);
if (Property_IsCustomRects == null) Property_IsCustomRects = serializedObject.FindProperty(PropertyName_IsCustomRects);
if (Property_ApplyColorScaleBias == null) Property_ApplyColorScaleBias = serializedObject.FindProperty(PropertyName_ApplyColorScaleBias);
if (Property_SolidEffect == null) Property_SolidEffect = serializedObject.FindProperty(PropertyName_SolidEffect);
if (Property_ColorScale == null) Property_ColorScale = serializedObject.FindProperty(PropertyName_ColorScale);
Expand Down Expand Up @@ -311,6 +324,12 @@ public override void OnInspectorGUI()
{
if (GUILayout.Button("Show Cylinder Preview"))
{
Rect srcRectLeft = FullRect;
if (targetCompositionLayer.isCustomRects && targetCompositionLayer.customRects == CompositionLayer.CustomRectsType.LeftRight)
srcRectLeft = LeftRightRect;
if (targetCompositionLayer.isCustomRects && targetCompositionLayer.customRects == CompositionLayer.CustomRectsType.TopDown)
srcRectLeft = TopDownRect;

targetCompositionLayer.isPreviewingCylinder = true;
Vector3[] cylinderVertices = CompositionLayer.MeshGenerationHelper.GenerateCylinderVertex(targetCompositionLayer.CylinderAngleOfArc, targetCompositionLayer.CylinderRadius, targetCompositionLayer.CylinderHeight);
//Add components to Game Object
Expand All @@ -330,6 +349,8 @@ public override void OnInspectorGUI()
if (targetCompositionLayer.texture != null)
{
cylinderMeshRenderer.sharedMaterial.mainTexture = targetCompositionLayer.texture;
cylinderMeshRenderer.sharedMaterial.mainTextureOffset = srcRectLeft.position;
cylinderMeshRenderer.sharedMaterial.mainTextureScale = srcRectLeft.size;
}

//Generate Mesh
Expand Down Expand Up @@ -409,6 +430,12 @@ public override void OnInspectorGUI()
{
if (GUILayout.Button("Show Quad Preview"))
{
Rect srcRectLeft = FullRect;
if (targetCompositionLayer.isCustomRects && targetCompositionLayer.customRects == CompositionLayer.CustomRectsType.LeftRight)
srcRectLeft = LeftRightRect;
if (targetCompositionLayer.isCustomRects && targetCompositionLayer.customRects == CompositionLayer.CustomRectsType.TopDown)
srcRectLeft = TopDownRect;

targetCompositionLayer.isPreviewingQuad = true;
//Generate vertices
Vector3[] quadVertices = CompositionLayer.MeshGenerationHelper.GenerateQuadVertex(targetCompositionLayer.quadWidth, targetCompositionLayer.quadHeight);
Expand All @@ -430,6 +457,8 @@ public override void OnInspectorGUI()
if (targetCompositionLayer.texture != null)
{
quadMeshRenderer.sharedMaterial.mainTexture = targetCompositionLayer.texture;
quadMeshRenderer.sharedMaterial.mainTextureOffset = srcRectLeft.position;
quadMeshRenderer.sharedMaterial.mainTextureScale = srcRectLeft.size;
}
//Generate Mesh
quadMeshFilter.mesh = CompositionLayer.MeshGenerationHelper.GenerateQuadMesh(quadVertices);
Expand All @@ -440,11 +469,18 @@ public override void OnInspectorGUI()
//Rect UI For textures
Rect labelRect = EditorGUILayout.GetControlRect();

EditorGUI.LabelField(new Rect(labelRect.x, labelRect.y, labelRect.width / 2, labelRect.height), new GUIContent("Texture", "Texture to be rendered on the layer"));
EditorGUI.LabelField(new Rect(labelRect.x, labelRect.y, labelRect.width / 2, labelRect.height), new GUIContent("Left Texture", "Texture used for the left eye"));
EditorGUI.LabelField(new Rect(labelRect.x + labelRect.width / 2, labelRect.y, labelRect.width / 2, labelRect.height), new GUIContent("Right Texture", "Texture used for the right eye"));

Rect textureRect = EditorGUILayout.GetControlRect(GUILayout.Height(64));

targetCompositionLayer.texture = (Texture)EditorGUI.ObjectField(new Rect(textureRect.x, textureRect.y, 64, textureRect.height), targetCompositionLayer.texture, typeof(Texture), true);
targetCompositionLayer.textureRight = (Texture)EditorGUI.ObjectField(new Rect(textureRect.x + textureRect.width / 2, textureRect.y, 64, textureRect.height), targetCompositionLayer.textureRight, typeof(Texture), true);
if (null == targetCompositionLayer.textureLeft)
{
targetCompositionLayer.texture = targetCompositionLayer.textureRight;
//myScript.textures[1] = right;
}

EditorGUILayout.PropertyField(Property_LayerVisibility, new GUIContent(Label_LayerVisibility));
serializedObject.ApplyModifiedProperties();
Expand All @@ -456,7 +492,7 @@ public override void OnInspectorGUI()
//serializedObject.ApplyModifiedProperties();

//if (targetCompositionLayer.isExternalSurface)
if (false)
/*if (false)
{
EditorGUI.indentLevel++;
showExternalSurfaceParams = EditorGUILayout.Foldout(showExternalSurfaceParams, "External Surface Parameters");
Expand All @@ -469,8 +505,21 @@ public override void OnInspectorGUI()
serializedObject.ApplyModifiedProperties();
}
EditorGUI.indentLevel--;
}*/

if (targetCompositionLayer.textureLeft == targetCompositionLayer.textureRight || targetCompositionLayer.textureRight == null)
{
EditorGUILayout.PropertyField(Property_IsCustomRects, Label_IsCustomRects);
serializedObject.ApplyModifiedProperties();
}

if (targetCompositionLayer.isCustomRects)
{
EditorGUILayout.PropertyField(Property_CustomRects, new GUIContent(Label_CustomRects));
serializedObject.ApplyModifiedProperties();
}

EditorGUILayout.Space();
EditorGUILayout.PropertyField(Property_ApplyColorScaleBias, Label_ApplyColorScaleBias);
serializedObject.ApplyModifiedProperties();

Expand Down
166 changes: 166 additions & 0 deletions com.htc.upm.vive.openxr/Editor/PackageManagerHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// Copyright HTC Corporation All Rights Reserved.

using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
using UnityEngine;

public static class PackageManagerHelper
{
private static bool s_wasPreparing;
private static bool m_wasAdded;
private static bool s_wasRemoved;
private static ListRequest m_listRequest;
private static AddRequest m_addRequest;
private static RemoveRequest m_removeRequest;
private static string s_fallbackIdentifier;

public static bool isPreparingList
{
get
{
if (m_listRequest == null) { return s_wasPreparing = true; }

switch (m_listRequest.Status)
{
case StatusCode.InProgress:
return s_wasPreparing = true;
case StatusCode.Failure:
if (!s_wasPreparing)
{
Debug.LogError("Something wrong when adding package to list. error:" + m_listRequest.Error.errorCode + "(" + m_listRequest.Error.message + ")");
}
break;
case StatusCode.Success:
break;
}

return s_wasPreparing = false;
}
}

public static bool isAddingToList
{
get
{
if (m_addRequest == null) { return m_wasAdded = false; }

switch (m_addRequest.Status)
{
case StatusCode.InProgress:
return m_wasAdded = true;
case StatusCode.Failure:
if (!m_wasAdded)
{
AddRequest request = m_addRequest;
m_addRequest = null;
if (string.IsNullOrEmpty(s_fallbackIdentifier))
{
Debug.LogError("Something wrong when adding package to list. error:" + request.Error.errorCode + "(" + request.Error.message + ")");
}
else
{
Debug.Log("Failed to install package: \"" + request.Error.message + "\". Retry with fallback identifier \"" + s_fallbackIdentifier + "\"");
AddToPackageList(s_fallbackIdentifier);
}

s_fallbackIdentifier = null;
}
break;
case StatusCode.Success:
if (!m_wasAdded)
{
m_addRequest = null;
s_fallbackIdentifier = null;
ResetPackageList();
}
break;
}

return m_wasAdded = false;
}
}

public static bool isRemovingFromList
{
get
{
if (m_removeRequest == null) { return s_wasRemoved = false; }

switch (m_removeRequest.Status)
{
case StatusCode.InProgress:
return s_wasRemoved = true;
case StatusCode.Failure:
if (!s_wasRemoved)
{
var request = m_removeRequest;
m_removeRequest = null;
Debug.LogError("Something wrong when removing package from list. error:" + m_removeRequest.Error.errorCode + "(" + m_removeRequest.Error.message + ")");
}
break;
case StatusCode.Success:
if (!s_wasRemoved)
{
m_removeRequest = null;
ResetPackageList();
}
break;
}

return s_wasRemoved = false;
}
}

public static void PreparePackageList()
{
if (m_listRequest != null) { return; }
m_listRequest = Client.List(true, true);
}

public static void ResetPackageList()
{
s_wasPreparing = false;
m_listRequest = null;
}

public static bool IsPackageInList(string name, out UnityEditor.PackageManager.PackageInfo packageInfo)
{
packageInfo = null;
if (m_listRequest == null || m_listRequest.Result == null) return false;

foreach (var package in m_listRequest.Result)
{
if (package.name.Equals(name))
{
packageInfo = package;
return true;
}
}
return false;
}

public static void AddToPackageList(string identifier, string fallbackIdentifier = null)
{
Debug.Assert(m_addRequest == null);

m_addRequest = Client.Add(identifier);
s_fallbackIdentifier = fallbackIdentifier;
}

public static void RemovePackage(string identifier)
{
Debug.Assert(m_removeRequest == null);

m_removeRequest = Client.Remove(identifier);
}

public static PackageCollection GetPackageList()
{
if (m_listRequest == null || m_listRequest.Result == null)
{
return null;
}

return m_listRequest.Result;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading