// Animancer // Copyright 2020 Kybernetik //
#if UNITY_EDITOR
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Animancer.Editor
{
/// [Editor-Only]
/// Stores data which needs to survive assembly reloading (such as from script compilation), but can be discarded
/// when the Unity Editor is closed.
///
internal sealed class TemporarySettings : ScriptableObject
{
/************************************************************************************************************************/
#region Instance
/************************************************************************************************************************/
private static TemporarySettings _Instance;
///
/// Finds an existing instance of this class or creates a new one.
///
public static TemporarySettings Instance
{
get
{
if (_Instance == null)
{
var instances = Resources.FindObjectsOfTypeAll();
if (instances.Length > 0)
{
_Instance = instances[0];
}
else
{
_Instance = CreateInstance();
_Instance.hideFlags = HideFlags.HideAndDontSave | HideFlags.DontUnloadUnusedAsset;
}
}
return _Instance;
}
}
/************************************************************************************************************************/
private void OnEnable()
{
OnEnableSelection();
}
private void OnDisable()
{
OnDisableSelection();
}
/************************************************************************************************************************/
#endregion
/************************************************************************************************************************/
#region Event Selection
/************************************************************************************************************************/
private readonly Dictionary