generated from max/template-unity-project
max
d225f897ba
- Object and prefab file id loading - Generate grid update - Switched uint to long but should probably be ulong!
56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace VertexColor.ScenePartition.Editor
|
|
{
|
|
public static class ScenePartitionUtils
|
|
{
|
|
public static string GetDataPath(ScenePartitionSO scenePartitionSO)
|
|
{
|
|
string dataPath = Path.Combine(Application.dataPath, $"../Data/Scenes/{scenePartitionSO.name}");
|
|
|
|
if (!Directory.Exists(dataPath))
|
|
{
|
|
Directory.CreateDirectory(dataPath);
|
|
}
|
|
|
|
return dataPath;
|
|
}
|
|
|
|
public static string GetScenePath(ScenePartitionSO scenePartitionSO)
|
|
{
|
|
string scenePath = AssetDatabase.GetAssetOrScenePath(scenePartitionSO.SceneAsset);
|
|
|
|
return scenePath;
|
|
}
|
|
|
|
public static SortedSet<long> FindDeeplyLinkedObjects(SortedList<long, ScenePartition> scenePartitions, long partitionId)
|
|
{
|
|
SortedSet<long> linkedObjects = new SortedSet<long>();
|
|
FindDeeplyLinkedObjectsRecursive(scenePartitions, partitionId, linkedObjects);
|
|
return linkedObjects;
|
|
}
|
|
|
|
private static void FindDeeplyLinkedObjectsRecursive(SortedList<long, ScenePartition> scenePartitions, long partitionId, SortedSet<long> linkedObjects)
|
|
{
|
|
if (linkedObjects.Contains(partitionId)) return;
|
|
if (!scenePartitions.TryGetValue(partitionId, out ScenePartition partition)) return;
|
|
|
|
linkedObjects.Add(partitionId);
|
|
|
|
foreach (long reference in partition.references)
|
|
{
|
|
FindDeeplyLinkedObjectsRecursive(scenePartitions, reference, linkedObjects);
|
|
if (scenePartitions.TryGetValue(reference, out ScenePartition referencedPartition))
|
|
{
|
|
foreach (long subReference in referencedPartition.references)
|
|
{
|
|
FindDeeplyLinkedObjectsRecursive(scenePartitions, subReference, linkedObjects);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |