generated from max/template-unity-project
Updated ScenePartitionViewEditor
- Grid is now drawn based on the cell size of the current active open scene - Added function to get ScenePartitionSO of current active scene
This commit is contained in:
@ -57,5 +57,35 @@ namespace VertexColor.ScenePartition.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetScenePartitionSOForActiveScene(out ScenePartitionSO scenePartitionSO)
|
||||
{
|
||||
scenePartitionSO = null;
|
||||
|
||||
UnityEngine.SceneManagement.Scene activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
|
||||
|
||||
if (activeScene == null) return false;
|
||||
|
||||
string filter = $"t:{nameof(ScenePartitionSO)}";
|
||||
string[] assets = AssetDatabase.FindAssets(filter);
|
||||
|
||||
if (assets == null || assets.Length <= 0) return false;
|
||||
|
||||
for (int i = 0; i < assets.Length; i++)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(assets[i]);
|
||||
ScenePartitionSO scenePartition = AssetDatabase.LoadAssetAtPath<ScenePartitionSO>(path);
|
||||
|
||||
if (scenePartition == null) continue;
|
||||
|
||||
if (scenePartition.SceneName == activeScene.name)
|
||||
{
|
||||
scenePartitionSO = scenePartition;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user