Jelajahi Sumber

Dependecies for misc. files added

Syed zainul abedin 1 Minggu lalu
induk
melakukan
9d1e2db48d

+ 38 - 3
Assets/IntelligentProjectAnalyzer/Editor/AssetDataFetcher.cs

@@ -22,13 +22,23 @@ namespace IntelligentProjectAnalyzer.Editor
         /// Finds all relevant asset GUIDs for scripts, prefabs, and ScriptableObjects.
         /// </summary>
         /// <returns>A tuple containing queues of GUIDs for each asset type.</returns>
-        public static (Queue<string> scriptGuids, Queue<string> prefabGuids, Queue<string> soGuids, Queue<string> sceneGuids) FindAssetGuids()
+        public static (Queue<string> scriptGuids, Queue<string> prefabGuids, Queue<string> soGuids, Queue<string> sceneGuids, Queue<string> miscGuids) FindAssetGuids()
         {
             var scripts = new Queue<string>(AssetDatabase.FindAssets("t:MonoScript"));
             var prefabs = new Queue<string>(AssetDatabase.FindAssets("t:Prefab"));
             var scriptableObjects = new Queue<string>(AssetDatabase.FindAssets("t:ScriptableObject"));
             var scenes = new Queue<string>(AssetDatabase.FindAssets("t:Scene"));
-            return (scripts, prefabs, scriptableObjects, scenes);
+            var allGuids = new Queue<string>(AssetDatabase.FindAssets(""));
+            
+            var knownGuids = new HashSet<string>();
+            knownGuids.UnionWith(scriptableObjects);
+            knownGuids.UnionWith(prefabs);
+            knownGuids.UnionWith(scriptableObjects);
+            knownGuids.UnionWith(scenes);
+            
+            var miscGuids = new Queue<string>(allGuids.Except(knownGuids));
+
+            return (scripts, prefabs, scriptableObjects, scenes, miscGuids);
         }
 
         /// <summary>
@@ -176,6 +186,31 @@ namespace IntelligentProjectAnalyzer.Editor
             return setupData;
         }
 
+        public static MiscAssetMetadata PreFetchMiscAssetMetadata(string guid)
+        {
+            var assetPath = AssetDatabase.GUIDToAssetPath(guid);
+            if (string.IsNullOrEmpty(assetPath) || !assetPath.StartsWith("Assets/")) return null;
+            
+            var miscMetaData = new MiscAssetMetadata() { Guid = guid };
+            var hash = new HashSet<string>();
+
+            var assetDependencies = AssetDatabase.GetDependencies(assetPath);
+            foreach (var dependency in assetDependencies)
+            {
+                if (string.IsNullOrEmpty(dependency) || !dependency.StartsWith("Assets/") || dependency == assetPath)
+                {
+                    continue;
+                }
+                var dependencyGuid = AssetDatabase.AssetPathToGUID(dependency);
+                if (!string.IsNullOrEmpty(dependencyGuid))
+                {
+                    hash.Add(dependencyGuid);
+                }
+            }
+            miscMetaData.DependencyGuids = hash.ToList();
+            return miscMetaData;
+        }
+
         public static SceneMetadata PreFetchSceneMetadata(string guid)
         {
             var assetPath = AssetDatabase.GUIDToAssetPath(guid);
@@ -186,7 +221,7 @@ namespace IntelligentProjectAnalyzer.Editor
             var sceneMetaData = new SceneMetadata() { Guid = guid };
             var hash = new HashSet<string>();
 
-            // Find all components on the prefab and its children to get their script GUIDs.
+            // Find all components on the scene and its children to get their script GUIDs.
             foreach (var root in scene.GetRootGameObjects())
             {
                 var components = root.GetComponentsInChildren<Component>(true);

+ 5 - 0
Assets/IntelligentProjectAnalyzer/Editor/DependencyBuilderData.cs

@@ -1,6 +1,7 @@
 using System;
 using Newtonsoft.Json;
 using System.Collections.Generic;
+using UnityEngine;
 
 namespace IntelligentProjectAnalyzer.Editor
 {
@@ -21,6 +22,7 @@ namespace IntelligentProjectAnalyzer.Editor
                 typeof(PrefabMetadata),
                 typeof(SceneMetadata),
                 typeof(ScriptableObjectMetadata),
+                typeof(MiscAssetMetadata),
             };
 
             public static int GetIndexFromType(Type type) => Types.IndexOf(type);
@@ -86,5 +88,8 @@ namespace IntelligentProjectAnalyzer.Editor
         /// </summary>
         [Serializable]
         public class SceneMetadata : AssetMetadata { }
+        
+        [Serializable]
+        public class MiscAssetMetadata : AssetMetadata { }
     }
 }

+ 14 - 2
Assets/IntelligentProjectAnalyzer/Editor/DependencyStoreBuilder.cs

@@ -26,11 +26,13 @@ namespace IntelligentProjectAnalyzer.Editor
         private static Queue<string> _prefabGuidsToProcess;
         private static Queue<string> _soGuidsToProcess;
         private static Queue<string> _sceneGuidsToProcess;
