AssetNodeResolver.cs 686 B

123456789101112131415161718192021222324
  1. using UnityEditor;
  2. namespace IntelligentProjectAnalyzer.Editor.Graphing
  3. {
  4. public class AssetNodeResolver
  5. {
  6. public static GraphNode CreateNodeFromGuid(string guid)
  7. {
  8. var path = AssetDatabase.GUIDToAssetPath(guid);
  9. if (string.IsNullOrEmpty(path))
  10. {
  11. return new GraphNode { Guid = guid, Path = "N/A (Missing Asset)", Type = "Unknown" };
  12. }
  13. var assetType = AssetDatabase.GetMainAssetTypeAtPath(path);
  14. return new GraphNode
  15. {
  16. Guid = guid,
  17. Path = path,
  18. Type = assetType?.Name ?? "Unknown"
  19. };
  20. }
  21. }
  22. }