// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) VRMADA, All rights reserved.
//
// --------------------------------------------------------------------------------------------------------------------
using UltimateXR.Core;
using UnityEditor;
using UnityEngine;
namespace UltimateXR.Editor.Sdks.InputTracking
{
///
/// SDK Locator for Oculus' SDK.
///
public sealed class UxrSdkLocatorOvr : UxrSdkLocator
{
#region Public Overrides UxrSdkLocator
///
public override SupportType Support => SupportType.InputTracking;
///
public override string Name => UxrConstants.SdkOculus;
///
public override string MinimumUnityVersion => "2021.1";
///
public override string[] AvailableSymbols
{
get
{
if (CurrentState == State.Available)
{
if (CurrentVersion == 0)
{
return new[] { "ULTIMATEXR_USE_OCULUS_SDK" };
}
}
return new string[0];
}
}
///
public override string[] AllSymbols
{
get { return new[] { "ULTIMATEXR_USE_OCULUS_SDK" }; }
}
///
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;
}
}
///
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");
}
}
///
public override void TryUpdate()
{
TryGet();
}
#endregion
#region Public Methods
///
/// Auto-registers the locator each time Unity is launched or the project folder is updated.
///
[InitializeOnLoadMethod]
public static void RegisterLocator()
{
UxrSdkManager.RegisterLocator(new UxrSdkLocatorOvr());
}
#endregion
#region Private Methods
///
/// Allows to remove dependencies from the project in case the user removed SDK folders manually.
///
[MenuItem(UxrConstants.Editor.MenuPathSdksInputTracking + "Remove Symbols for Oculus SDK", priority = UxrConstants.Editor.PriorityMenuPathSdksInputTracking)]
private static void RemoveSymbols()
{
UxrSdkManager.RemoveSymbols(new UxrSdkLocatorOvr());
}
#endregion
}
}