Parcourir la source

Sujith :) ->
1. Minor clean up for asmdefs
2. Updated analyzer with few new changes to support customised analyze export

Sujith:) il y a 1 semaine
Parent
commit
364249ab9a

+ 1 - 3
Assets/AssetBank/AssetDatabase.asmdef

@@ -1,9 +1,7 @@
 {
     "name": "AssetBank",
     "rootNamespace": "",
-    "references": [
-        "GUID:ae9b6d935e0774f0a9e43c085bf3c9c0"
-    ],
+    "references": [],
     "includePlatforms": [],
     "excludePlatforms": [],
     "allowUnsafeCode": false,

+ 11 - 0
Assets/IntelligentProjectAnalyzer/Analyzer/AnalyzerSettings.cs

@@ -11,6 +11,17 @@ namespace IntelligentProjectAnalyzer.Analyzer
         [Header("Type Analysis Settings")]
         [SerializeField]
         private List<string> mCustomSystemTypes = new();
+        
+        [Header("Custom Analysis Settings")]
+        [SerializeField] private bool mAnalyzeScripts = true;
+        [SerializeField] private bool mAnalyzePrefabs = true;
+        [SerializeField] private bool mAnalyzeScriptableObjects = true;
+        [SerializeField] private bool mAnalyzeMiscellaneous = true;
+        
         [UsedImplicitly] public IReadOnlyList<string> CustomSystemTypes => mCustomSystemTypes;
+        [UsedImplicitly] public bool AnalyzeScripts => mAnalyzeScripts;
+        [UsedImplicitly] public bool AnalyzePrefabs => mAnalyzePrefabs;
+        [UsedImplicitly] public bool AnalyzeScriptableObjects => mAnalyzeScriptableObjects;
+        [UsedImplicitly] public bool AnalyzeMiscellaneous => mAnalyzeMiscellaneous;
     }
 }

+ 5 - 0
Assets/IntelligentProjectAnalyzer/Editor/AnalyzerSettings.asset

@@ -15,3 +15,8 @@ MonoBehaviour:
   mCustomSystemTypes:
   - LLM.Editor
   - IntelligentProjectAnalyzer
+  - AssetBank
+  mAnalyzeScripts: 1
+  mAnalyzePrefabs: 1
+  mAnalyzeScriptableObjects: 1
+  mAnalyzeMiscellaneous: 1

+ 10 - 0
Assets/IntelligentProjectAnalyzer/Editor/AnalyzerSettingsProvider.cs

@@ -41,6 +41,16 @@ namespace IntelligentProjectAnalyzer.Editor
             EditorGUILayout.HelpBox("Add additional namespace prefixes to be ignored by the analyzer (e.g., 'MyCompany.CoreLib').", MessageType.Info);
             
             EditorGUILayout.PropertyField(_mSettings.FindProperty("mCustomSystemTypes"), new GUIContent("Ignored Namespaces"), true);
