using UnityEditor;
using UnityEngine;
namespace VertexColor.ScenePartition.Editor
{
///
/// Local cache/data container.
/// Hold loaded data, calculated data, cache data, state data.
/// This data is persistent though editor sessions and recompiles, is stored in the project folder.
///
[FilePath("Library/ScenePartition/SceneDataCache.asset", FilePathAttribute.Location.ProjectFolder)]
public class ScenePartitionSS : ScriptableSingleton
{
public SceneDataCache SceneDataCache => sceneDataCache;
[SerializeField]
private SceneDataCache sceneDataCache = new SceneDataCache();
public ScenePartitionData GetScenePartitionData(ScenePartitionSO scenePartitionSO)
{
if (!sceneDataCache.TryGetValue(scenePartitionSO, out ScenePartitionData scenePartitionData))
{
scenePartitionData = new ScenePartitionData();
sceneDataCache.Add(scenePartitionSO, scenePartitionData);
}
return scenePartitionData;
}
private void OnDisable()
{
Save();
}
public static void Save()
{
instance.Save(true);
}
}
[System.Serializable]
public class SceneDataCache : SerializableDictionary { }
}