ActiveSceneProvider.cs 871 B

123456789101112131415161718192021222324252627282930313233
  1. using UnityEngine;
  2. using UnityEngine.SceneManagement;
  3. using UnityEditor.SceneManagement;
  4. namespace LLM.Editor.Analysis
  5. {
  6. /// <summary>
  7. /// Provides context about the currently active scene in the editor.
  8. /// </summary>
  9. public class ActiveSceneProvider : IContextProvider
  10. {
  11. public class SceneInfo
  12. {
  13. public string name;
  14. public string path;
  15. public bool isDirty;
  16. public bool isValid;
  17. }
  18. public object GetContext(Object target, string qualifier)
  19. {
  20. var activeScene = SceneManager.GetActiveScene();
  21. return new SceneInfo
  22. {
  23. name = activeScene.name,
  24. path = activeScene.path,
  25. isDirty = activeScene.isDirty,
  26. isValid = activeScene.IsValid()
  27. };
  28. }
  29. }
  30. }