using System.Collections.Generic; using UnityEngine.XR.Management; #if UNITY_EDITOR using UnityEditor; using UnityEditor.XR.Management; #endif using UnityEngine.XR.Management.Tests.Standalone; namespace Unity.XR.Management.TestPackage { public class TestLoaderBase : XRLoaderHelper { #if UNITY_EDITOR public TestLoaderBase() { WasAssigned = false; WasUnassigned = false; } public static bool WasAssigned { get; set; } public static bool WasUnassigned { get; set; } #endif static List s_StandaloneSubsystemDescriptors = new List(); public StandaloneSubsystem inputSubsystem { get { return GetLoadedSubsystem(); } } TestSettings GetSettings() { TestSettings settings = null; // When running in the Unity Editor, we have to load user's customization of configuration data directly from // EditorBuildSettings. At runtime, we need to grab it from the static instance field instead. #if UNITY_EDITOR UnityEditor.EditorBuildSettings.TryGetConfigObject(Constants.k_SettingsKey, out settings); #else settings = TestSettings.s_RuntimeInstance; #endif return settings; } #region XRLoader API Implementation /// Implementaion of /// True if successful, false otherwise public override bool Initialize() { TestSettings settings = GetSettings(); if (settings != null) { // TODO: Pass settings off to plugin prior to subsystem init. } CreateSubsystem(s_StandaloneSubsystemDescriptors, "Standalone Subsystem"); return false; } /// Implementaion of /// True if successful, false otherwise public override bool Start() { StartSubsystem(); return true; } /// Implementaion of /// True if successful, false otherwise public override bool Stop() { StopSubsystem(); return true; } /// Implementaion of /// True if successful, false otherwise public override bool Deinitialize() { DestroySubsystem(); return true; } #if UNITY_EDITOR public override void WasAssignedToBuildTarget(BuildTargetGroup buildTargetGroup) { WasAssigned = true; } public override void WasUnassignedFromBuildTarget(BuildTargetGroup buildTargetGroup) { WasUnassigned = true; } #endif #endregion } }