UnityGame/Library/PackageCache/com.unity.ai.navigation/Tests/Editor/DomainReloadTestBase.cs

57 lines
1.5 KiB
C#
Raw Permalink Normal View History

2024-10-27 10:53:47 +03:00
using System.Collections;
using NUnit.Framework;
using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
namespace Unity.AI.Navigation.Editor.Tests
{
internal abstract class DomainReloadTestBase
{
struct OptionSet
{
public bool enterPlayModeOptionsEnabled;
public EnterPlayModeOptions enterPlayModeOptions;
}
OptionSet m_OriginalOptions;
[SerializeField] protected GameObject m_TestGo;
[UnityTearDown]
public IEnumerator TearDown()
{
if (EditorApplication.isPlaying)
yield return new ExitPlayMode();
if (m_TestGo != null)
{
Object.DestroyImmediate(m_TestGo);
m_TestGo = null;
}
}
[OneTimeSetUp]
public void OneTimeSetUp()
{
if (EditorApplication.isPlaying)
return;
m_OriginalOptions = new OptionSet()
{
enterPlayModeOptions = EditorSettings.enterPlayModeOptions,
enterPlayModeOptionsEnabled = EditorSettings.enterPlayModeOptionsEnabled
};
}
[OneTimeTearDown]
public void OneTimeTearDown()
{
if (EditorApplication.isPlaying)
return;
EditorSettings.enterPlayModeOptions = m_OriginalOptions.enterPlayModeOptions;
EditorSettings.enterPlayModeOptionsEnabled = m_OriginalOptions.enterPlayModeOptionsEnabled;
}
}
}