using System.Collections.Generic; using UnityEngine; using UnityEngine.AdaptivePerformance; #if UNITY_EDITOR using UnityEditor; using UnityEditor.AdaptivePerformance; #endif using UnityEngine.AdaptivePerformance.Tests.Standalone; namespace UnityEngine.AdaptivePerformance.TestPackage { public class TestLoaderBase : AdaptivePerformanceLoaderHelper { #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(); } } public override ISubsystem GetDefaultSubsystem() { return GetLoadedSubsystem(); } public override IAdaptivePerformanceSettings 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 AdaptivePerformanceLoader API Implementation /// Implementaion of /// True if successful, false otherwise public override bool Initialize() { IAdaptivePerformanceSettings 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 } }