+        private static Queue<string> _miscGuidsToProcess;
 
         // Lists to store the pre-fetched metadata
         private static List<AssetMetadata> _allMetadata;
         private static List<ScriptMetadata> _scriptMetadata;
         private static List<SceneMetadata> _sceneMetadata;
+        private static List<MiscAssetMetadata> _miscMetadata;
 
         // Task for background analysis
         private static Task<List<AssetMetadata>> _analysisTask;
@@ -57,11 +59,12 @@ namespace IntelligentProjectAnalyzer.Editor
             Debug.Log($"--- Starting Async Dependency Store Build ---");
             DependencyCacheManager.CleanAndPrepareCache();
 
-            (_scriptGuidsToProcess, _prefabGuidsToProcess, _soGuidsToProcess, _sceneGuidsToProcess) = AssetDataFetcher.FindAssetGuids();
+            (_scriptGuidsToProcess, _prefabGuidsToProcess, _soGuidsToProcess, _sceneGuidsToProcess, _miscGuidsToProcess) = AssetDataFetcher.FindAssetGuids();
 
             _allMetadata = new List<AssetMetadata>();
             _scriptMetadata = new List<ScriptMetadata>();
             _sceneMetadata = new List<SceneMetadata>();
+            _miscMetadata = new List<MiscAssetMetadata>();
 
             _currentState = BuilderState.PreFetching;
         }
@@ -95,7 +98,7 @@ namespace IntelligentProjectAnalyzer.Editor
 
         private static void ProcessPreFetchingBatch()
         {
-            var totalAssets = _scriptGuidsToProcess.Count + _prefabGuidsToProcess.Count + _soGuidsToProcess.Count + _sceneGuidsToProcess.Count;
+            var totalAssets = _scriptGuidsToProcess.Count + _prefabGuidsToProcess.Count + _soGuidsToProcess.Count + _sceneGuidsToProcess.Count + _miscGuidsToProcess.Count;
             var initialTotal = _allMetadata.Count + totalAssets;
 
             for (var i = 0; i < BatchSize; i++)
@@ -128,6 +131,15 @@ namespace IntelligentProjectAnalyzer.Editor
                     var meta = AssetDataFetcher.PreFetchScriptableObjectMetadata(_soGuidsToProcess.Dequeue());
                     if (meta != null) _allMetadata.Add(meta);
                 }
+                else if (_miscGuidsToProcess.Count > 0)
+                {
+                    var meta = AssetDataFetcher.PreFetchMiscAssetMetadata(_miscGuidsToProcess.Dequeue());
+                    if (meta != null)
+                    {
+                        _allMetadata.Add(meta);
+                        _miscMetadata.Add(meta);
+                    }
+                }
                 else
                 {
                     // All pre-fetching is complete.

+ 1 - 12
Assets/IntelligentProjectAnalyzer/Editor/DependencyViewer/DependencyViewerWindow.cs

@@ -111,18 +111,7 @@ namespace IntelligentProjectAnalyzer.Editor.DependencyViewer
                 return;
             }
 
-            // --- Validation Step 1: Check Asset Type ---
-            var isValidType = newAsset is MonoScript or GameObject or ScriptableObject or SceneAsset;
-            if (!isValidType)
-            {
-                EditorUtility.DisplayDialog("Invalid Asset Type", "Please select a C# Script, Prefab, or ScriptableObject.", "OK");
-                _assetSelector.SetValueWithoutNotify(null); // Clear the selection
-                _selectedAsset = null;
-                PopulateLists();
-                return;
-            }
-
-            // --- Validation Step 2: Check if it's a project asset ---
+            // --- Validation Step 1: Check if it's a project asset ---
             var assetPath = AssetDatabase.GetAssetPath(newAsset);
             if (string.IsNullOrEmpty(assetPath) || !assetPath.StartsWith("Assets/"))
             {

+ 66 - 1
Assets/Scenes/SampleScene.unity

@@ -38,7 +38,6 @@ RenderSettings:
   m_ReflectionIntensity: 1
   m_CustomReflection: {fileID: 0}
   m_Sun: {fileID: 0}
-  m_IndirectSpecularColor: {r: 0.18028305, g: 0.22571313, b: 0.3069213, a: 1}
   m_UseRadianceAmbientProbe: 0
 --- !u!157 &3
 LightmapSettings:
@@ -405,3 +404,69 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 2
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &1429936256
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 1429936258}
+  - component: {fileID: 1429936257}
+  - component: {fileID: 1429936259}
+  m_Layer: 0
+  m_Name: GameObject
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!114 &1429936257
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1429936256}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: feee230b4aee48b5bcc58550c0f62fdb, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  fuseTime: 3
+  explosionRadius: 5
+  explosionForce: 700
+  explosionEffect: {fileID: 0}
+--- !u!4 &1429936258
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1429936256}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0.2898221, y: -22.73114, z: -58.733814}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 0}
+  m_RootOrder: 3
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &1429936259
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 1429936256}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: f2c3ddebf28f407fa44e90962e424c3e, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  grenadePrefab: {fileID: 0}
+  grenadeSpawnPoint: {fileID: 0}
+  launchForce: 20
+  upwardForce: 5
+  fireRate: 1