+            
+            EditorGUILayout.Space();
+            
+            EditorGUILayout.LabelField("Custom Analysis Rules", EditorStyles.boldLabel);
+            EditorGUILayout.HelpBox("Choose which type of unity types to analyze.", MessageType.Info);
+            
+            EditorGUILayout.PropertyField(_mSettings.FindProperty("mAnalyzeScripts"), new GUIContent("Analyze Scripts"));
+            EditorGUILayout.PropertyField(_mSettings.FindProperty("mAnalyzePrefabs"), new GUIContent("Analyze Prefabs"));
+            EditorGUILayout.PropertyField(_mSettings.FindProperty("mAnalyzeScriptableObjects"), new GUIContent("Analyze Scriptable Objects"));
+            EditorGUILayout.PropertyField(_mSettings.FindProperty("mAnalyzeMiscellaneous"), new GUIContent("Analyze Other Assets"));
 
             if (_mSettings.hasModifiedProperties)
             {

+ 18 - 0
Assets/IntelligentProjectAnalyzer/Editor/DependencyStoreBuilder.cs

@@ -60,6 +60,24 @@ namespace IntelligentProjectAnalyzer.Editor
             DependencyCacheManager.CleanAndPrepareCache();
 
             (_scriptGuidsToProcess, _prefabGuidsToProcess, _soGuidsToProcess, _sceneGuidsToProcess, _miscGuidsToProcess) = AssetDataFetcher.FindAssetGuids();
+            
+            var analyzerSettings = AnalyzerSettingsCrud.GetOrCreateSettings();
+            if (!analyzerSettings.AnalyzeScripts)
+            {
+                _scriptGuidsToProcess?.Clear();
+            }
+            if (!analyzerSettings.AnalyzePrefabs)
+            {
+                _prefabGuidsToProcess?.Clear();
+            }
+            if (!analyzerSettings.AnalyzeScriptableObjects)
+            {
+                _soGuidsToProcess?.Clear();
+            }
+            if (!analyzerSettings.AnalyzeMiscellaneous)
+            {
+                _miscGuidsToProcess?.Clear();
+            }
 
             _allMetadata = new List<AssetMetadata>();
             _scriptMetadata = new List<ScriptMetadata>();

+ 163 - 0
JSON_GENERATION_README.md

@@ -0,0 +1,163 @@
+# Project JSON Representation for LLM Analysis
+
+This document outlines the structure and schema of the JSON files generated to represent the Unity project in a machine-readable format. The primary goal of this JSON-ification is to allow Large Language Models (LLMs) to better understand, analyze, and process the project's structure, assets, and dependencies.
+
+## 1. Project Data Export (`ProjectDataExport`)
+
+This directory contains a JSON representation of the Unity project's assets. Each asset file (e.g., `.unity`, `.prefab`, `.asset`, `.meta`) is converted into a corresponding `.json` file. These JSON files are structured as an array of objects, where each object corresponds to a document in Unity's YAML text serialization format.
+
+### General Asset Schema
+
+Most generated JSON files follow this basic structure:
+
+```json
+[
+  {
+    "type_id": "...",
+    "anchor_id": "...",
+    "data": {
+      "ObjectType": {
+        "property1": "value1",
+        "property2": { ... }
+      }
+    }
+  },
+  ...
+]
+```
+
+-   **`type_id`**: A string representing Unity's internal class ID for the object type (e.g., "1" for `GameObject`, "4" for `Transform`, "114" for `MonoBehaviour`).
+-   **`anchor_id`**: A string representing the unique anchor or `fileID` for this object within the asset file. This ID is used to create references between objects.
+-   **`data`**: An object containing the serialized data. The key is the object's type (e.g., `GameObject`, `RenderSettings`), and the value contains its properties.
+
+### Specific File Schemas
+
+#### Scene (`.unity`) or Prefab (`.prefab`)
+
+Scene and Prefab files are converted into a JSON array that describes their GameObjects, components, and settings.
+
+**Example Schema (`SampleScene.unity.json`):**
+```json
+[
+  {
+    "type_id": "104",
+    "anchor_id": "2",
+    "data": {
+      "RenderSettings": { ... }
+    }
+  },
+  {
+    "type_id": "1",
+    "anchor_id": "330585543",
+    "data": {
+      "GameObject": {
+        "m_Name": "Main Camera",
+        "m_Component": [
+          { "component": { "fileID": "330585546" } },
+          { "component": { "fileID": "330585545" } }
+        ],
+        ...
+      }
+    }
+  },
+  {
+    "type_id": "4",
+    "anchor_id": "330585546",
+    "data": {
+      "Transform": {
+        "m_GameObject": { "fileID": "330585543" },
+        "m_LocalPosition": { "x": 0, "y": 1, "z": -10 },
+        ...
+      }
+    }
+  },
+  {
+    "type_id": "20",
+    "anchor_id": "330585545",
+    "data": {
+      "Camera": {
+        "m_GameObject": { "fileID": "330585543" },
+        ...
+      }
+    }
+  }
+]
+```
+-   The array contains definitions for scene-wide settings (like `RenderSettings`, `LightmapSettings`) and all GameObjects and their components.
+-   A `GameObject` is defined with its properties and a list of its components. The components are referenced by their `fileID` (which corresponds to an `anchor_id` of another object in the file).
+-   Each `Component` (e.g., `Transform`, `Camera`, `MonoBehaviour`) has a reference back to its parent `GameObject` via a `m_GameObject` field containing the `fileID`.
+
+#### Project Settings (`.asset`)
+
+Project settings files (like `AudioManager.asset`) are also converted into a JSON array.
+
+**Example Schema (`AudioManager.asset.json`):**
+```json
+[
+  {
+    "type_id": "11",
+    "anchor_id": "1",
+    "data": {
+      "AudioManager": {
+        "m_Volume": 1,
+        "Rolloff Scale": 1,
+        ...
+      }
+    }
+  }
+]
+```
+-   This structure is simpler, usually containing one object that defines the settings for a specific manager.
+
+#### Meta File (`.meta`)
+
+A `.meta` file's JSON representation contains the asset's `guid` and importer settings. It has a slightly different structure, without the `type_id` and `anchor_id`.
+
+**Example Schema (`SampleScene.unity.meta.json`):**
+```json
+[
+  {
+    "data": {
+      "fileFormatVersion": 2,
+      "guid": "99c9720ab356a0642a771bea13969a05",
+      "DefaultImporter": {
+        "externalObjects": {},
+        "userData": null,
+        "assetBundleName": null,
+        "assetBundleVariant": null
+      }
+    }
+  }
+]
+```
+-   **`guid`**: The unique identifier for the asset in the Unity project. This is crucial for tracking dependencies.
+-   **`DefaultImporter`** (or a specific importer type): Contains the settings for how the associated asset is imported into Unity.
+
+---
+
+## 2. Dependency Cache (`DependencyCache`)
+
+This directory contains JSON files that map out the dependency graph of the entire project. A dependency file is generated for every asset type, providing a complete picture of how assets reference each other.
+
+This cache is built by analyzing every asset in the project and recording all the other assets it depends on.
+
+### Schema Overview
+
+The dependency information is stored in a JSON file where each key is the GUID of an asset. The value is an object containing lists of dependency and referencer GUIDs. The GUID can be used to look up in the Project Exported Data to find the exact attributes of the asset.
+
+**Schema:**
+```json
+{
+  "AssetTypeIndex": 4,
+  "JsonData": "{\"Guid\":\"0a0f5a0711f844690b4fa78f78c922f5\",\"DependencyGuids\":[]}"
+}
+```
+- **`AssetTypeIndex`**: The internal type of unity asset.
+- *`0`*: Script
+- *`1`*: Prefab
+- *`2`*: Scene
+- *`3`*: ScriptableObject
+- *`4`*: Every other asset type
+- **`JsonData`**: A JSON object containing the following fields:
+  - **`Guid`**: The GUID of the asset.
+  - **`DependencyGuids`**: The GUIDs of all assets that this asset depends on.