Add ultimate xr
This commit is contained in:
8
Assets/UltimateXR/Editor/Sdks/InputTracking.meta
Normal file
8
Assets/UltimateXR/Editor/Sdks/InputTracking.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80a407967dfa23b4fac5a6f16025432c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="SteamVRActionsExporter.ButtonUsageFlags.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.InputTracking
|
||||
{
|
||||
public static partial class SteamVRActionsExporter
|
||||
{
|
||||
#region Private Types & Data
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates the possible button interaction types.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
private enum ButtonUsageFlags
|
||||
{
|
||||
None = 0,
|
||||
Click = 1,
|
||||
Touch = 1 << 1,
|
||||
All = 0x7FFFFFFF
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17dc027d2f2240d4a5a9e20a8ac418d5
|
||||
timeCreated: 1643734986
|
||||
@@ -0,0 +1,28 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="SteamVRActionsExporter.SideFlags.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.InputTracking
|
||||
{
|
||||
public static partial class SteamVRActionsExporter
|
||||
{
|
||||
#region Private Types & Data
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates the different sides supported by controller elements.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
private enum SideFlags
|
||||
{
|
||||
None = 0,
|
||||
Left = 1,
|
||||
Right = 1 << 1,
|
||||
BothSides = Left | Right
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7a4a5048ce345dabdee78225ba2abe5
|
||||
timeCreated: 1643734994
|
||||
@@ -0,0 +1,843 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="SteamVRActionsExporter.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
#if ULTIMATEXR_USE_STEAMVR_SDK
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UltimateXR.Core;
|
||||
using UltimateXR.Core.Settings;
|
||||
using UltimateXR.Devices;
|
||||
using UltimateXR.Devices.Integrations.SteamVR;
|
||||
using UltimateXR.Extensions.System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Valve.Newtonsoft.Json;
|
||||
using Valve.VR;
|
||||
#endif
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.InputTracking
|
||||
{
|
||||
#if ULTIMATEXR_USE_STEAMVR_SDK
|
||||
/// <summary>
|
||||
/// Class with functionality to create and remove the required SteamVR actions to interface with UltimateXR.
|
||||
/// </summary>
|
||||
public static partial class SteamVRActionsExporter
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// If SteamVR has the actions already set up, checks if UltimateXR actions need to be setup.
|
||||
/// </summary>
|
||||
/// <returns>True if SteamVR actions are present but UltimateXR custom actions are missing</returns>
|
||||
public static bool NeedsActionsSetup()
|
||||
{
|
||||
if (SteamVR_Input.DoesActionsFileExist() && SteamVR_Input.actionFile != null && SteamVR_Input.actionFile.action_sets != null)
|
||||
{
|
||||
// Action set registered?
|
||||
|
||||
SteamVR_Input_ActionFile_ActionSet actionSet = SteamVR_Input.actionFile.action_sets.FirstOrDefault(a => a.name == ActionSetName);
|
||||
|
||||
if (actionSet == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!string.Equals(actionSet.usage, SteamVR_Input_ActionFile_ActionSet_Usages.single))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// All actions registered?
|
||||
|
||||
foreach (SteamVR_Input_ActionFile_Action action in EnumerateCustomActionsToBeAdded(actionSet))
|
||||
{
|
||||
if (!IsActionPresent(actionSet, action))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to set up UltimateXR SteamVR actions to interface with the input system.
|
||||
/// </summary>
|
||||
public static void TrySetupActions()
|
||||
{
|
||||
if (SteamVR_Input.DoesActionsFileExist())
|
||||
{
|
||||
// Action file not loaded?
|
||||
|
||||
if (SteamVR_Input.actionFile == null)
|
||||
{
|
||||
SteamVR_Input.InitializeFile(false, false);
|
||||
}
|
||||
|
||||
// Only process if SteamVR actions are available
|
||||
|
||||
if (SteamVR_Input.actionFile != null && SteamVR_Input.actionFile.action_sets != null)
|
||||
{
|
||||
// Try to find our action set
|
||||
|
||||
SteamVR_Input_ActionFile_ActionSet actionSet = SteamVR_Input.actionFile.action_sets.FirstOrDefault(a => a.name == ActionSetName);
|
||||
|
||||
// If not present, create:
|
||||
|
||||
if (actionSet == null)
|
||||
{
|
||||
actionSet = new SteamVR_Input_ActionFile_ActionSet
|
||||
{
|
||||
name = ActionSetName,
|
||||
usage = SteamVR_Input_ActionFile_ActionSet_Usages.single
|
||||
};
|
||||
|
||||
SteamVR_Input.actionFile.action_sets.Add(actionSet);
|
||||
}
|
||||
else
|
||||
{
|
||||
actionSet.usage = SteamVR_Input_ActionFile_ActionSet_Usages.single;
|
||||
}
|
||||
|
||||
// Clear list and add actions. This will remove deprecated actions in the future.
|
||||
|
||||
actionSet.actionsInList = new List<SteamVR_Input_ActionFile_Action>();
|
||||
actionSet.actionsOutList = new List<SteamVR_Input_ActionFile_Action>();
|
||||
|
||||
foreach (SteamVR_Input_ActionFile_Action action in EnumerateCustomActionsToBeAdded(actionSet))
|
||||
{
|
||||
if (!IsActionPresent(actionSet, action))
|
||||
{
|
||||
if (action.direction == SteamVR_ActionDirections.In)
|
||||
{
|
||||
actionSet.actionsInList.Add(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
actionSet.actionsOutList.Add(action);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UxrGlobalSettings.Instance.LogLevelDevices >= UxrLogLevel.Warnings)
|
||||
{
|
||||
Debug.LogWarning($"{UxrConstants.DevicesModule}: Warning. Action {action.name} already exists. Skipping...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate bindings
|
||||
|
||||
TryGenerateBindings();
|
||||
|
||||
// Save at the end
|
||||
|
||||
EditorApplication.delayCall += SaveSteamVRActions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to remove SteamVR actions to interface with the UltimateXR input system.
|
||||
/// </summary>
|
||||
public static void TryRemoveActions()
|
||||
{
|
||||
if (SteamVR_Input.DoesActionsFileExist())
|
||||
{
|
||||
// Action file not loaded?
|
||||
|
||||
if (SteamVR_Input.actionFile == null)
|
||||
{
|
||||
SteamVR_Input.InitializeFile(false, false);
|
||||
}
|
||||
|
||||
// Only process if SteamVR actions are available
|
||||
|
||||
if (SteamVR_Input.actionFile != null && SteamVR_Input.actionFile.action_sets != null)
|
||||
{
|
||||
// Try to find action set and remove it.
|
||||
// TODO: SteamVR has a bug where the action set is not removed but at least the actions are
|
||||
|
||||
int index = SteamVR_Input.actionFile.action_sets.FindIndex(a => a.name == ActionSetName);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
SteamVR_Input.actionFile.action_sets.RemoveAt(index);
|
||||
EditorApplication.delayCall += SaveSteamVRActions;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Saves the SteamVR actions to disk.
|
||||
/// </summary>
|
||||
private static void SaveSteamVRActions()
|
||||
{
|
||||
SteamVR_Input.actionFile.SaveHelperLists();
|
||||
SteamVR_Input.actionFile.Save(SteamVR_Input.GetActionsFilePath());
|
||||
SteamVR_Input_ActionManifest_Manager.CleanBindings(true);
|
||||
SteamVR_Input_Generator.BeginGeneration();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if an action is present in a SteamVR action set.
|
||||
/// </summary>
|
||||
/// <param name="actionSet">Action set to process</param>
|
||||
/// <param name="action">Action to look for</param>
|
||||
/// <returns>True if the action was found</returns>
|
||||
private static bool IsActionPresent(SteamVR_Input_ActionFile_ActionSet actionSet, SteamVR_Input_ActionFile_Action action)
|
||||
{
|
||||
if (action.direction == SteamVR_ActionDirections.In)
|
||||
{
|
||||
SteamVR_Input_ActionFile_Action existingAction = actionSet.actionsInList.FirstOrDefault(a => string.Equals(a.name, action.name));
|
||||
return existingAction != null && existingAction.Equals(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
SteamVR_Input_ActionFile_Action existingAction = actionSet.actionsOutList.FirstOrDefault(a => string.Equals(a.name, action.name));
|
||||
return existingAction != null && existingAction.Equals(action);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates all the SteamVR actions that need to be added in order to translate SteamVR input to UltimateXR input.
|
||||
/// </summary>
|
||||
/// <param name="actionSet">Action set that the actions will belong to</param>
|
||||
/// <returns>Enumerable collection with required SteamVR actions</returns>
|
||||
private static IEnumerable<SteamVR_Input_ActionFile_Action> EnumerateCustomActionsToBeAdded(SteamVR_Input_ActionFile_ActionSet actionSet)
|
||||
{
|
||||
// Buttons
|
||||
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Joystick);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Joystick2);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Trigger);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Trigger2);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Grip);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Button1);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Button2);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Button3);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Button4);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Bumper);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Bumper2);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Back);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.Menu);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.ThumbCapSense);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.IndexCapSense);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.MiddleCapSense);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.RingCapSense);
|
||||
yield return GetNewActionButtonClick(actionSet, UxrInputButtons.LittleCapSense);
|
||||
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Joystick);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Joystick2);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Trigger);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Trigger2);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Grip);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Button1);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Button2);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Button3);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Button4);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Bumper);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Bumper2);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Back);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.Menu);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.ThumbCapSense);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.IndexCapSense);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.MiddleCapSense);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.RingCapSense);
|
||||
yield return GetNewActionButtonTouch(actionSet, UxrInputButtons.LittleCapSense);
|
||||
|
||||
// UxrInput1D
|
||||
|
||||
yield return GetNewAction(actionSet, UxrInput1D.Grip.ToString(), SteamVR_ActionDirections.In, UxrSteamVRConstants.BindingVarVector1);
|
||||
yield return GetNewAction(actionSet, UxrInput1D.Trigger.ToString(), SteamVR_ActionDirections.In, UxrSteamVRConstants.BindingVarVector1);
|
||||
yield return GetNewAction(actionSet, UxrInput1D.Trigger2.ToString(), SteamVR_ActionDirections.In, UxrSteamVRConstants.BindingVarVector1);
|
||||
|
||||
// UxrInput2D
|
||||
|
||||
yield return GetNewAction(actionSet, UxrInput2D.Joystick.ToString(), SteamVR_ActionDirections.In, UxrSteamVRConstants.BindingVarVector2);
|
||||
yield return GetNewAction(actionSet, UxrInput2D.Joystick2.ToString(), SteamVR_ActionDirections.In, UxrSteamVRConstants.BindingVarVector2);
|
||||
|
||||
// Hand skeletons
|
||||
|
||||
yield return GetNewActionSkeleton(actionSet, UxrSteamVRConstants.ActionNameHandSkeletonLeft, true);
|
||||
yield return GetNewActionSkeleton(actionSet, UxrSteamVRConstants.ActionNameHandSkeletonRight, false);
|
||||
|
||||
// Haptic feedback
|
||||
|
||||
yield return GetNewActionHaptic(actionSet, UxrSteamVRConstants.ActionNameHandHaptics);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new SteamVR action object.
|
||||
/// </summary>
|
||||
/// <param name="actionSet">Action set this action will belong to</param>
|
||||
/// <param name="actionName">Action name</param>
|
||||
/// <param name="direction">Input or output action?</param>
|
||||
/// <param name="varType">Variable type associated to the action</param>
|
||||
/// <returns>New SteamVR action object</returns>
|
||||
private static SteamVR_Input_ActionFile_Action GetNewAction(SteamVR_Input_ActionFile_ActionSet actionSet, string actionName, SteamVR_ActionDirections direction, string varType)
|
||||
{
|
||||
SteamVR_Input_ActionFile_Action action = new SteamVR_Input_ActionFile_Action
|
||||
{
|
||||
name = SteamVR_Input_ActionFile_Action.CreateNewName(actionSet.shortName, direction, actionName.ToLower()) + "_" + varType,
|
||||
type = varType,
|
||||
requirement = SteamVR_Input_ActionFile_Action_Requirements.optional.ToString()
|
||||
};
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simplified method to create a new SteamVR action object for a button click.
|
||||
/// </summary>
|
||||
/// <param name="actionSet">Action set this action will belong to</param>
|
||||
/// <param name="button">Button to generate action for</param>
|
||||
/// <returns>Action object representing the action of a button click</returns>
|
||||
private static SteamVR_Input_ActionFile_Action GetNewActionButtonClick(SteamVR_Input_ActionFile_ActionSet actionSet, UxrInputButtons button)
|
||||
{
|
||||
return GetNewAction(actionSet, $"{button}_{UxrSteamVRConstants.BindingInputClick}", SteamVR_ActionDirections.In, UxrSteamVRConstants.BindingVarBool);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simplified method to create a new SteamVR action object for a button touch.
|
||||
/// </summary>
|
||||
/// <param name="actionSet">Action set this action will belong to</param>
|
||||
/// <param name="button">Button to generate action for</param>
|
||||
/// <returns>Action object representing the action of a button touch</returns>
|
||||
private static SteamVR_Input_ActionFile_Action GetNewActionButtonTouch(SteamVR_Input_ActionFile_ActionSet actionSet, UxrInputButtons button)
|
||||
{
|
||||
return GetNewAction(actionSet, $"{button}_{UxrSteamVRConstants.BindingInputTouch}", SteamVR_ActionDirections.In, UxrSteamVRConstants.BindingVarBool);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simplified method to create a new SteamVR action object for skeleton tracking.
|
||||
/// </summary>
|
||||
/// <param name="actionSet">Action set this action will belong to</param>
|
||||
/// <param name="actionName">Name of the action</param>
|
||||
/// <param name="isLeft">Is it for the left hand or right hand?</param>
|
||||
/// <returns>Action object representing the action of hand skeleton tracking</returns>
|
||||
private static SteamVR_Input_ActionFile_Action GetNewActionSkeleton(SteamVR_Input_ActionFile_ActionSet actionSet, string actionName, bool isLeft)
|
||||
{
|
||||
SteamVR_Input_ActionFile_Action action = new SteamVR_Input_ActionFile_Action
|
||||
{
|
||||
name = SteamVR_Input_ActionFile_Action.CreateNewName(actionSet.shortName, SteamVR_ActionDirections.In, actionName),
|
||||
type = SteamVR_Input_ActionFile_ActionTypes.skeleton,
|
||||
skeleton = SteamVR_Input_ActionFile_ActionTypes.listSkeletons[isLeft ? 0 : 1].Replace("\\", "/"),
|
||||
requirement = SteamVR_Input_ActionFile_Action_Requirements.optional.ToString()
|
||||
};
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simplified method to create a new SteamVR action object for haptic feedback.
|
||||
/// </summary>
|
||||
/// <param name="actionSet">Action set this action will belong to</param>
|
||||
/// <param name="actionName">Name of the action</param>
|
||||
/// <returns>Action object representing the action</returns>
|
||||
private static SteamVR_Input_ActionFile_Action GetNewActionHaptic(SteamVR_Input_ActionFile_ActionSet actionSet, string actionName)
|
||||
{
|
||||
SteamVR_Input_ActionFile_Action action = new SteamVR_Input_ActionFile_Action
|
||||
{
|
||||
name = SteamVR_Input_ActionFile_Action.CreateNewName(actionSet.shortName, SteamVR_ActionDirections.Out, actionName),
|
||||
type = SteamVR_Input_ActionFile_ActionTypes.vibration
|
||||
};
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Tries to generate bindings for all the registered SteamVR binding files.
|
||||
/// Files are deserialized, processed and if necessary changes are saved back to disk.
|
||||
/// </summary>
|
||||
private static void TryGenerateBindings()
|
||||
{
|
||||
// Iterate over binding files
|
||||
|
||||
foreach (SteamVR_Input_ActionFile_DefaultBinding binding in SteamVR_Input.actionFile.default_bindings)
|
||||
{
|
||||
// Compose full path
|
||||
|
||||
string bindingsFilePath = PathExt.Combine(SteamVR_Input.GetActionsFileFolder(), binding.binding_url);
|
||||
|
||||
if (File.Exists(bindingsFilePath))
|
||||
{
|
||||
// Try to process
|
||||
|
||||
try
|
||||
{
|
||||
SteamVR_Input_BindingFile bindingFile = JsonConvert.DeserializeObject<SteamVR_Input_BindingFile>(File.ReadAllText(bindingsFilePath));
|
||||
|
||||
// Find action list from our action set. If it's not present, create it:
|
||||
|
||||
if (!bindingFile.bindings.TryGetValue(ActionSetName, out SteamVR_Input_BindingFile_ActionList actionList))
|
||||
{
|
||||
actionList = new SteamVR_Input_BindingFile_ActionList();
|
||||
bindingFile.bindings.Add(ActionSetName, actionList);
|
||||
}
|
||||
|
||||
// Reset data
|
||||
|
||||
actionList.sources.Clear();
|
||||
actionList.skeleton.Clear();
|
||||
actionList.haptics.Clear();
|
||||
|
||||
// Try to process it. If it's been modified we need to save it back.
|
||||
|
||||
bool modified = false;
|
||||
|
||||
switch (bindingFile.controller_type)
|
||||
{
|
||||
case BindingControllerTypeOculusTouch:
|
||||
modified = GenerateBindingsControllerOculusTouch(actionList);
|
||||
break;
|
||||
|
||||
case BindingControllerTypeHtcVive:
|
||||
modified = GenerateBindingsControllerHtcVive(actionList);
|
||||
break;
|
||||
|
||||
case BindingControllerTypeHtcViveCosmos:
|
||||
modified = GenerateBindingsControllerHtcViveCosmos(actionList);
|
||||
break;
|
||||
|
||||
case BindingControllerTypeValveKnuckles:
|
||||
modified = GenerateBindingsControllerValveKnuckles(actionList);
|
||||
break;
|
||||
|
||||
case BindingControllerTypeWindowsMixedReality:
|
||||
modified = GenerateBindingsControllerWindowsMixedReality(actionList);
|
||||
break;
|
||||
}
|
||||
|
||||
// Haptics, which are common
|
||||
|
||||
if (modified)
|
||||
{
|
||||
AddHapticsBindings(actionList);
|
||||
}
|
||||
|
||||
// Need to Save?
|
||||
|
||||
if (modified)
|
||||
{
|
||||
File.WriteAllText(bindingsFilePath, JsonConvert.SerializeObject(bindingFile, Formatting.Indented));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (UxrGlobalSettings.Instance.LogLevelDevices >= UxrLogLevel.Errors)
|
||||
{
|
||||
Debug.LogError($"{UxrConstants.DevicesModule}: Error creating custom bindings to {nameof(SteamVR_Input_BindingFile)} in {bindingsFilePath} : {e.Message}, {e.StackTrace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates necessary custom bindings for the Oculus Touch controllers.
|
||||
/// </summary>
|
||||
/// <param name="actionList">The action list to register the bindings in</param>
|
||||
/// <returns>True if the action list was modified</returns>
|
||||
private static bool GenerateBindingsControllerOculusTouch(SteamVR_Input_BindingFile_ActionList actionList)
|
||||
{
|
||||
AddButtonBindings(actionList.sources, "system", UxrInputButtons.Menu, SideFlags.Left, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "x", UxrInputButtons.Button1, SideFlags.Left, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "y", UxrInputButtons.Button2, SideFlags.Left, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "a", UxrInputButtons.Button1, SideFlags.Right, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "b", UxrInputButtons.Button2, SideFlags.Right, ButtonUsageFlags.All);
|
||||
AddVector2Bindings(actionList.sources, "joystick", BindingModeJoystick, UxrInput2D.Joystick, UxrInputButtons.Joystick, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddVector1Bindings(actionList.sources, "grip", UxrInput1D.Grip, UxrInputButtons.Grip, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddVector1Bindings(actionList.sources, "trigger", UxrInput1D.Trigger, UxrInputButtons.Trigger, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates necessary custom bindings for the HTC Vive controllers.
|
||||
/// </summary>
|
||||
/// <param name="actionList">The action list to register the bindings in</param>
|
||||
/// <returns>True if the action list was modified</returns>
|
||||
private static bool GenerateBindingsControllerHtcVive(SteamVR_Input_BindingFile_ActionList actionList)
|
||||
{
|
||||
AddButtonBindings(actionList.sources, "menu", UxrInputButtons.Menu, SideFlags.BothSides, ButtonUsageFlags.Click);
|
||||
AddButtonBindings(actionList.sources, "grip", UxrInputButtons.Grip, SideFlags.BothSides, ButtonUsageFlags.Click);
|
||||
AddVector2Bindings(actionList.sources, "trackpad", BindingModeTrackpad, UxrInput2D.Joystick, UxrInputButtons.Joystick, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddVector1Bindings(actionList.sources, "trigger", UxrInput1D.Trigger, UxrInputButtons.Trigger, SideFlags.BothSides, ButtonUsageFlags.Click);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates necessary custom bindings for the HTC Vive Cosmos controllers.
|
||||
/// </summary>
|
||||
/// <param name="actionList">The action list to register the bindings in</param>
|
||||
/// <returns>True if the action list was modified</returns>
|
||||
private static bool GenerateBindingsControllerHtcViveCosmos(SteamVR_Input_BindingFile_ActionList actionList)
|
||||
{
|
||||
AddButtonBindings(actionList.sources, "system", UxrInputButtons.Menu, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "x", UxrInputButtons.Button1, SideFlags.Left, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "y", UxrInputButtons.Button2, SideFlags.Left, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "a", UxrInputButtons.Button1, SideFlags.Right, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "b", UxrInputButtons.Button2, SideFlags.Right, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "bumper", UxrInputButtons.Bumper, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddVector2Bindings(actionList.sources, "joystick", BindingModeJoystick, UxrInput2D.Joystick, UxrInputButtons.Joystick, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddVector1Bindings(actionList.sources, "grip", UxrInput1D.Grip, UxrInputButtons.Grip, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddVector1Bindings(actionList.sources, "trigger", UxrInput1D.Trigger, UxrInputButtons.Trigger, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates necessary custom bindings for the Valve Knuckles controllers.
|
||||
/// </summary>
|
||||
/// <param name="actionList">The action list to register the bindings in</param>
|
||||
/// <returns>True if the action list was modified</returns>
|
||||
private static bool GenerateBindingsControllerValveKnuckles(SteamVR_Input_BindingFile_ActionList actionList)
|
||||
{
|
||||
AddButtonBindings(actionList.sources, "system", UxrInputButtons.Menu, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "a", UxrInputButtons.Button1, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddButtonBindings(actionList.sources, "b", UxrInputButtons.Button2, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddVector2Bindings(actionList.sources, "thumbstick", BindingModeJoystick, UxrInput2D.Joystick, UxrInputButtons.Joystick, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddVector2Bindings(actionList.sources, "trackpad", BindingModeJoystick, UxrInput2D.Joystick2, UxrInputButtons.Joystick2, SideFlags.BothSides, ButtonUsageFlags.Touch);
|
||||
AddVector1Bindings(actionList.sources, "grip", UxrInput1D.Grip, UxrInputButtons.Grip, SideFlags.BothSides, ButtonUsageFlags.Touch);
|
||||
AddVector1Bindings(actionList.sources, "trigger", UxrInput1D.Trigger, UxrInputButtons.Trigger, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
|
||||
AddSkeletalBindings(actionList);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates necessary custom bindings for the Windows Mixed Reality controllers.
|
||||
/// </summary>
|
||||
/// <param name="actionList">The action list to register the bindings in</param>
|
||||
/// <returns>True if the action list was modified</returns>
|
||||
private static bool GenerateBindingsControllerWindowsMixedReality(SteamVR_Input_BindingFile_ActionList actionList)
|
||||
{
|
||||
AddButtonBindings(actionList.sources, "menu", UxrInputButtons.Menu, SideFlags.BothSides, ButtonUsageFlags.Click);
|
||||
AddButtonBindings(actionList.sources, "grip", UxrInputButtons.Button1, SideFlags.BothSides, ButtonUsageFlags.Click);
|
||||
AddVector2Bindings(actionList.sources, "joystick", BindingModeJoystick, UxrInput2D.Joystick, UxrInputButtons.Joystick, SideFlags.BothSides, ButtonUsageFlags.Click);
|
||||
AddVector2Bindings(actionList.sources, "trackpad", BindingModeJoystick, UxrInput2D.Joystick2, UxrInputButtons.Joystick2, SideFlags.BothSides, ButtonUsageFlags.All);
|
||||
AddVector1Bindings(actionList.sources, "trigger", UxrInput1D.Trigger, UxrInputButtons.Trigger, SideFlags.BothSides, ButtonUsageFlags.None);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds necessary binding information for a controller button.
|
||||
/// </summary>
|
||||
/// <param name="sources">List to add the necessary information to</param>
|
||||
/// <param name="deviceElement">Name of the device button in SteamVR to generate the binding for</param>
|
||||
/// <param name="button">UltimateXR button that it will be mapped to</param>
|
||||
/// <param name="sideFlags">
|
||||
/// Flags telling which sides need to be registered. Some buttons may be
|
||||
/// available for both sides, some only for one side (menu, system...)
|
||||
/// </param>
|
||||
/// <param name="usageFlags">Which actions to register (click, touch...)</param>
|
||||
private static void AddButtonBindings(List<SteamVR_Input_BindingFile_Source> sources,
|
||||
string deviceElement,
|
||||
UxrInputButtons button,
|
||||
SideFlags sideFlags,
|
||||
ButtonUsageFlags usageFlags)
|
||||
{
|
||||
if (sideFlags.HasFlag(SideFlags.Left))
|
||||
{
|
||||
sources.Add(GetControllerButtonBindingSource(deviceElement, BindingLeft, button, usageFlags));
|
||||
}
|
||||
|
||||
if (sideFlags.HasFlag(SideFlags.Right))
|
||||
{
|
||||
sources.Add(GetControllerButtonBindingSource(deviceElement, BindingRight, button, usageFlags));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds necessary binding information for a vector1 controller element, which also can be used as a button.
|
||||
/// </summary>
|
||||
/// <param name="sources">List to add the necessary information to</param>
|
||||
/// <param name="deviceElement">Name of the device element in SteamVR to generate the binding for</param>
|
||||
/// <param name="input1D">The UltimateXR 1D controller that it will be mapped to</param>
|
||||
/// <param name="button">UltimateXR button that it will be mapped to</param>
|
||||
/// <param name="sideFlags">
|
||||
/// Flags telling which sides need to be registered. Some buttons may be available for both sides,
|
||||
/// some only for one side
|
||||
/// </param>
|
||||
/// <param name="buttonUsageFlags">Which actions to register (click, touch...)</param>
|
||||
private static void AddVector1Bindings(List<SteamVR_Input_BindingFile_Source> sources,
|
||||
string deviceElement,
|
||||
UxrInput1D input1D,
|
||||
UxrInputButtons button,
|
||||
SideFlags sideFlags,
|
||||
ButtonUsageFlags buttonUsageFlags)
|
||||
{
|
||||
if (sideFlags.HasFlag(SideFlags.Left))
|
||||
{
|
||||
// Create button
|
||||
|
||||
SteamVR_Input_BindingFile_Source source = GetControllerButtonBindingSource(deviceElement, BindingLeft, button, buttonUsageFlags);
|
||||
|
||||
// Override mode with trigger and add trigger action
|
||||
|
||||
source.mode = BindingModeTrigger;
|
||||
source.inputs.Add(BindingInputPull, GetVector1BindingDictionary(input1D));
|
||||
sources.Add(source);
|
||||
}
|
||||
|
||||
if (sideFlags.HasFlag(SideFlags.Right))
|
||||
{
|
||||
// Create button
|
||||
|
||||
SteamVR_Input_BindingFile_Source source = GetControllerButtonBindingSource(deviceElement, BindingRight, button, buttonUsageFlags);
|
||||
|
||||
// Override mode with trigger and add trigger action
|
||||
|
||||
source.mode = BindingModeTrigger;
|
||||
source.inputs.Add(BindingInputPull, GetVector1BindingDictionary(input1D));
|
||||
sources.Add(source);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds necessary binding information for a vector2 controller element, which also can be used as a button.
|
||||
/// </summary>
|
||||
/// <param name="sources">List to add the necessary information to</param>
|
||||
/// <param name="deviceElement">Name of the device element in SteamVR to generate the binding for</param>
|
||||
/// <param name="bindingMode">Input bindingMode (trackpad, joystick). Use string constants!</param>
|
||||
/// <param name="input2D">The UltimateXR 2D controller that it will be mapped to</param>
|
||||
/// <param name="button">UltimateXR button that it will be mapped to</param>
|
||||
/// <param name="sideFlags">
|
||||
/// Flags telling which sides need to be registered. Some buttons may be available for both sides,
|
||||
/// some only for one side
|
||||
/// </param>
|
||||
/// <param name="buttonUsageFlags">Which actions to register (click, touch...)</param>
|
||||
private static void AddVector2Bindings(List<SteamVR_Input_BindingFile_Source> sources,
|
||||
string deviceElement,
|
||||
string bindingMode,
|
||||
UxrInput2D input2D,
|
||||
UxrInputButtons button,
|
||||
SideFlags sideFlags,
|
||||
ButtonUsageFlags buttonUsageFlags)
|
||||
{
|
||||
if (sideFlags.HasFlag(SideFlags.Left))
|
||||
{
|
||||
// Create button
|
||||
|
||||
SteamVR_Input_BindingFile_Source source = GetControllerButtonBindingSource(deviceElement, BindingLeft, button, buttonUsageFlags);
|
||||
|
||||
// Override mode and add position action
|
||||
|
||||
source.mode = bindingMode;
|
||||
source.inputs.Add(BindingInputPosition, GetVector2BindingDictionary(input2D));
|
||||
sources.Add(source);
|
||||
}
|
||||
|
||||
if (sideFlags.HasFlag(SideFlags.Right))
|
||||
{
|
||||
// Create button
|
||||
|
||||
SteamVR_Input_BindingFile_Source source = GetControllerButtonBindingSource(deviceElement, BindingRight, button, buttonUsageFlags);
|
||||
|
||||
// Override mode and add position action
|
||||
|
||||
source.mode = bindingMode;
|
||||
source.inputs.Add(BindingInputPosition, GetVector2BindingDictionary(input2D));
|
||||
sources.Add(source);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the skeleton bindings to the given action list. This will enable access to skeleton data.
|
||||
/// </summary>
|
||||
/// <param name="actionList">Action list to add the bindings to</param>
|
||||
private static void AddSkeletalBindings(SteamVR_Input_BindingFile_ActionList actionList)
|
||||
{
|
||||
actionList.skeleton.Add(new SteamVR_Input_BindingFile_Skeleton
|
||||
{
|
||||
output = $"/actions/{UxrSteamVRConstants.ActionSetName}/in/{UxrSteamVRConstants.ActionNameHandSkeletonLeft}",
|
||||
path = BindingSkeletonPathLeft
|
||||
});
|
||||
|
||||
actionList.skeleton.Add(new SteamVR_Input_BindingFile_Skeleton
|
||||
{
|
||||
output = $"/actions/{UxrSteamVRConstants.ActionSetName}/in/{UxrSteamVRConstants.ActionNameHandSkeletonRight}",
|
||||
path = BindingSkeletonPathRight
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the haptic bindings to the given action list. This will enable sending haptic feedback.
|
||||
/// </summary>
|
||||
/// <param name="actionList">Action list to add the bindings to</param>
|
||||
private static void AddHapticsBindings(SteamVR_Input_BindingFile_ActionList actionList)
|
||||
{
|
||||
actionList.haptics.Add(new SteamVR_Input_BindingFile_Haptic
|
||||
{
|
||||
output = $"/actions/{UxrSteamVRConstants.ActionSetName}/out/{UxrSteamVRConstants.ActionNameHandHaptics}",
|
||||
path = BindingHapticsPathLeft
|
||||
});
|
||||
|
||||
actionList.haptics.Add(new SteamVR_Input_BindingFile_Haptic
|
||||
{
|
||||
output = $"/actions/{UxrSteamVRConstants.ActionSetName}/out/{UxrSteamVRConstants.ActionNameHandHaptics}",
|
||||
path = BindingHapticsPathRight
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="SteamVR_Input_BindingFile_Source" /> object describing a binding for a specific SteamVR
|
||||
/// controller button of one side, to an well-known action.
|
||||
/// </summary>
|
||||
/// <param name="deviceElement">SteamVR device element name</param>
|
||||
/// <param name="side">Left or right side. Use string constants.</param>
|
||||
/// <param name="button">UltimateXR button mapped to</param>
|
||||
/// <param name="usageFlags">Which actions to register (click, touch...)</param>
|
||||
/// <returns><see cref="SteamVR_Input_BindingFile_Source" /> object</returns>
|
||||
private static SteamVR_Input_BindingFile_Source GetControllerButtonBindingSource(string deviceElement,
|
||||
string side,
|
||||
UxrInputButtons button,
|
||||
ButtonUsageFlags usageFlags)
|
||||
{
|
||||
SteamVR_Input_BindingFile_Source source = new SteamVR_Input_BindingFile_Source
|
||||
{
|
||||
path = GetControllerBindingSourcePath(side, deviceElement),
|
||||
mode = BindingModeButton
|
||||
};
|
||||
|
||||
if (usageFlags.HasFlag(ButtonUsageFlags.Click))
|
||||
{
|
||||
source.inputs.Add(UxrSteamVRConstants.BindingInputClick, GetButtonBindingDictionary(button, UxrSteamVRConstants.BindingInputClick));
|
||||
}
|
||||
|
||||
if (usageFlags.HasFlag(ButtonUsageFlags.Touch))
|
||||
{
|
||||
source.inputs.Add(UxrSteamVRConstants.BindingInputTouch, GetButtonBindingDictionary(button, UxrSteamVRConstants.BindingInputTouch));
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string that can be used as a path to a given SteamVR device element.
|
||||
/// </summary>
|
||||
/// <param name="side">Left or right side. Use string constants.</param>
|
||||
/// <param name="deviceElement">The SteamVR controller element name</param>
|
||||
/// <returns>Full path that can be used in a <see cref="SteamVR_Input_BindingFile_Source" /> object</returns>
|
||||
private static string GetControllerBindingSourcePath(string side, string deviceElement)
|
||||
{
|
||||
return $"/user/hand/{side}/input/{deviceElement}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string that describes a path to a given button action.
|
||||
/// </summary>
|
||||
/// <param name="button">UltimateXR button that the action will be mapped to</param>
|
||||
/// <param name="inputType">The type of input (click, touch...)</param>
|
||||
/// <returns>Full action path</returns>
|
||||
private static string GetControllerBindingOutputButton(UxrInputButtons button, string inputType)
|
||||
{
|
||||
return $"/actions/{UxrSteamVRConstants.ActionSetName}/in/{button.ToString().ToLower()}_{inputType}_{UxrSteamVRConstants.BindingVarBool}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string that describes a path to a given vector1 action.
|
||||
/// </summary>
|
||||
/// <param name="input1D">UltimateXR input1D that the action will be mapped to</param>
|
||||
/// <returns>Full action path</returns>
|
||||
private static string GetControllerBindingOutputInput1D(UxrInput1D input1D)
|
||||
{
|
||||
return $"/actions/{UxrSteamVRConstants.ActionSetName}/in/{input1D.ToString().ToLower()}_{UxrSteamVRConstants.BindingVarVector1}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a string that describes a path to a given vector2 action.
|
||||
/// </summary>
|
||||
/// <param name="input2D">UltimateXR input2D that the action will be mapped to</param>
|
||||
/// <returns>Full action path</returns>
|
||||
private static string GetControllerBindingOutputInput2D(UxrInput2D input2D)
|
||||
{
|
||||
return $"/actions/{UxrSteamVRConstants.ActionSetName}/in/{input2D.ToString().ToLower()}_{UxrSteamVRConstants.BindingVarVector2}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a dictionary describing a button input type to an action.
|
||||
/// </summary>
|
||||
/// <param name="button">UltimateXR button to map</param>
|
||||
/// <param name="inputType">Input type (click, touch...)</param>
|
||||
/// <returns>Dictionary describing the mapping</returns>
|
||||
private static SteamVR_Input_BindingFile_Source_Input_StringDictionary GetButtonBindingDictionary(UxrInputButtons button, string inputType)
|
||||
{
|
||||
return new SteamVR_Input_BindingFile_Source_Input_StringDictionary
|
||||
{
|
||||
{ BindingOutput, GetControllerBindingOutputButton(button, inputType) }
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a dictionary describing a vector1 type to an action.
|
||||
/// </summary>
|
||||
/// <param name="input1D">UltimateXR input1D to map</param>
|
||||
/// <returns>Dictionary describing the mapping</returns>
|
||||
private static SteamVR_Input_BindingFile_Source_Input_StringDictionary GetVector1BindingDictionary(UxrInput1D input1D)
|
||||
{
|
||||
return new SteamVR_Input_BindingFile_Source_Input_StringDictionary
|
||||
{
|
||||
{ BindingOutput, GetControllerBindingOutputInput1D(input1D) }
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a dictionary describing a vector2 type to an action.
|
||||
/// </summary>
|
||||
/// <param name="input2D">UltimateXR input2D to map</param>
|
||||
/// <returns>Dictionary describing the mapping</returns>
|
||||
private static SteamVR_Input_BindingFile_Source_Input_StringDictionary GetVector2BindingDictionary(UxrInput2D input2D)
|
||||
{
|
||||
return new SteamVR_Input_BindingFile_Source_Input_StringDictionary
|
||||
{
|
||||
{ BindingOutput, GetControllerBindingOutputInput2D(input2D) }
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Types & Data
|
||||
|
||||
private const string ActionSetName = "/actions/" + UxrSteamVRConstants.ActionSetName;
|
||||
private const string BindingModeButton = "button";
|
||||
private const string BindingModeTrigger = "trigger";
|
||||
private const string BindingModeTrackpad = "trackpad";
|
||||
private const string BindingModeJoystick = "joystick";
|
||||
private const string BindingInputPull = "pull";
|
||||
private const string BindingInputPosition = "position";
|
||||
private const string BindingLeft = "left";
|
||||
private const string BindingRight = "right";
|
||||
private const string BindingOutput = "output";
|
||||
private const string BindingSkeletonPathLeft = "/user/hand/left/input/skeleton/left";
|
||||
private const string BindingSkeletonPathRight = "/user/hand/right/input/skeleton/right";
|
||||
private const string BindingHapticsPathLeft = "/user/hand/left/output/haptic";
|
||||
private const string BindingHapticsPathRight = "/user/hand/right/output/haptic";
|
||||
private const string BindingControllerTypeOculusTouch = "oculus_touch";
|
||||
private const string BindingControllerTypeHtcVive = "vive_controller";
|
||||
private const string BindingControllerTypeHtcViveCosmos = "vive_cosmos_controller";
|
||||
private const string BindingControllerTypeValveKnuckles = "knuckles";
|
||||
private const string BindingControllerTypeWindowsMixedReality = "holographic_controller";
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endif // ULTIMATEXR_USE_STEAMVR_SDK
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a090c84ea1019d041973dee3eb82f068
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,121 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorMagicLeap.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.InputTracking
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the Magic Leap SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorMagicLeap : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.InputTracking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string PackageName => "com.magicleap.unitysdk";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkMagicLeap;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2022.2";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_MAGICLEAP_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_MAGICLEAP_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
|
||||
if (EditorUserBuildSettings.activeBuildTarget is BuildTarget.Android or BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64)
|
||||
{
|
||||
// UltimateXR assembly already sets up version define for the Magic Leap package
|
||||
#if ULTIMATEXR_USE_MAGICLEAP_SDK
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
#else
|
||||
CurrentState = State.NotInstalled;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentState = State.CurrentTargetNotSupported;
|
||||
}
|
||||
#else
|
||||
CurrentState = State.NeedsHigherUnityVersion;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://developer-docs.magicleap.cloud/docs/guides/unity/getting-started/install-the-tools");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorMagicLeap());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksInputTracking + "Remove Symbols for Magic Leap SDK", priority = UxrConstants.Editor.PriorityMenuPathSdksInputTracking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorMagicLeap());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7e62f5f1f8c8b6469005fd2dd08fa0d
|
||||
timeCreated: 1516622924
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
113
Assets/UltimateXR/Editor/Sdks/InputTracking/UxrSdkLocatorOvr.cs
Normal file
113
Assets/UltimateXR/Editor/Sdks/InputTracking/UxrSdkLocatorOvr.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorOvr.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.InputTracking
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for Oculus' SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorOvr : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.InputTracking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkOculus;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2021.1";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_OCULUS_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_OCULUS_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
if (EditorUserBuildSettings.activeBuildTarget is BuildTarget.Android or BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64)
|
||||
{
|
||||
CurrentState = State.NotInstalled;
|
||||
|
||||
if (IsTypeInAssemblies("OVRManager"))
|
||||
{
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentState = State.CurrentTargetNotSupported;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("Install integration?", $"Oculus integration asset needs to be installed. Proceed to the Asset Store?", UxrConstants.Editor.Yes, UxrConstants.Editor.Cancel))
|
||||
{
|
||||
Application.OpenURL("https://assetstore.unity.com/packages/tools/integration/oculus-integration-82022");
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorOvr());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksInputTracking + "Remove Symbols for Oculus SDK", priority = UxrConstants.Editor.PriorityMenuPathSdksInputTracking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorOvr());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: baf1f71e835776b499b39f9dadef67a5
|
||||
timeCreated: 1516622924
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,123 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorPicoXR.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.InputTracking
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the PicoXR SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorPicoXR : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.InputTracking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string PackageName => "com.unity.xr.picoxr";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkPicoXR;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2021.1";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_PICOXR_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_PICOXR_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
|
||||
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
|
||||
{
|
||||
// UltimateXR assembly already sets up version define for the PicoXR package
|
||||
#if ULTIMATEXR_USE_PICOXR_SDK
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
#else
|
||||
CurrentState = State.NotInstalled;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentState = State.CurrentTargetNotSupported;
|
||||
}
|
||||
|
||||
#else
|
||||
CurrentState = State.NeedsHigherUnityVersion
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://developer.pico-interactive.com/sdk");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorPicoXR());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksInputTracking + "Remove Symbols for PicoXR", priority = UxrConstants.Editor.PriorityMenuPathSdksInputTracking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorPicoXR());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcb742eddb99cc847a70027cb1af5e16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,178 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorSteamVR.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
#if ULTIMATEXR_USE_STEAMVR_SDK
|
||||
using Valve.VR;
|
||||
#endif
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.InputTracking
|
||||
{
|
||||
#if ULTIMATEXR_USE_STEAMVR_SDK
|
||||
#endif
|
||||
/// <summary>
|
||||
/// SDK Locator for the SteamVR SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorSteamVR : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.InputTracking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkSteamVR;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2021.1";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_STEAMVR_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_STEAMVR_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
|
||||
if (EditorUserBuildSettings.activeBuildTarget is BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64)
|
||||
{
|
||||
CurrentState = State.NotInstalled;
|
||||
|
||||
if (IsTypeInAssemblies("Valve.VR.SteamVR_Events"))
|
||||
{
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentState = State.CurrentTargetNotSupported;
|
||||
}
|
||||
#else
|
||||
CurrentState = State.NeedsHigherUnityVersion
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://assetstore.unity.com/packages/templates/systems/steamvr-plugin-32647");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorSteamVR());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
#if ULTIMATEXR_USE_STEAMVR_SDK
|
||||
if (SteamVR_Input.DoesActionsFileExist())
|
||||
{
|
||||
if (SteamVR_Input.actionFile != null && SteamVR_Input.actionFile.action_sets != null)
|
||||
{
|
||||
bool needsSetup = SteamVRActionsExporter.NeedsActionsSetup();
|
||||
|
||||
if (!needsSetup)
|
||||
{
|
||||
EditorGUILayout.LabelField("Found UltimateXR actions. Input is available.");
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("UltimateXR actions need to be set up to use SteamVR input", MessageType.Warning);
|
||||
}
|
||||
|
||||
bool guiEnabled = GUI.enabled;
|
||||
GUI.enabled = guiEnabled && needsSetup;
|
||||
|
||||
if (UxrEditorUtils.CenteredButton(new GUIContent("Create Actions")))
|
||||
{
|
||||
SteamVRActionsExporter.TrySetupActions();
|
||||
}
|
||||
|
||||
GUI.enabled = guiEnabled && !needsSetup;
|
||||
|
||||
if (UxrEditorUtils.CenteredButton(new GUIContent("Delete Actions")))
|
||||
{
|
||||
SteamVRActionsExporter.TryRemoveActions();
|
||||
}
|
||||
|
||||
GUI.enabled = guiEnabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SteamVR_Input.actionFile == null)
|
||||
{
|
||||
SteamVR_Input.InitializeFile(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("SteamVR actions have not been set up and need to be created first.\nNavigate to Unity's top menu Window->SteamVR Input to generate the actions. When finished continue setup here.", MessageType.Warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksInputTracking + "Remove Symbols for SteamVR", priority = UxrConstants.Editor.PriorityMenuPathSdksInputTracking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorSteamVR());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edbdd5bdbf4a4ad4c83346bc46a3d6ab
|
||||
timeCreated: 1516622924
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,124 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorUltraleap.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.InputTracking
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the hand-tracking Ultraleap SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorUltraleap : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.InputTracking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkUltraleap;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2021.1";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_ULTRALEAP_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_ULTRALEAP_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
|
||||
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android ||
|
||||
EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows ||
|
||||
EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64)
|
||||
{
|
||||
/*
|
||||
CurrentState = State.NotInstalled;
|
||||
|
||||
if (IsTypeInAssemblies("Leap.Unity.RigidHand"))
|
||||
{
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
}
|
||||
|
||||
CurrentVersion = 0;*/
|
||||
CurrentState = State.SoonSupported;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentState = State.CurrentTargetNotSupported;
|
||||
}
|
||||
#else
|
||||
CurrentState = State.NeedsHigherUnityVersion
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://github.com/ultraleap/UnityPlugin/releases/");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorUltraleap());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksInputTracking + "Remove Symbols for Ultraleap", priority = UxrConstants.Editor.PriorityMenuPathSdksInputTracking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorUltraleap());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99ee4409d6435fb458eadb87ab751efd
|
||||
timeCreated: 1516622924
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,122 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorWaveXR.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.InputTracking
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the WaveXR SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorWaveXR : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.InputTracking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string PackageName => "com.htc.upm.wave.xrsdk";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkWaveXR;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2021.1";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_WAVEXR_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_WAVEXR_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
|
||||
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
|
||||
{
|
||||
// UltimateXR assembly already sets up version define for package com.htc.upm.wave.xrsdk
|
||||
#if ULTIMATEXR_USE_WAVEXR_SDK
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
#else
|
||||
CurrentState = State.NotInstalled;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentState = State.CurrentTargetNotSupported;
|
||||
}
|
||||
|
||||
#else
|
||||
CurrentState = State.NeedsHigherUnityVersion
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://developer.vive.com/resources/vive-wave/tutorials/installing-wave-xr-plugin-unity/");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorWaveXR());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksInputTracking + "Remove Symbols for WaveXR", priority = UxrConstants.Editor.PriorityMenuPathSdksInputTracking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorWaveXR());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4b9f11aeb6810d47b5302587cf5f550
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,100 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorWindowsMR.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.InputTracking
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the Windows Mixed Reality SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorWindowsMixedReality : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.InputTracking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkWindowsMixedReality;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2021.1";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_WINDOWSMIXEDREALITY_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_WINDOWSMIXEDREALITY_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
|
||||
if (EditorUserBuildSettings.activeBuildTarget is BuildTarget.WSAPlayer or BuildTarget.StandaloneWindows or BuildTarget.StandaloneWindows64)
|
||||
{
|
||||
CurrentState = State.Available;
|
||||
CurrentVersion = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentState = State.CurrentTargetNotSupported;
|
||||
}
|
||||
#else
|
||||
CurrentState = State.NeedsHigherUnityVersion;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorWindowsMixedReality());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksInputTracking + "Remove Symbols for Windows Mixed Reality", priority = UxrConstants.Editor.PriorityMenuPathSdksInputTracking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorWindowsMixedReality());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1f682fbe8d6acb44a8f65de45d892b2
|
||||
timeCreated: 1516622924
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/UltimateXR/Editor/Sdks/Networking.meta
Normal file
8
Assets/UltimateXR/Editor/Sdks/Networking.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9fb6e53efa3f444db1743bcf9375120
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
107
Assets/UltimateXR/Editor/Sdks/Networking/UxrSdkLocatorFishNet.cs
Normal file
107
Assets/UltimateXR/Editor/Sdks/Networking/UxrSdkLocatorFishNet.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorFishNet.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.Networking
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the FishNet SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorFishNet : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.Networking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkFishNet;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2020.3";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_FISHNET_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_FISHNET_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
CurrentState = State.NotInstalled;
|
||||
|
||||
if (IsTypeInAssemblies("FishNet.Managing.NetworkManager"))
|
||||
{
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://assetstore.unity.com/packages/tools/network/fish-net-networking-evolved-207815");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorFishNet());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksNetworking + "Remove Symbols for FishNet", priority = UxrConstants.Editor.PriorityMenuPathSdksNetworking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorFishNet());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81f3545268a322b4c8b838a85d71619e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
107
Assets/UltimateXR/Editor/Sdks/Networking/UxrSdkLocatorMirror.cs
Normal file
107
Assets/UltimateXR/Editor/Sdks/Networking/UxrSdkLocatorMirror.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorMirror.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.Networking
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the Mirror SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorMirror : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.Networking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkMirror;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2020.3";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_MIRROR_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_MIRROR_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
CurrentState = State.NotInstalled;
|
||||
|
||||
if (IsTypeInAssemblies("Mirror.NetworkBehaviour"))
|
||||
{
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://assetstore.unity.com/packages/tools/network/mirror-129321");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorMirror());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksNetworking + "Remove Symbols for Mirror", priority = UxrConstants.Editor.PriorityMenuPathSdksNetworking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorMirror());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2515479c46de9a418d8b0297c225363
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorPhotonFusion.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.Networking
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the Photon Fusion SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorPhotonFusion : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.Networking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkPhotonFusion;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2020.3";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_PHOTONFUSION_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_PHOTONFUSION_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
CurrentState = State.NotInstalled;
|
||||
|
||||
if (IsTypeInAssemblies("Fusion.NetworkBehaviour"))
|
||||
{
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://doc.photonengine.com/fusion/current/getting-started/sdk-download");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorPhotonFusion());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksNetworking + "Remove Symbols for Photon Fusion", priority = UxrConstants.Editor.PriorityMenuPathSdksNetworking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorPhotonFusion());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fa9de1a571bad948a5d67d17f13cc35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,110 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorUnityNetCode.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.Networking
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the Unity NetCode package.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorUnityNetCode : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.Networking;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string PackageName => "com.unity.netcode.gameobjects";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkUnityNetCode;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2020.3";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_UNITY_NETCODE" };
|
||||
}
|
||||
}
|
||||
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_UNITY_NETCODE" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
// UltimateXR assembly already sets up version define for the Unity NetCode package
|
||||
#if ULTIMATEXR_USE_UNITY_NETCODE
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
#else
|
||||
CurrentState = State.NotInstalled;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://docs-multiplayer.unity3d.com/netcode/current/installation/");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorUnityNetCode());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksNetworking + "Remove Symbols for Unity NetCode", priority = UxrConstants.Editor.PriorityMenuPathSdksNetworking)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorUnityNetCode());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f88a10bc760b2464e950835079520dfc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/UltimateXR/Editor/Sdks/UxrSdkLocator.State.cs
Normal file
50
Assets/UltimateXR/Editor/Sdks/UxrSdkLocator.State.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocator.State.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace UltimateXR.Editor.Sdks
|
||||
{
|
||||
public abstract partial class UxrSdkLocator
|
||||
{
|
||||
#region Public Types & Data
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates the different SDK states.
|
||||
/// </summary>
|
||||
public enum State
|
||||
{
|
||||
/// <summary>
|
||||
/// Not initialized.
|
||||
/// </summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// SDK needs a higher Unity version to work.
|
||||
/// </summary>
|
||||
NeedsHigherUnityVersion,
|
||||
|
||||
/// <summary>
|
||||
/// SDK does not support the current build target.
|
||||
/// </summary>
|
||||
CurrentTargetNotSupported,
|
||||
|
||||
/// <summary>
|
||||
/// SDK is not installed.
|
||||
/// </summary>
|
||||
NotInstalled,
|
||||
|
||||
/// <summary>
|
||||
/// SDK is registered but support will come soon.
|
||||
/// </summary>
|
||||
SoonSupported,
|
||||
|
||||
/// <summary>
|
||||
/// SDK is installed and available.
|
||||
/// </summary>
|
||||
Available
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f8bc6ed429e4a7ca69dbc769464b758
|
||||
timeCreated: 1647085496
|
||||
35
Assets/UltimateXR/Editor/Sdks/UxrSdkLocator.SupportType.cs
Normal file
35
Assets/UltimateXR/Editor/Sdks/UxrSdkLocator.SupportType.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocator.Type.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace UltimateXR.Editor.Sdks
|
||||
{
|
||||
public abstract partial class UxrSdkLocator
|
||||
{
|
||||
#region Public Types & Data
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates the different SDK types.
|
||||
/// </summary>
|
||||
public enum SupportType
|
||||
{
|
||||
/// <summary>
|
||||
/// Input/Tracking devices.
|
||||
/// </summary>
|
||||
InputTracking,
|
||||
|
||||
/// <summary>
|
||||
/// Networking support.
|
||||
/// </summary>
|
||||
Networking,
|
||||
|
||||
/// <summary>
|
||||
/// Voice over network support.
|
||||
/// </summary>
|
||||
VoiceOverNetwork
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f4a6b3c1b45d42479fdfdae7433d583
|
||||
timeCreated: 1647085496
|
||||
171
Assets/UltimateXR/Editor/Sdks/UxrSdkLocator.cs
Normal file
171
Assets/UltimateXR/Editor/Sdks/UxrSdkLocator.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocator.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for SDK locators. SDK locators are classes instantiated when Unity is loaded or changes are made and the
|
||||
/// projects is recompiled.
|
||||
/// They are used to automatically add/remove scripting symbols that allow to use different SDKs without the need of
|
||||
/// manual user setup.
|
||||
/// </summary>
|
||||
public abstract partial class UxrSdkLocator
|
||||
{
|
||||
#region Public Types & Data
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of SDK it is (device/multiplayer, etc.).
|
||||
/// </summary>
|
||||
public abstract SupportType Support { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the SDK name.
|
||||
/// </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum required Unity version as a string.
|
||||
/// </summary>
|
||||
public abstract string MinimumUnityVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of scripting symbols that will be added to the project when this SDK is available. Usually
|
||||
/// <see cref="TryLocate" /> will set up an internal list that can be accessed through this array.
|
||||
/// </summary>
|
||||
public abstract string[] AvailableSymbols { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of all scripting symbols that this SDK can add to the project.
|
||||
/// It is used to remove all symbols when it is required.
|
||||
/// </summary>
|
||||
public abstract string[] AllSymbols { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the SDK can be updated. If so, <see cref="TryUpdate" /> is available.
|
||||
/// </summary>
|
||||
public virtual bool CanBeUpdated => false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the package name if the SDK is distributed through the package manager.
|
||||
/// </summary>
|
||||
public virtual string PackageName => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current SDK state as a string.
|
||||
/// </summary>
|
||||
public string CurrentStateString
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (CurrentState)
|
||||
{
|
||||
case State.Unknown: return StringUnknown;
|
||||
case State.NeedsHigherUnityVersion: return StringNeedsHigherUnityVersion;
|
||||
case State.CurrentTargetNotSupported: return $"{StringCurrentTargetNotSupported} ({EditorUserBuildSettings.activeBuildTarget})";
|
||||
case State.NotInstalled: return StringNotInstalled;
|
||||
case State.SoonSupported: return StringSoonSupported;
|
||||
case State.Available: return StringAvailable;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the SDK is a package. This will simplify dependency handling since Unity's Assembly system can take
|
||||
/// care of it.
|
||||
/// </summary>
|
||||
public bool IsPackage => !string.IsNullOrEmpty(PackageName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current SDK state.
|
||||
/// </summary>
|
||||
public State CurrentState { get; protected set; } = State.Unknown;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Tries to find the given type name in the current assemblies. It is used to check for given types to see if an SDK
|
||||
/// is installed or not.
|
||||
/// </summary>
|
||||
/// <param name="typeName">Type name to look for</param>
|
||||
/// <returns>Boolean telling whether the type was found or not</returns>
|
||||
public static bool IsTypeInAssemblies(string typeName)
|
||||
{
|
||||
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
if (assembly.GetType(typeName) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Child SDK locators should implement this method. It will try to locate the SDK and update the internal state making
|
||||
/// it available through <see cref="CurrentState" /> or <see cref="CurrentStateString" />.
|
||||
/// </summary>
|
||||
public abstract void TryLocate();
|
||||
|
||||
/// <summary>
|
||||
/// Child SDK locators can implement this method. It will try to get the SDK from somewhere (usually opening a specific
|
||||
/// URL).
|
||||
/// </summary>
|
||||
public virtual void TryGet()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Child SDK locators can implement this method if <see cref="CanBeUpdated" /> returns true. It will try to update the
|
||||
/// SDK from somewhere (usually opening a specific URL).
|
||||
/// </summary>
|
||||
public virtual void TryUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity
|
||||
|
||||
/// <summary>
|
||||
/// Child SDK locators can implement Unity Editor functionality here. The inspector for <see cref="UxrManager" /> will
|
||||
/// iterate through all SDKs and for the installed ones, will allow to draw custom inspector UI underneath.
|
||||
/// </summary>
|
||||
public virtual void OnInspectorGUI()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Types & Data
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the incremental version number. It enables backwards compatibility across different SDKs.
|
||||
/// </summary>
|
||||
protected int CurrentVersion { get; set; } = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Types & Data
|
||||
|
||||
private const string StringUnknown = "Unknown (not processed)";
|
||||
private const string StringNeedsHigherUnityVersion = "Needs a higher Unity version";
|
||||
private const string StringCurrentTargetNotSupported = "Current build target not supported by SDK";
|
||||
private const string StringNotInstalled = "Not installed";
|
||||
private const string StringSoonSupported = "Soon supported";
|
||||
private const string StringAvailable = "Available";
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
13
Assets/UltimateXR/Editor/Sdks/UxrSdkLocator.cs.meta
Normal file
13
Assets/UltimateXR/Editor/Sdks/UxrSdkLocator.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5795369b43e2828498f7693dab4f90e9
|
||||
timeCreated: 1516622924
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkManager.SetupSymbolsMode.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
namespace UltimateXR.Editor.Sdks
|
||||
{
|
||||
public static partial class UxrSdkManager
|
||||
{
|
||||
#region Private Types & Data
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates the different operations on the SDK preprocessor symbols.
|
||||
/// </summary>
|
||||
private enum SetupSymbolsMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds or removes the preprocessor symbols depending on whether the SDK is present.
|
||||
/// </summary>
|
||||
AddOrRemove,
|
||||
|
||||
/// <summary>
|
||||
/// Removes the symbols.
|
||||
/// </summary>
|
||||
ForceRemove
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 286b3a0b39c845c69c7666a393703ecf
|
||||
timeCreated: 1643729017
|
||||
284
Assets/UltimateXR/Editor/Sdks/UxrSdkManager.cs
Normal file
284
Assets/UltimateXR/Editor/Sdks/UxrSdkManager.cs
Normal file
@@ -0,0 +1,284 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkManager.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks
|
||||
{
|
||||
/// <summary>
|
||||
/// Static class that will store all SDK locators through auto-registration. Each <see cref="UxrSdkLocator" />
|
||||
/// implementation will register itself through this class.
|
||||
/// </summary>
|
||||
public static partial class UxrSdkManager
|
||||
{
|
||||
#region Public Types & Data
|
||||
|
||||
/// <summary>
|
||||
/// Gets the global list of registered SDK locators. SDK locators will auto-register every time Unity is installed or
|
||||
/// the project is updated.
|
||||
/// </summary>
|
||||
public static IReadOnlyList<UxrSdkLocator> SDKLocators => s_locators;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Registers a new SDK locator if it is not already registered.
|
||||
/// The locator then is used to update the project symbols adding the necessary symbols if the SDK was found or
|
||||
/// removing them if it wasn't.
|
||||
/// </summary>
|
||||
/// <param name="locator">SDK locator interface</param>
|
||||
public static void RegisterLocator(UxrSdkLocator locator)
|
||||
{
|
||||
if (s_locators == null)
|
||||
{
|
||||
s_locators = new List<UxrSdkLocator>();
|
||||
}
|
||||
|
||||
// Check if it was already registered
|
||||
|
||||
bool locatorAlreadyRegistered = false;
|
||||
|
||||
foreach (UxrSdkLocator registeredLocator in s_locators)
|
||||
{
|
||||
if (string.Equals(registeredLocator.Name, locator.Name, StringComparison.Ordinal))
|
||||
{
|
||||
locatorAlreadyRegistered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Register if not found
|
||||
|
||||
if (locatorAlreadyRegistered == false)
|
||||
{
|
||||
s_locators.Add(locator);
|
||||
}
|
||||
|
||||
// Try to locate SDK and set up symbols
|
||||
|
||||
locator.TryLocate();
|
||||
|
||||
if (!locator.IsPackage)
|
||||
{
|
||||
SetupSymbols(locator);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given SDK is present and available.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the SDK locator</typeparam>
|
||||
/// <returns>True if installed and available, false if not</returns>
|
||||
public static bool IsAvailable<T>() where T : UxrSdkLocator
|
||||
{
|
||||
if (s_locators != null)
|
||||
{
|
||||
foreach (UxrSdkLocator locator in s_locators)
|
||||
{
|
||||
if (locator.GetType() == typeof(T))
|
||||
{
|
||||
return locator.CurrentState == UxrSdkLocator.State.Available;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given SDK is present and available.
|
||||
/// </summary>
|
||||
/// <param name="name">The SDK name (looks to match any UxrSdkLocator.Name)</param>
|
||||
/// <returns>True if installed and available, false if not</returns>
|
||||
public static bool IsAvailable(string name)
|
||||
{
|
||||
if (s_locators != null)
|
||||
{
|
||||
foreach (UxrSdkLocator locator in s_locators)
|
||||
{
|
||||
if (locator.Name == name)
|
||||
{
|
||||
return locator.CurrentState == UxrSdkLocator.State.Available;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the project symbols removing the symbols of the SDK locator given as argument.
|
||||
/// </summary>
|
||||
/// <param name="locator">The SDK locator to remove the symbols from</param>
|
||||
public static void RemoveSymbols(UxrSdkLocator locator)
|
||||
{
|
||||
if (!locator.IsPackage)
|
||||
{
|
||||
SetupSymbols(locator, SetupSymbolsMode.ForceRemove);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks if currently the project has any symbols defined for the given SDK locator.
|
||||
/// </summary>
|
||||
/// <param name="locator">The SDK locator to check the symbols for</param>
|
||||
public static bool HasAnySymbols(UxrSdkLocator locator)
|
||||
{
|
||||
string[] targetGroupNames = Enum.GetNames(typeof(BuildTargetGroup));
|
||||
int targetGroupIndex = 0;
|
||||
|
||||
foreach (BuildTargetGroup targetGroup in Enum.GetValues(typeof(BuildTargetGroup)))
|
||||
{
|
||||
// Get the BuildTargetGroup name through targetGroupNames. targetGroup.ToString() does not work because there are
|
||||
// enum entries with the same numerical value
|
||||
|
||||
string targetGroupName = targetGroupNames[targetGroupIndex];
|
||||
targetGroupIndex++;
|
||||
|
||||
// Ignore target groups to avoid scripting errors (thank you Ludiq!)
|
||||
|
||||
if (targetGroup == BuildTargetGroup.Unknown)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof(BuildTargetGroup).GetField(targetGroupName).IsDefined(typeof(ObsoleteAttribute), true))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get trimmed target symbol list
|
||||
|
||||
List<string> currentSymbols = new List<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup).Split(';'));
|
||||
|
||||
for (int currentSymbolIndex = 0; currentSymbolIndex < currentSymbols.Count; ++currentSymbolIndex)
|
||||
{
|
||||
currentSymbols[currentSymbolIndex] = currentSymbols[currentSymbolIndex].Trim();
|
||||
}
|
||||
|
||||
// Look for symbols
|
||||
|
||||
foreach (string sdkSymbolString in locator.AllSymbols)
|
||||
{
|
||||
if (currentSymbols.IndexOf(sdkSymbolString) != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Updates the project symbols adding the necessary symbols if the SDK is present or removing them if it is not. Also
|
||||
/// allows to remove the symbols if necessary.
|
||||
/// </summary>
|
||||
/// <param name="locator">The SDK locator</param>
|
||||
/// <param name="setupSymbolsMode">
|
||||
/// If <see cref="SetupSymbolsMode.AddOrRemove" /> is specified then it will update the symbols depending on the SDK
|
||||
/// presence (add if SDK is present, remove if it is not present).
|
||||
/// In <see cref="SetupSymbolsMode.ForceRemove" /> mode it will remove all symbols linked to the SDK locator.
|
||||
/// </param>
|
||||
private static void SetupSymbols(UxrSdkLocator locator, SetupSymbolsMode setupSymbolsMode = SetupSymbolsMode.AddOrRemove)
|
||||
{
|
||||
string[] targetGroupNames = Enum.GetNames(typeof(BuildTargetGroup));
|
||||
int targetGroupIndex = 0;
|
||||
|
||||
foreach (BuildTargetGroup targetGroup in Enum.GetValues(typeof(BuildTargetGroup)))
|
||||
{
|
||||
// Get the BuildTargetGroup name through targetGroupNames. targetGroup.ToString() does not work because there are
|
||||
// enum entries with the same numerical value
|
||||
|
||||
string targetGroupName = targetGroupNames[targetGroupIndex];
|
||||
targetGroupIndex++;
|
||||
|
||||
// Ignore target groups to avoid scripting errors (thank you Ludiq!)
|
||||
|
||||
if (targetGroup == BuildTargetGroup.Unknown)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof(BuildTargetGroup).GetField(targetGroupName).IsDefined(typeof(ObsoleteAttribute), true))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get trimmed target symbol list
|
||||
|
||||
List<string> currentSymbols = new List<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup).Split(';'));
|
||||
|
||||
for (int currentSymbolIndex = 0; currentSymbolIndex < currentSymbols.Count; ++currentSymbolIndex)
|
||||
{
|
||||
currentSymbols[currentSymbolIndex].Trim();
|
||||
}
|
||||
|
||||
// Look for symbols, adding or removing if necessary
|
||||
|
||||
bool updated = false;
|
||||
|
||||
List<string> availableSymbols = new List<string>(locator.AvailableSymbols);
|
||||
|
||||
foreach (string sdkSymbolString in locator.AllSymbols)
|
||||
{
|
||||
if (setupSymbolsMode == SetupSymbolsMode.AddOrRemove)
|
||||
{
|
||||
// Add
|
||||
|
||||
if (availableSymbols.Contains(sdkSymbolString) && currentSymbols.IndexOf(sdkSymbolString) == -1)
|
||||
{
|
||||
currentSymbols.Add(sdkSymbolString);
|
||||
updated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (currentSymbols.IndexOf(sdkSymbolString) != currentSymbols.LastIndexOf(sdkSymbolString))
|
||||
{
|
||||
// Remove duplicates
|
||||
currentSymbols.Remove(sdkSymbolString);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove
|
||||
|
||||
while (currentSymbols.IndexOf(sdkSymbolString) != -1)
|
||||
{
|
||||
currentSymbols.Remove(sdkSymbolString);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update target symbol list
|
||||
|
||||
if (updated)
|
||||
{
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, string.Join(";", currentSymbols.ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Types & Data
|
||||
|
||||
private static List<UxrSdkLocator> s_locators;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
13
Assets/UltimateXR/Editor/Sdks/UxrSdkManager.cs.meta
Normal file
13
Assets/UltimateXR/Editor/Sdks/UxrSdkManager.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 779e69b16313ff244b32a7d3e4a2172a
|
||||
timeCreated: 1516626601
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/UltimateXR/Editor/Sdks/VoiceOverNetwork.meta
Normal file
8
Assets/UltimateXR/Editor/Sdks/VoiceOverNetwork.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f3f6185d3f2a804bbe0166868a92b2f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorDissonance.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.VoiceOverNetwork
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the Dissonance Voice Chat SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorDissonance : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.VoiceOverNetwork;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkDissonance;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2020.3";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_DISSONANCE_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_DISSONANCE_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
CurrentState = State.NotInstalled;
|
||||
|
||||
if (IsTypeInAssemblies("Dissonance.DissonanceComms"))
|
||||
{
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://assetstore.unity.com/packages/tools/audio/dissonance-voice-chat-70078");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorDissonance());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksNetworkingVoice + "Remove Symbols for Dissonance", priority = UxrConstants.Editor.PriorityMenuPathSdksNetworkingVoice)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorDissonance());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4591a4c15a3b83d4ca0a1195edb9d4f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// <copyright file="UxrSdkLocatorPhotonVoice.cs" company="VRMADA">
|
||||
// Copyright (c) VRMADA, All rights reserved.
|
||||
// </copyright>
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
using System;
|
||||
using UltimateXR.Core;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UltimateXR.Editor.Sdks.VoiceOverNetwork
|
||||
{
|
||||
/// <summary>
|
||||
/// SDK Locator for the Photon Voice SDK.
|
||||
/// </summary>
|
||||
public sealed class UxrSdkLocatorPhotonVoice : UxrSdkLocator
|
||||
{
|
||||
#region Public Overrides UxrSdkLocator
|
||||
|
||||
/// <inheritdoc />
|
||||
public override SupportType Support => SupportType.VoiceOverNetwork;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Name => UxrConstants.SdkPhotonVoice;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string MinimumUnityVersion => "2020.3";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AvailableSymbols
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentState == State.Available)
|
||||
{
|
||||
if (CurrentVersion == 0)
|
||||
{
|
||||
return new[] { "ULTIMATEXR_USE_PHOTONVOICE_SDK" };
|
||||
}
|
||||
}
|
||||
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string[] AllSymbols
|
||||
{
|
||||
get { return new[] { "ULTIMATEXR_USE_PHOTONVOICE_SDK" }; }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanBeUpdated => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryLocate()
|
||||
{
|
||||
CurrentState = State.NotInstalled;
|
||||
|
||||
if (IsTypeInAssemblies("Photon.Voice.Unity.Recorder"))
|
||||
{
|
||||
CurrentVersion = 0;
|
||||
CurrentState = State.Available;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryGet()
|
||||
{
|
||||
Application.OpenURL("https://assetstore.unity.com/packages/tools/audio/photon-voice-2-130518");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void TryUpdate()
|
||||
{
|
||||
TryGet();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
|
||||
/// </summary>
|
||||
[InitializeOnLoadMethod]
|
||||
public static void RegisterLocator()
|
||||
{
|
||||
UxrSdkManager.RegisterLocator(new UxrSdkLocatorPhotonVoice());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
|
||||
/// </summary>
|
||||
[MenuItem(UxrConstants.Editor.MenuPathSdksNetworkingVoice + "Remove Symbols for Photon Voice", priority = UxrConstants.Editor.PriorityMenuPathSdksNetworkingVoice)]
|
||||
private static void RemoveSymbols()
|
||||
{
|
||||
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorPhotonVoice());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a6bfda70f8e6f246ad4cb2da05ad538
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user