123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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<StandaloneSubsystemDescriptor> s_StandaloneSubsystemDescriptors =
- new List<StandaloneSubsystemDescriptor>();
-
- public StandaloneSubsystem inputSubsystem
- {
- get { return GetLoadedSubsystem<StandaloneSubsystem>(); }
- }
-
- public override ISubsystem GetDefaultSubsystem()
- {
- return GetLoadedSubsystem<StandaloneSubsystem>();
- }
-
- 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
-
- /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Initialize"/></summary>
- /// <returns>True if successful, false otherwise</returns>
- public override bool Initialize()
- {
- IAdaptivePerformanceSettings settings = GetSettings();
- if (settings != null)
- {
- // TODO: Pass settings off to plugin prior to subsystem init.
- }
-
- CreateSubsystem<StandaloneSubsystemDescriptor, StandaloneSubsystem>(s_StandaloneSubsystemDescriptors, "Standalone Subsystem");
-
- return false;
- }
-
- /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Start"/></summary>
- /// <returns>True if successful, false otherwise</returns>
- public override bool Start()
- {
- StartSubsystem<StandaloneSubsystem>();
- return true;
- }
-
- /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Stop"/></summary>
- /// <returns>True if successful, false otherwise</returns>
- public override bool Stop()
- {
- StopSubsystem<StandaloneSubsystem>();
- return true;
- }
-
- /// <summary>Implementaion of <see cref="AdaptivePerformanceLoader.Deinitialize"/></summary>
- /// <returns>True if successful, false otherwise</returns>
- public override bool Deinitialize()
- {
- DestroySubsystem<StandaloneSubsystem>();
- return true;
- }
-
- #if UNITY_EDITOR
- public override void WasAssignedToBuildTarget(BuildTargetGroup buildTargetGroup)
- {
- WasAssigned = true;
- }
-
- public override void WasUnassignedFromBuildTarget(BuildTargetGroup buildTargetGroup)
- {
- WasUnassigned = true;
- }
-
- #endif
- #endregion
- }
- }
|