version 2.5.0
This commit is contained in:
@@ -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;
|
||||
@@ -12,7 +13,6 @@ using UnityEngine;
|
||||
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;
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace VIVE.OpenXR.Editor
|
||||
|
||||
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)]
|
||||
@@ -255,6 +255,10 @@ namespace VIVE.OpenXR.Editor
|
||||
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)
|
||||
@@ -279,14 +283,32 @@ namespace VIVE.OpenXR.Editor
|
||||
|
||||
foreach (var feature in settings.GetFeatures<OpenXRFeature>())
|
||||
{
|
||||
if (feature is ViveHandTracking && feature.enabled)
|
||||
if (!feature.enabled) { continue; }
|
||||
|
||||
FieldInfo fieldInfoOpenXrExtensionStrings = typeof(OpenXRFeature).GetField(
|
||||
"openxrExtensionStrings",
|
||||
BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (fieldInfoOpenXrExtensionStrings != null)
|
||||
{
|
||||
enableHandtracking = true;
|
||||
}
|
||||
if (feature is ViveFacialTracking && feature.enabled)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,15 @@ namespace VIVE.OpenXR.CompositionLayer.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;
|
||||
@@ -114,15 +123,18 @@ namespace VIVE.OpenXR.CompositionLayer.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);
|
||||
@@ -134,6 +146,7 @@ namespace VIVE.OpenXR.CompositionLayer.Editor
|
||||
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);
|
||||
@@ -311,6 +324,12 @@ namespace VIVE.OpenXR.CompositionLayer.Editor
|
||||
{
|
||||
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
|
||||
@@ -330,6 +349,8 @@ namespace VIVE.OpenXR.CompositionLayer.Editor
|
||||
if (targetCompositionLayer.texture != null)
|
||||
{
|
||||
cylinderMeshRenderer.sharedMaterial.mainTexture = targetCompositionLayer.texture;
|
||||
cylinderMeshRenderer.sharedMaterial.mainTextureOffset = srcRectLeft.position;
|
||||
cylinderMeshRenderer.sharedMaterial.mainTextureScale = srcRectLeft.size;
|
||||
}
|
||||
|
||||
//Generate Mesh
|
||||
@@ -409,6 +430,12 @@ namespace VIVE.OpenXR.CompositionLayer.Editor
|
||||
{
|
||||
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);
|
||||
@@ -430,6 +457,8 @@ namespace VIVE.OpenXR.CompositionLayer.Editor
|
||||
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);
|
||||
@@ -440,11 +469,18 @@ namespace VIVE.OpenXR.CompositionLayer.Editor
|
||||
//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();
|
||||
@@ -456,7 +492,7 @@ namespace VIVE.OpenXR.CompositionLayer.Editor
|
||||
//serializedObject.ApplyModifiedProperties();
|
||||
|
||||
//if (targetCompositionLayer.isExternalSurface)
|
||||
if (false)
|
||||
/*if (false)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
showExternalSurfaceParams = EditorGUILayout.Foldout(showExternalSurfaceParams, "External Surface Parameters");
|
||||
@@ -469,8 +505,21 @@ namespace VIVE.OpenXR.CompositionLayer.Editor
|
||||
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();
|
||||
|
||||
|
||||
166
com.htc.upm.vive.openxr/Editor/PackageManagerHelper.cs
Normal file
166
com.htc.upm.vive.openxr/Editor/PackageManagerHelper.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a00aae5e5e4790c429467d7a03b4a6de
|
||||
guid: 43952515f295bac4385e71851692047d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
8
com.htc.upm.vive.openxr/Editor/Preferences.meta
Normal file
8
com.htc.upm.vive.openxr/Editor/Preferences.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f1198e3724eb5b44a705edc6d6bae06
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright HTC Corporation All Rights Reserved.
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
namespace VIVE.OpenXR.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class PreferenceAvatarAsset : ScriptableObject
|
||||
{
|
||||
public const string AssetPath = "Assets/VIVE/OpenXR/Preferences/PreferenceAvatarAsset.asset";
|
||||
|
||||
// VRM constants
|
||||
public const string kVrm0Package = "UniVRM-0.109.0_7aff.unitypackage";
|
||||
public const string kVrm0Asset = "Assets/VRM.meta";
|
||||
public const string kVrm1Package = "VRM-0.109.0_7aff.unitypackage";
|
||||
public const string kVrm1Asset = "Assets/VRM10.meta";
|
||||
|
||||
public bool SupportVrm0 = false;
|
||||
public bool SupportVrm1 = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b048c9b388bf8d34e9814b272da7ddb5
|
||||
guid: 94f6766384418a0418eb5ebdb371be20
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,296 @@
|
||||
// Copyright HTC Corporation All Rights Reserved.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.PackageManager;
|
||||
using UnityEditor.PackageManager.Requests;
|
||||
using UnityEditor.XR.Management.Metadata;
|
||||
|
||||
namespace VIVE.OpenXR.Editor
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public static class ViveOpenXRPreference
|
||||
{
|
||||
#region Log
|
||||
static StringBuilder m_sb = null;
|
||||
static StringBuilder sb {
|
||||
get {
|
||||
if (m_sb == null) { m_sb = new StringBuilder(); }
|
||||
return m_sb;
|
||||
}
|
||||
}
|
||||
const string LOG_TAG = "VIVE.OpenXR.Editor.ViveOpenXRPreference";
|
||||
static void DEBUG(StringBuilder msg) { Debug.LogFormat("{0} {1}", LOG_TAG, msg); }
|
||||
static void ERROR(StringBuilder msg) { Debug.LogErrorFormat("{0} {1}", LOG_TAG, msg); }
|
||||
#endregion
|
||||
|
||||
static ViveOpenXRPreference()
|
||||
{
|
||||
EditorApplication.update += OnUpdate;
|
||||
}
|
||||
|
||||
#region Scripting Symbols
|
||||
internal struct ScriptingDefinedSettings
|
||||
{
|
||||
public string[] scriptingDefinedSymbols;
|
||||
public BuildTargetGroup[] targetGroups;
|
||||
|
||||
public ScriptingDefinedSettings(string[] symbols, BuildTargetGroup[] groups)
|
||||
{
|
||||
scriptingDefinedSymbols = symbols;
|
||||
targetGroups = groups;
|
||||
}
|
||||
}
|
||||
|
||||
const string DEFINE_USE_VRM_0_x = "USE_VRM_0_x";
|
||||
static readonly ScriptingDefinedSettings m_ScriptDefineSettingVrm0 = new ScriptingDefinedSettings(
|
||||
new string[] { DEFINE_USE_VRM_0_x, },
|
||||
new BuildTargetGroup[] { BuildTargetGroup.Android, }
|
||||
);
|
||||
|
||||
static void AddScriptingDefineSymbols(ScriptingDefinedSettings setting)
|
||||
{
|
||||
for (int group_index = 0; group_index < setting.targetGroups.Length; group_index++)
|
||||
{
|
||||
var group = setting.targetGroups[group_index];
|
||||
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
||||
List<string> allDefines = definesString.Split(';').ToList();
|
||||
for (int symbol_index = 0; symbol_index < setting.scriptingDefinedSymbols.Length; symbol_index++)
|
||||
{
|
||||
if (!allDefines.Contains(setting.scriptingDefinedSymbols[symbol_index]))
|
||||
{
|
||||
sb.Clear().Append("AddDefineSymbols() ").Append(setting.scriptingDefinedSymbols[symbol_index]).Append(" to group ").Append(group); DEBUG(sb);
|
||||
allDefines.Add(setting.scriptingDefinedSymbols[symbol_index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Clear().Append("AddDefineSymbols() ").Append(setting.scriptingDefinedSymbols[symbol_index]).Append(" already existed."); DEBUG(sb);
|
||||
}
|
||||
}
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(
|
||||
group,
|
||||
string.Join(";", allDefines.ToArray())
|
||||
);
|
||||
}
|
||||
}
|
||||
static void RemoveScriptingDefineSymbols(ScriptingDefinedSettings setting)
|
||||
{
|
||||
for (int group_index = 0; group_index < setting.targetGroups.Length; group_index++)
|
||||
{
|
||||
var group = setting.targetGroups[group_index];
|
||||
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
||||
List<string> allDefines = definesString.Split(';').ToList();
|
||||
for (int symbol_index = 0; symbol_index < setting.scriptingDefinedSymbols.Length; symbol_index++)
|
||||
{
|
||||
if (allDefines.Contains(setting.scriptingDefinedSymbols[symbol_index]))
|
||||
{
|
||||
sb.Clear().Append("RemoveDefineSymbols() ").Append(setting.scriptingDefinedSymbols[symbol_index]).Append(" from group ").Append(group); DEBUG(sb);
|
||||
allDefines.Remove(setting.scriptingDefinedSymbols[symbol_index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Clear().Append("RemoveDefineSymbols() ").Append(setting.scriptingDefinedSymbols[symbol_index]).Append(" already existed."); DEBUG(sb);
|
||||
}
|
||||
}
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(
|
||||
group,
|
||||
string.Join(";", allDefines.ToArray())
|
||||
);
|
||||
}
|
||||
}
|
||||
static bool HasScriptingDefineSymbols(ScriptingDefinedSettings setting)
|
||||
{
|
||||
for (int group_index = 0; group_index < setting.targetGroups.Length; group_index++)
|
||||
{
|
||||
var group = setting.targetGroups[group_index];
|
||||
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
||||
List<string> allDefines = definesString.Split(';').ToList();
|
||||
for (int symbol_index = 0; symbol_index < setting.scriptingDefinedSymbols.Length; symbol_index++)
|
||||
{
|
||||
if (!allDefines.Contains(setting.scriptingDefinedSymbols[symbol_index]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const string XR_LOADER_OPENXR_NAME = "UnityEngine.XR.OpenXR.OpenXRLoader";
|
||||
internal static bool ViveOpenXRAndroidAssigned { get { return XRPackageMetadataStore.IsLoaderAssigned(XR_LOADER_OPENXR_NAME, BuildTargetGroup.Android); } }
|
||||
|
||||
static PreferenceAvatarAsset m_AssetAvatar = null;
|
||||
static void CheckPreferenceAssets()
|
||||
{
|
||||
if (File.Exists(PreferenceAvatarAsset.AssetPath))
|
||||
{
|
||||
m_AssetAvatar = AssetDatabase.LoadAssetAtPath(PreferenceAvatarAsset.AssetPath, typeof(PreferenceAvatarAsset)) as PreferenceAvatarAsset;
|
||||
}
|
||||
else
|
||||
{
|
||||
string folderPath = PreferenceAvatarAsset.AssetPath.Substring(0, PreferenceAvatarAsset.AssetPath.LastIndexOf('/'));
|
||||
DirectoryInfo folder = Directory.CreateDirectory(folderPath);
|
||||
sb.Clear().Append("CheckPreferenceAssets() Creates folder: Assets/").Append(folder.Name); DEBUG(sb);
|
||||
|
||||
m_AssetAvatar = ScriptableObject.CreateInstance(typeof(PreferenceAvatarAsset)) as PreferenceAvatarAsset;
|
||||
m_AssetAvatar.SupportVrm0 = false;
|
||||
m_AssetAvatar.SupportVrm1 = false;
|
||||
|
||||
sb.Clear().Append("CheckPreferenceAssets() Creates the asset: ").Append(PreferenceAvatarAsset.AssetPath); DEBUG(sb);
|
||||
AssetDatabase.CreateAsset(m_AssetAvatar, PreferenceAvatarAsset.AssetPath);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnUpdate()
|
||||
{
|
||||
if (!ViveOpenXRAndroidAssigned) { return; }
|
||||
|
||||
CheckPreferenceAssets();
|
||||
|
||||
if (m_AssetAvatar)
|
||||
{
|
||||
// Adds the script symbol if VRM0 is imported.
|
||||
if (File.Exists(PreferenceAvatarAsset.kVrm0Asset))
|
||||
{
|
||||
if (!HasScriptingDefineSymbols(m_ScriptDefineSettingVrm0))
|
||||
{
|
||||
sb.Clear().Append("OnUpdate() Adds m_ScriptDefineSettingVrm0."); DEBUG(sb);
|
||||
AddScriptingDefineSymbols(m_ScriptDefineSettingVrm0);
|
||||
}
|
||||
m_AssetAvatar.SupportVrm0 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HasScriptingDefineSymbols(m_ScriptDefineSettingVrm0))
|
||||
{
|
||||
sb.Clear().Append("OnUpdate() Removes m_ScriptDefineSettingVrm0."); DEBUG(sb);
|
||||
RemoveScriptingDefineSymbols(m_ScriptDefineSettingVrm0);
|
||||
}
|
||||
m_AssetAvatar.SupportVrm0 = false;
|
||||
}
|
||||
|
||||
m_AssetAvatar.SupportVrm1 = File.Exists(PreferenceAvatarAsset.kVrm1Asset);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Preferences
|
||||
const string kPreferenceName = "VIVE OpenXR";
|
||||
private static GUIContent m_Vrm0Option = new GUIContent("VRM 0", "Avatar format.");
|
||||
private static GUIContent m_Vrm1Option = new GUIContent("VRM 1", "Avatar format.");
|
||||
|
||||
internal static void ImportModule(string packagePath, bool interactive = false)
|
||||
{
|
||||
string target = Path.Combine("Packages/com.htc.upm.vive.openxr/UnityPackages~", packagePath);
|
||||
sb.Clear().Append("ImportModule: " + target); DEBUG(sb);
|
||||
AssetDatabase.ImportPackage(target, interactive);
|
||||
}
|
||||
|
||||
static bool avatarOption = true;
|
||||
#pragma warning disable 0618
|
||||
[PreferenceItem(kPreferenceName)]
|
||||
#pragma warning restore 0618
|
||||
private static void OnPreferencesGUI()
|
||||
{
|
||||
if (EditorApplication.isCompiling)
|
||||
{
|
||||
EditorGUILayout.LabelField("Compiling...");
|
||||
return;
|
||||
}
|
||||
if (PackageManagerHelper.isAddingToList)
|
||||
{
|
||||
EditorGUILayout.LabelField("Installing packages...");
|
||||
return;
|
||||
}
|
||||
if (PackageManagerHelper.isRemovingFromList)
|
||||
{
|
||||
EditorGUILayout.LabelField("Removing packages...");
|
||||
return;
|
||||
}
|
||||
|
||||
PackageManagerHelper.PreparePackageList();
|
||||
if (PackageManagerHelper.isPreparingList)
|
||||
{
|
||||
EditorGUILayout.LabelField("Checking Packages...");
|
||||
return;
|
||||
}
|
||||
|
||||
CheckPreferenceAssets();
|
||||
|
||||
GUIStyle sectionTitleStyle = new GUIStyle(EditorStyles.label);
|
||||
sectionTitleStyle.fontSize = 16;
|
||||
sectionTitleStyle.richText = true;
|
||||
sectionTitleStyle.fontStyle = FontStyle.Bold;
|
||||
|
||||
#region Avatar
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(10);
|
||||
GUILayout.Label("Avatar", sectionTitleStyle);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUIStyle foldoutStyle = EditorStyles.foldout;
|
||||
foldoutStyle.fontSize = 14;
|
||||
foldoutStyle.fontStyle = FontStyle.Normal;
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(20);
|
||||
avatarOption = EditorGUILayout.Foldout(avatarOption, "Supported Format", foldoutStyle);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
foldoutStyle.fontSize = 12;
|
||||
foldoutStyle.fontStyle = FontStyle.Normal;
|
||||
|
||||
if (m_AssetAvatar && avatarOption)
|
||||
{
|
||||
/// VRM 0
|
||||
GUILayout.Space(5);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(35);
|
||||
if (!m_AssetAvatar.SupportVrm0)
|
||||
{
|
||||
bool toggled = EditorGUILayout.ToggleLeft(m_Vrm0Option, false, GUILayout.Width(230f));
|
||||
if (toggled)
|
||||
{
|
||||
sb.Clear().Append("OnPreferencesGUI() Adds ").Append(PreferenceAvatarAsset.kVrm0Package); DEBUG(sb);
|
||||
ImportModule(PreferenceAvatarAsset.kVrm0Package);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.ToggleLeft(m_Vrm0Option, true, GUILayout.Width(230f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
/// VRM 1
|
||||
GUILayout.Space(5);
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Space(35);
|
||||
if (!m_AssetAvatar.SupportVrm1)
|
||||
{
|
||||
bool toggled = EditorGUILayout.ToggleLeft(m_Vrm1Option, false, GUILayout.Width(230f));
|
||||
if (toggled)
|
||||
{
|
||||
sb.Clear().Append("OnPreferencesGUI() Adds ").Append(PreferenceAvatarAsset.kVrm1Package); DEBUG(sb);
|
||||
ImportModule(PreferenceAvatarAsset.kVrm1Package);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.ToggleLeft(m_Vrm1Option, true, GUILayout.Width(230f));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73bdd0b88ffae0e43a3a498347e6dea4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright HTC Corporation All Rights Reserved.
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
|
||||
namespace VIVE.OpenXR.Editor
|
||||
{
|
||||
[CustomEditor(typeof(VIVEFocus3Feature))]
|
||||
internal class VIVEFocus3FeatureEditor : UnityEditor.Editor
|
||||
{
|
||||
//private SerializedProperty enableHandTracking;
|
||||
//private SerializedProperty enableTracker;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
//enableHandTracking = serializedObject.FindProperty("enableHandTracking");
|
||||
//enableTracker = serializedObject.FindProperty("enableTracker");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
//EditorGUILayout.PropertyField(enableHandTracking);
|
||||
//EditorGUILayout.PropertyField(enableTracker);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
24
com.htc.upm.vive.openxr/Editor/ViveAnchorEditor.cs
Normal file
24
com.htc.upm.vive.openxr/Editor/ViveAnchorEditor.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright HTC Corporation All Rights Reserved.
|
||||
using UnityEditor;
|
||||
using VIVE.OpenXR.Feature;
|
||||
|
||||
namespace VIVE.OpenXR.Editor
|
||||
{
|
||||
[CustomEditor(typeof(ViveAnchor))]
|
||||
internal class ViveAnchorEditor : UnityEditor.Editor
|
||||
{
|
||||
private SerializedProperty enablePersistedAnchor;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
enablePersistedAnchor = serializedObject.FindProperty("enablePersistedAnchor");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(enablePersistedAnchor);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
com.htc.upm.vive.openxr/Editor/ViveAnchorEditor.cs.meta
Normal file
11
com.htc.upm.vive.openxr/Editor/ViveAnchorEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9094698271e2abb4ab295256548772c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
com.htc.upm.vive.openxr/Editor/ViveMenu.cs
Normal file
44
com.htc.upm.vive.openxr/Editor/ViveMenu.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright HTC Corporation All Rights Reserved.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
|
||||
namespace VIVE.OpenXR.Editor
|
||||
{
|
||||
public class ViveMenu : UnityEditor.Editor
|
||||
{
|
||||
private const string kMenuXR = "VIVE/XR/Convert Main Camera to ViveRig";
|
||||
|
||||
[MenuItem(kMenuXR, priority = 101)]
|
||||
private static void ConvertToViveRig()
|
||||
{
|
||||
// 1. Removes default Camera
|
||||
Camera cam = FindObjectOfType<Camera>();
|
||||
if (cam != null && cam.transform.parent == null)
|
||||
{
|
||||
Debug.Log("ConvertToViveRig() remove " + cam.gameObject.name);
|
||||
DestroyImmediate(cam.gameObject);
|
||||
}
|
||||
|
||||
// 2. Loads ViveRig
|
||||
if (GameObject.Find("ViveRig") == null && GameObject.Find("ViveRig(Clone)") == null)
|
||||
{
|
||||
GameObject prefab = Resources.Load<GameObject>("Prefabs/ViveRig");
|
||||
if (prefab != null)
|
||||
{
|
||||
Debug.Log("ConvertToViveRig() load " + prefab.name);
|
||||
GameObject inst = Instantiate(prefab, null);
|
||||
if (inst != null)
|
||||
{
|
||||
inst.name = "ViveRig";
|
||||
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
com.htc.upm.vive.openxr/Editor/ViveMenu.cs.meta
Normal file
11
com.htc.upm.vive.openxr/Editor/ViveMenu.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f78968df8bc5794393fb2016e223a6c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
com.htc.upm.vive.openxr/Editor/ViveMockRuntimeEditor.cs
Normal file
64
com.htc.upm.vive.openxr/Editor/ViveMockRuntimeEditor.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright HTC Corporation All Rights Reserved.
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VIVE.OpenXR.Feature;
|
||||
|
||||
namespace VIVE.OpenXR.Editor
|
||||
{
|
||||
[CustomEditor(typeof(ViveMockRuntime))]
|
||||
internal class ViveMockRuntimeEditor : UnityEditor.Editor
|
||||
{
|
||||
private SerializedProperty enableFuture;
|
||||
private SerializedProperty enableAnchor;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
enableFuture = serializedObject.FindProperty("enableFuture");
|
||||
enableAnchor = serializedObject.FindProperty("enableAnchor");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
// Show a text field for description
|
||||
EditorGUILayout.HelpBox("VIVE's mock runtime. Used with OpenXR MockRuntime to test unsupported extensions and features on Editor.", MessageType.Info);
|
||||
|
||||
if (GUILayout.Button("Install MockRuntime Library")) {
|
||||
InstallMockRuntimeLibrary();
|
||||
}
|
||||
|
||||
// check if changed
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(enableFuture);
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
if (!enableFuture.boolValue) {
|
||||
enableAnchor.boolValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(enableAnchor);
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
if (enableAnchor.boolValue) {
|
||||
enableFuture.boolValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
public void InstallMockRuntimeLibrary() {
|
||||
string sourcePathName = "Packages/com.htc.upm.vive.openxr/MockRuntime~/Win64/ViveMockRuntime.dll";
|
||||
string destPath = "Assets/Plugins/Win64";
|
||||
string destPathName = "Assets/Plugins/Win64/ViveMockRuntime.dll";
|
||||
|
||||
// check if the folder exists. If not, create it.
|
||||
if (!System.IO.Directory.Exists(destPath)) {
|
||||
System.IO.Directory.CreateDirectory(destPath);
|
||||
}
|
||||
|
||||
FileUtil.CopyFileOrDirectory(sourcePathName, destPathName);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
com.htc.upm.vive.openxr/Editor/ViveMockRuntimeEditor.cs.meta
Normal file
11
com.htc.upm.vive.openxr/Editor/ViveMockRuntimeEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eedb4211aafd2cb4bae86fcc0e948f72
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,135 +0,0 @@
|
||||
// Copyright HTC Corporation All Rights Reserved.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.XR.Management.Metadata;
|
||||
|
||||
namespace VIVE.OpenXR.Editor
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public static class CheckIfVIVEEnabled
|
||||
{
|
||||
const string LOG_TAG = "VIVE.OpenXR.Editor.CheckIfVIVEEnabled";
|
||||
static void DEBUG(string msg) { Debug.Log(LOG_TAG + " " + msg); }
|
||||
const string VERSION_DEFINE_OPENXR = "USE_VIVE_OPENXR_1_0_0";
|
||||
internal struct ScriptingDefinedSettings
|
||||
{
|
||||
public string[] scriptingDefinedSymbols;
|
||||
public BuildTargetGroup[] targetGroups;
|
||||
|
||||
public ScriptingDefinedSettings(string[] symbols, BuildTargetGroup[] groups)
|
||||
{
|
||||
scriptingDefinedSymbols = symbols;
|
||||
targetGroups = groups;
|
||||
}
|
||||
}
|
||||
static readonly ScriptingDefinedSettings m_ScriptDefineSettingOpenXRAndroid = new ScriptingDefinedSettings(
|
||||
new string[] { VERSION_DEFINE_OPENXR, },
|
||||
new BuildTargetGroup[] { BuildTargetGroup.Android, }
|
||||
);
|
||||
const string XR_LOADER_OPENXR_NAME = "UnityEngine.XR.OpenXR.OpenXRLoader";
|
||||
internal static bool ViveOpenXRAndroidAssigned { get { return XRPackageMetadataStore.IsLoaderAssigned(XR_LOADER_OPENXR_NAME, BuildTargetGroup.Android); } }
|
||||
static void AddScriptingDefineSymbols(ScriptingDefinedSettings setting)
|
||||
{
|
||||
for (int group_index = 0; group_index < setting.targetGroups.Length; group_index++)
|
||||
{
|
||||
var group = setting.targetGroups[group_index];
|
||||
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
||||
List<string> allDefines = definesString.Split(';').ToList();
|
||||
for (int symbol_index = 0; symbol_index < setting.scriptingDefinedSymbols.Length; symbol_index++)
|
||||
{
|
||||
if (!allDefines.Contains(setting.scriptingDefinedSymbols[symbol_index]))
|
||||
{
|
||||
DEBUG("AddDefineSymbols() " + setting.scriptingDefinedSymbols[symbol_index] + " to group " + group);
|
||||
allDefines.Add(setting.scriptingDefinedSymbols[symbol_index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG("AddDefineSymbols() " + setting.scriptingDefinedSymbols[symbol_index] + " already existed.");
|
||||
}
|
||||
}
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(
|
||||
group,
|
||||
string.Join(";", allDefines.ToArray())
|
||||
);
|
||||
}
|
||||
}
|
||||
static void RemoveScriptingDefineSymbols(ScriptingDefinedSettings setting)
|
||||
{
|
||||
for (int group_index = 0; group_index < setting.targetGroups.Length; group_index++)
|
||||
{
|
||||
var group = setting.targetGroups[group_index];
|
||||
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
||||
List<string> allDefines = definesString.Split(';').ToList();
|
||||
for (int symbol_index = 0; symbol_index < setting.scriptingDefinedSymbols.Length; symbol_index++)
|
||||
{
|
||||
if (allDefines.Contains(setting.scriptingDefinedSymbols[symbol_index]))
|
||||
{
|
||||
DEBUG("RemoveDefineSymbols() " + setting.scriptingDefinedSymbols[symbol_index] + " from group " + group);
|
||||
allDefines.Remove(setting.scriptingDefinedSymbols[symbol_index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG("RemoveDefineSymbols() " + setting.scriptingDefinedSymbols[symbol_index] + " already existed.");
|
||||
}
|
||||
}
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(
|
||||
group,
|
||||
string.Join(";", allDefines.ToArray())
|
||||
);
|
||||
}
|
||||
}
|
||||
static bool HasScriptingDefineSymbols(ScriptingDefinedSettings setting)
|
||||
{
|
||||
for (int group_index = 0; group_index < setting.targetGroups.Length; group_index++)
|
||||
{
|
||||
var group = setting.targetGroups[group_index];
|
||||
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);
|
||||
List<string> allDefines = definesString.Split(';').ToList();
|
||||
for (int symbol_index = 0; symbol_index < setting.scriptingDefinedSymbols.Length; symbol_index++)
|
||||
{
|
||||
if (!allDefines.Contains(setting.scriptingDefinedSymbols[symbol_index]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
static void CheckScriptingDefineSymbols()
|
||||
{
|
||||
// Adds the script symbol if Vive OpenXR Plugin - Android is imported and assigned in XR Plugin-in Management.
|
||||
if (ViveOpenXRAndroidAssigned)
|
||||
{
|
||||
if (!HasScriptingDefineSymbols(m_ScriptDefineSettingOpenXRAndroid))
|
||||
{
|
||||
DEBUG("OnUpdate() Adds m_ScriptDefineSettingOpenXRAndroid.");
|
||||
AddScriptingDefineSymbols(m_ScriptDefineSettingOpenXRAndroid);
|
||||
}
|
||||
}
|
||||
// Removes the script symbol if Vive OpenXR Plugin - Android is uninstalled.
|
||||
else
|
||||
{
|
||||
if (HasScriptingDefineSymbols(m_ScriptDefineSettingOpenXRAndroid))
|
||||
{
|
||||
DEBUG("OnUpdate() Removes m_ScriptDefineSettingOpenXRAndroid.");
|
||||
RemoveScriptingDefineSymbols(m_ScriptDefineSettingOpenXRAndroid);
|
||||
}
|
||||
}
|
||||
}
|
||||
static void OnUpdate()
|
||||
{
|
||||
//CheckScriptingDefineSymbols();
|
||||
}
|
||||
static CheckIfVIVEEnabled()
|
||||
{
|
||||
EditorApplication.update += OnUpdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -19,14 +19,27 @@ namespace VIVE.OpenXR
|
||||
"vive.openxr.feature.foveation",
|
||||
FacialTracking.ViveFacialTracking.featureId,
|
||||
PlaneDetection.VivePlaneDetection.featureId,
|
||||
Anchor.ViveAnchor.featureId,
|
||||
VivePathEnumeration.featureId,
|
||||
Feature.ViveAnchor.featureId,
|
||||
DisplayRefreshRate.ViveDisplayRefreshRate.featureId,
|
||||
Passthrough.VivePassthrough.featureId,
|
||||
FirstPersonObserver.ViveFirstPersonObserver.FeatureId,
|
||||
SecondaryViewConfiguration.ViveSecondaryViewConfiguration.FeatureId,
|
||||
UserPresence.ViveUserPresence.featureId,
|
||||
CompositionLayer.ViveCompositionLayerExtraSettings.featureId,
|
||||
FrameSynchronization.ViveFrameSynchronization.featureId,
|
||||
EyeTracker.ViveEyeTracker.featureId,
|
||||
Feature.ViveMockRuntime.featureId,
|
||||
Interaction.ViveInteractions.featureId,
|
||||
},
|
||||
UiName = "VIVE XR Support",
|
||||
Description = "Necessary to deploy an VIVE XR compatible app.",
|
||||
FeatureSetId = "com.htc.vive.openxr.featureset.vivexr",
|
||||
#if UNITY_ANDROID
|
||||
DefaultFeatureIds = new string[] { VIVEFocus3Feature.featureId, VIVEFocus3Profile.featureId, },
|
||||
SupportedBuildTargets = new BuildTargetGroup[] { BuildTargetGroup.Android }
|
||||
#endif
|
||||
SupportedBuildTargets = new BuildTargetGroup[] { BuildTargetGroup.Android, BuildTargetGroup.Standalone }
|
||||
)]
|
||||
sealed class VIVEFocus3FeatureSet { }
|
||||
sealed class ViveOpenXRFeatureSet { }
|
||||
}
|
||||
#endif
|
||||
81
com.htc.upm.vive.openxr/Editor/ViveSpectatorCameraProcess.cs
Normal file
81
com.htc.upm.vive.openxr/Editor/ViveSpectatorCameraProcess.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
using UnityEngine.XR.OpenXR.Features;
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using static VIVE.OpenXR.VIVEFocus3Feature;
|
||||
|
||||
namespace VIVE.OpenXR.Editor
|
||||
{
|
||||
public class ViveSpectatorCameraProcess : OpenXRFeatureBuildHooks
|
||||
{
|
||||
public override int callbackOrder => 1;
|
||||
|
||||
public override Type featureType => typeof(VIVEFocus3Feature);
|
||||
|
||||
/// <summary>
|
||||
/// Enable or disable the "First Person Observer" extension according to the Spectator Camera Feature.
|
||||
/// </summary>
|
||||
/// <param name="enable">Type True if Spectator Camera Feature is enabled. Otherwise, type False.</param>
|
||||
private static void SetFirstPersonObserver(in bool enable)
|
||||
{
|
||||
var settings = OpenXRSettings.GetSettingsForBuildTargetGroup(BuildTargetGroup.Android);
|
||||
|
||||
foreach (OpenXRFeature feature in settings.GetFeatures<OpenXRFeature>())
|
||||
{
|
||||
FieldInfo fieldInfoOpenXrExtensionStrings = typeof(OpenXRFeature).GetField(
|
||||
"openxrExtensionStrings",
|
||||
BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (fieldInfoOpenXrExtensionStrings != null)
|
||||
{
|
||||
var openXrExtensionStringsArray =
|
||||
((string)fieldInfoOpenXrExtensionStrings.GetValue(feature)).Split(' ');
|
||||
|
||||
foreach (var stringItem in openXrExtensionStringsArray)
|
||||
{
|
||||
if (string.IsNullOrEmpty(stringItem))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!string.Equals(stringItem, FirstPersonObserver.ViveFirstPersonObserver.OPEN_XR_EXTENSION_STRING))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
feature.enabled = enable;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region The callbacks during the build process when your OpenXR Extension is enabled.
|
||||
|
||||
protected override void OnPreprocessBuildExt(BuildReport report)
|
||||
{
|
||||
if (IsViveSpectatorCameraEnabled())
|
||||
{
|
||||
SetFirstPersonObserver(true);
|
||||
UnityEngine.Debug.Log("Enable \"First Person Observer\" extension due to the Spectator Camera Feature.");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFirstPersonObserver(false);
|
||||
UnityEngine.Debug.Log("Disable \"First Person Observer\" extension because Spectator Camera Feature is closed.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPostGenerateGradleAndroidProjectExt(string path)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnPostprocessBuildExt(BuildReport report)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fcb7e5a984acb64bb9221b9b05c0517
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user