ScenePartition/Editor/ScenePartitionSS.cs
max c42a23d6fa Simple grid generation and loading
- Grid generation
- Grid loading
- GridIds
- Still having issues with serialization of the grid data structure
2023-06-28 01:07:27 +02:00

43 lines
1.4 KiB
C#

using UnityEditor;
using UnityEngine;
namespace VertexColor.ScenePartition.Editor
{
/// <summary>
/// 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.
/// </summary>
[FilePath("Library/ScenePartition/SceneDataCache.asset", FilePathAttribute.Location.ProjectFolder)]
public class ScenePartitionSS : ScriptableSingleton<ScenePartitionSS>
{
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<ScenePartitionSO, ScenePartitionData> { }
}