2023-06-27 00:24:46 +02:00
|
|
|
using UnityEditor;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace VertexColor.ScenePartition.Editor
|
|
|
|
{
|
2023-06-27 01:09:28 +02:00
|
|
|
/// <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)]
|
2023-06-27 00:24:46 +02:00
|
|
|
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;
|
|
|
|
}
|
2023-06-27 01:09:28 +02:00
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
{
|
2023-06-28 01:07:27 +02:00
|
|
|
Save();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Save()
|
|
|
|
{
|
|
|
|
instance.Save(true);
|
2023-06-27 01:09:28 +02:00
|
|
|
}
|
2023-06-27 00:24:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
public class SceneDataCache : SerializableDictionary<ScenePartitionSO, ScenePartitionData> { }
|
|
|
|
}
|