Przeglądaj źródła

Sujith :) ->
1. Json data trimmer
2. Lot, I mean really lot of changes that I cannot manually add to the git changes list

Sujith:) 1 tydzień temu
rodzic
commit
b84ecb1fab

+ 6 - 22
Assets/AssetBank/Assets/ComponentWhitelistSettings.asset

@@ -10,83 +10,67 @@ MonoBehaviour:
   m_Enabled: 1
   m_EditorHideFlags: 0
   m_Script: {fileID: 11500000, guid: 7571dc5d989934e52969681034da6a8f, type: 3}
-  m_Name: ComponentWhitelistSettings
+  m_Name: ComponentStatsSettings
   m_EditorClassIdentifier: 
-  m_AllowAllComponents: 1
   m_ComponentStats:
   - Name: AudioListener
-    IsWhitelisted: 1
     TotalOccurrences: 1
     MaxProperties: 10
     TotalProperties: 10
   - Name: BoxCollider
-    IsWhitelisted: 1
     TotalOccurrences: 3
     MaxProperties: 22
     TotalProperties: 66
   - Name: Camera
-    IsWhitelisted: 1
     TotalOccurrences: 1
     MaxProperties: 54
     TotalProperties: 54
   - Name: GameObject
-    IsWhitelisted: 1
-    TotalOccurrences: 10
+    TotalOccurrences: 11
     MaxProperties: 27
-    TotalProperties: 240
+    TotalProperties: 259
   - Name: Light
-    IsWhitelisted: 1
     TotalOccurrences: 1
     MaxProperties: 76
     TotalProperties: 76
   - Name: LightmapSettings
-    IsWhitelisted: 1
     TotalOccurrences: 1
     MaxProperties: 60
     TotalProperties: 60
   - Name: MeshFilter
-    IsWhitelisted: 1
     TotalOccurrences: 5
     MaxProperties: 13
     TotalProperties: 65
   - Name: MeshRenderer
-    IsWhitelisted: 1
     TotalOccurrences: 5
     MaxProperties: 51
     TotalProperties: 255
   - Name: MonoBehaviour
-    IsWhitelisted: 1
     TotalOccurrences: 8
     MaxProperties: 39
     TotalProperties: 206
   - Name: NavMeshSettings
-    IsWhitelisted: 1
     TotalOccurrences: 1
     MaxProperties: 23
     TotalProperties: 23
   - Name: OcclusionCullingSettings
-    IsWhitelisted: 1
     TotalOccurrences: 1
     MaxProperties: 9
     TotalProperties: 9
   - Name: PrefabInstance
-    IsWhitelisted: 1
     TotalOccurrences: 1
     MaxProperties: 107
     TotalProperties: 107
   - Name: RenderSettings
-    IsWhitelisted: 1
     TotalOccurrences: 1
     MaxProperties: 56
     TotalProperties: 56
   - Name: SphereCollider
-    IsWhitelisted: 1
     TotalOccurrences: 1
     MaxProperties: 19
     TotalProperties: 19
   - Name: Transform
-    IsWhitelisted: 1
-    TotalOccurrences: 10
+    TotalOccurrences: 12
     MaxProperties: 32
-    TotalProperties: 312
-  m_LastScanTime: 23-07-2025 18:27
+    TotalProperties: 353
+  m_LastScanTime: 24-07-2025 17:12

+ 1 - 1
Assets/AssetBank/Assets/ComponentWhitelistSettings.asset.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 93944907517ca4b1090d8602a68ebf77
+guid: 62f70ed00979248618095565b8616f45
 NativeFormatImporter:
   externalObjects: {}
   mainObjectFileID: 11400000

+ 14 - 6
Assets/AssetBank/Assets/ProjectExporterSettings.asset

@@ -16,21 +16,29 @@ MonoBehaviour:
   m_CategoriesToOptimise:
   - Scenes
   - Prefabs
-  m_SafeComponents:
+  m_SafeComponents: []
+  m_HardcodedComponents:
   - Component: GameObject
     ExposedFields:
-    - m_Layer
+    - m_Component
     - m_Name
+    - m_Layer
     - m_TagString
     - m_IsActive
-    - m_Component
+  - Component: Transform
+    ExposedFields:
+    - m_Father
+    - m_Children
+    - m_PrefabInstance
+  - Component: PrefabInstance
+    ExposedFields:
+    - m_SourcePrefab
+    - m_TransformParent
   - Component: MonoBehaviour
     ExposedFields:
     - m_Script
     - m_Enabled
-  - Component: PrefabInstance
-    ExposedFields:
-    - '*'
+  m_OverrideHardcodedDefaults: 0
   m_FoldersToIgnore:
   - Assets/AssetBank
   - Assets/IntelligentProjectAnalyzer

+ 2 - 5
Assets/AssetBank/Editor/DockableWindow/ProjectExporterController.cs

@@ -154,10 +154,7 @@ namespace AssetBank.DockableWindow
 
             var outputDirectory = customExportPath ?? Path.Combine(ProjectRoot, "Library", "ProjectDataExport");
             Directory.CreateDirectory(outputDirectory);
-
-            var whitelistSettings = ComponentWhitelistSettings.GetOrCreateSettings();
-            var whitelist = string.Join(",", whitelistSettings.WhitelistedComponents);
-
+            
             EditorUtility.DisplayProgressBar("Exporting...", "Starting export process...", 0f);
 
             try
@@ -179,7 +176,7 @@ namespace AssetBank.DockableWindow
                     }
 
                     var arguments =
-                        $"\"{conversionScript}\" \"{absoluteAssetPath}\" \"{outputJsonPath}\" --whitelist \"{whitelist}\"";
+                        $"\"{conversionScript}\" \"{absoluteAssetPath}\" \"{outputJsonPath}\"";
 
                     var process = new Process
                     {

+ 5 - 19
Assets/AssetBank/Editor/Settings/ComponentWhitelistSettings.cs

@@ -1,23 +1,14 @@
 using System.Collections.Generic;
 using System.IO;
-using System.Linq;
 using AssetBank.Editor.Tools;
 using UnityEditor;
 using UnityEngine;
 
 namespace AssetBank.Settings
 {
-    public class ComponentWhitelistSettings : ScriptableObject
+    public class ComponentStatsSettings : ScriptableObject
     {
-        private const string k_SettingsPath = "Assets/AssetBank/Assets/ComponentWhitelistSettings.asset";
-
-        [SerializeField]
-        private bool m_AllowAllComponents;
-        public bool AllowAllComponents
-        {
-            get => m_AllowAllComponents;
-            set => m_AllowAllComponents = value;
-        }
+        private const string k_SettingsPath = "Assets/AssetBank/Assets/ComponentStatsSettings.asset";
 
         [SerializeField]
         private List<ComponentStats> m_ComponentStats = new();
@@ -31,17 +22,12 @@ namespace AssetBank.Settings
             set => m_LastScanTime = value;
         }
 
-        public IReadOnlyList<string> WhitelistedComponents =>
-            m_AllowAllComponents
-                ? new List<string> { "*" } 
-                : m_ComponentStats.Where(s => s.IsWhitelisted).Select(s => s.Name).ToList();
-
-        internal static ComponentWhitelistSettings GetOrCreateSettings()
+        internal static ComponentStatsSettings GetOrCreateSettings()
         {
-            var settings = AssetDatabase.LoadAssetAtPath<ComponentWhitelistSettings>(k_SettingsPath);
+            var settings = AssetDatabase.LoadAssetAtPath<ComponentStatsSettings>(k_SettingsPath);
             if (settings == null)
             {
-                settings = CreateInstance<ComponentWhitelistSettings>();
+                settings = CreateInstance<ComponentStatsSettings>();
                 var directory = Path.GetDirectoryName(k_SettingsPath);
                 if (!Directory.Exists(directory))
                 {

Assets/AssetBank/Editor/Settings/ComponentWhitelistSettings.cs.meta → Assets/AssetBank/Editor/Settings/ComponentStatsSettings.cs.meta


+ 20 - 47
Assets/AssetBank/Editor/Settings/ComponentWhitelistSettingsProvider.cs

@@ -8,27 +8,27 @@ using UnityEngine;
 namespace AssetBank.Settings
 {
     /// <summary>
-    /// Hosts the Component Whitelister UI within the Project Settings window.
+    /// Hosts the Component Stats UI within the Project Settings window.
     /// </summary>
-    internal class ComponentWhitelistSettingsProvider : SettingsProvider
+    internal class ComponentStatsSettingsProvider : SettingsProvider
     {
-        private ComponentWhitelistController _controller;
-        private ComponentWhitelistController.ScanSource _scanSource = ComponentWhitelistController.ScanSource.Both;
+        private ComponentStatsController _controller;
+        private ComponentStatsController.ScanSource _scanSource = ComponentStatsController.ScanSource.Both;
         
         private Dictionary<string, ComponentStats> _stats = new();
         private Vector2 _scrollPosition;
         private GUIStyle _alternatingRowStyle;
-        private ComponentWhitelistSettings _whitelistSettings;
+        private ComponentStatsSettings _statsSettings;
 
-        const string k_SettingsPath = "Project/Project AssetDatabase/Whitelist Components";
+        const string k_SettingsPath = "Project/Project AssetDatabase/Component Stats";
 
-        public ComponentWhitelistSettingsProvider(string path, SettingsScope scope = SettingsScope.Project)
+        public ComponentStatsSettingsProvider(string path, SettingsScope scope = SettingsScope.Project)
             : base(path, scope) {}
 
         public override void OnActivate(string searchContext, UnityEngine.UIElements.VisualElement rootElement)
         {
-            _controller = new ComponentWhitelistController();
-            _whitelistSettings = ComponentWhitelistSettings.GetOrCreateSettings();
+            _controller = new ComponentStatsController();
+            _statsSettings = ComponentStatsSettings.GetOrCreateSettings();
             LoadStatsFromSettings();
             
             // Create a style for alternating row colors
@@ -44,49 +44,23 @@ namespace AssetBank.Settings
 
         public override void OnGUI(string searchContext)
         {
-            EditorGUILayout.LabelField("Component Whitelist Generator", EditorStyles.boldLabel);
+            EditorGUILayout.LabelField("Component Stats Generator", EditorStyles.boldLabel);
             
-            _whitelistSettings.AllowAllComponents = EditorGUILayout.Toggle("Allow All Components", _whitelistSettings.AllowAllComponents);
-
             EditorGUILayout.Space();
-
-            // If "Allow All" is checked, we don't need to show the rest of the UI.
-            if (_whitelistSettings.AllowAllComponents)
-            {
-                EditorGUILayout.HelpBox("All components are currently allowed. No specific whitelisting is necessary.", MessageType.Info);
-                if (GUI.changed)
-                {
-                    EditorUtility.SetDirty(_whitelistSettings);
-                    AssetDatabase.SaveAssets();
-                }
-                return;
-            }
             
-            EditorGUILayout.HelpBox("Scan project assets to find all unique component types and their statistics. Select the components you want to include in the export.", MessageType.Info);
+            EditorGUILayout.HelpBox("Scan project assets to find all unique component types and their statistics.", MessageType.Info);
 
-            if (!string.IsNullOrEmpty(_whitelistSettings.LastScanTime))
+            if (!string.IsNullOrEmpty(_statsSettings.LastScanTime))
             {
-                EditorGUILayout.HelpBox($"Last Scan: {_whitelistSettings.LastScanTime}", MessageType.None);
+                EditorGUILayout.HelpBox($"Last Scan: {_statsSettings.LastScanTime}", MessageType.None);
             }
 
-            _scanSource = (ComponentWhitelistController.ScanSource)EditorGUILayout.EnumPopup("Asset Source to Scan", _scanSource);
+            _scanSource = (ComponentStatsController.ScanSource)EditorGUILayout.EnumPopup("Asset Source to Scan", _scanSource);
 
             if (GUILayout.Button("Scan Project for Components"))
             {
                 var newStats = _controller.ScanProject(_scanSource);
                 
-                // Preserve the whitelist status of existing components
-                foreach (var newStat in newStats.Values)
-                {
-                    if (_stats.TryGetValue(newStat.Name, out var oldStat))
-                    {
-                        newStat.IsWhitelisted = oldStat.IsWhitelisted;
-                    }
-                    else
-                    {
-                        newStat.IsWhitelisted = true; // Default new components to whitelisted
-                    }
-                }
                 _stats = newStats;
                 
                 // Immediately save the new scan results and update the timestamp
@@ -100,14 +74,14 @@ namespace AssetBank.Settings
 
             EditorGUILayout.Space();
 
-            if (GUILayout.Button("Save Whitelist"))
+            if (GUILayout.Button("Save Stats"))
             {
-                _controller.SaveWhitelistSelections(_stats);
+                _controller.SaveStats(_stats);
             }
             
             if (GUI.changed)
             {
-                EditorUtility.SetDirty(_whitelistSettings);
+                EditorUtility.SetDirty(_statsSettings);
                 AssetDatabase.SaveAssets();
             }
         }
@@ -115,7 +89,6 @@ namespace AssetBank.Settings
         private void DrawHeader()
         {
             EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
-            GUILayout.Label("Whitelist", GUILayout.Width(70));
             GUILayout.Label("Component Name", GUILayout.MinWidth(150), GUILayout.ExpandWidth(true));
             GUILayout.Label("Occurrences", GUILayout.Width(80));
             GUILayout.Label("Max Props", GUILayout.Width(70));
@@ -139,7 +112,6 @@ namespace AssetBank.Settings
                     var style = (i++ % 2 == 0) ? GUIStyle.none : _alternatingRowStyle;
                     EditorGUILayout.BeginHorizontal(style);
                     
-                    stat.IsWhitelisted = EditorGUILayout.Toggle(stat.IsWhitelisted, GUILayout.Width(70));
                     EditorGUILayout.LabelField(stat.Name, GUILayout.MinWidth(150), GUILayout.ExpandWidth(true));
                     EditorGUILayout.LabelField(stat.TotalOccurrences.ToString(), GUILayout.Width(80));
                     EditorGUILayout.LabelField(stat.MaxProperties.ToString(), GUILayout.Width(70));
@@ -153,14 +125,15 @@ namespace AssetBank.Settings
 
         private void LoadStatsFromSettings()
         {
-            _stats = _whitelistSettings.ComponentStats.ToDictionary(s => s.Name, s => s);
+            _stats = _statsSettings.ComponentStats.ToDictionary(s => s.Name, s => s);
         }
 
         [SettingsProvider]
         public static SettingsProvider CreateSettingsProvider()
         {
-            var provider = new ComponentWhitelistSettingsProvider(k_SettingsPath, SettingsScope.Project);
+            var provider = new ComponentStatsSettingsProvider(k_SettingsPath, SettingsScope.Project);
             return provider;
         }
     }
 }
+

Assets/AssetBank/Editor/Settings/ComponentWhitelistSettingsProvider.cs.meta → Assets/AssetBank/Editor/Settings/ComponentStatsSettingsProvider.cs.meta


+ 26 - 1
Assets/AssetBank/Editor/Settings/ProjectExporterSettings.cs

@@ -60,6 +60,14 @@ namespace AssetBank.Settings
         [SerializeField] 
         private List<SafeExposedComponents> m_SafeComponents = new();
         public List<SafeExposedComponents> SafeComponents => m_SafeComponents;
+        
+        [SerializeField] 
+        private List<SafeExposedComponents> m_HardcodedComponents = new();
+        public List<SafeExposedComponents> HardcodedComponents => m_HardcodedComponents;
+
+        [SerializeField] 
+        private bool m_OverrideHardcodedDefaults;
+        public bool OverrideHardcodedDefaults => m_OverrideHardcodedDefaults;
 
         [SerializeField]
         private List<string> m_FoldersToIgnore = new();
@@ -80,7 +88,18 @@ namespace AssetBank.Settings
             if (settings == null)
             {
                 settings = CreateInstance<ProjectExporterSettings>();
+                settings.m_OptimiseExport = true;
                 settings.m_CategoriesToOptimise = new List<string> { "Scenes", "Prefabs" };
+                settings.m_OverrideHardcodedDefaults = false;
+
+                settings.m_HardcodedComponents = new List<SafeExposedComponents>
+                {
+                    new() { Component = "GameObject", ExposedFields = new List<string> { "m_Component", "m_Name", "m_Layer", "m_TagString", "m_IsActive" } },
+                    new() { Component = "Transform", ExposedFields = new List<string> { "m_Father", "m_Children", "m_PrefabInstance" } },
+                    new() { Component = "PrefabInstance", ExposedFields = new List<string> { "m_SourcePrefab", "m_TransformParent" } },
+                    new() { Component = "MonoBehaviour", ExposedFields = new List<string> { "m_Enabled", "m_Script" } }
+                };
+
                 settings.m_SafeComponents = new List<SafeExposedComponents>
                 {
                     new()
@@ -89,9 +108,14 @@ namespace AssetBank.Settings
                         ExposedFields = new List<string> { "m_Layer", "m_Name", "m_TagString", "m_IsActive", "m_Component" }
                     },
                     new()
+                    {
+                        Component = "Transform",
+                        ExposedFields = new List<string> { "m_Father", "m_Children" }
+                    },
+                    new()
                     {
                         Component = "MonoBehaviour",
-                        ExposedFields = new List<string> { "m_Enabled", "m_Script" }
+                        ExposedFields = new List<string> { "*" }
                     },
                     new()
                     {
@@ -99,6 +123,7 @@ namespace AssetBank.Settings
                         ExposedFields = new List<string> { "*" }
                     }
                 };
+                
                 var directory = Path.GetDirectoryName(k_SettingsPath);
                 if (!Directory.Exists(directory))
                 {

+ 15 - 0
Assets/AssetBank/Editor/Settings/ProjectExporterSettingsProvider.cs

@@ -14,6 +14,8 @@ namespace AssetBank.Settings
         private SerializedProperty m_OptimiseExport;
         private SerializedProperty m_CategoriesToOptimise;
         private SerializedProperty m_SafeComponents;
+        private SerializedProperty m_HardcodedComponents;
+        private SerializedProperty m_OverrideHardcodedDefaults;
 
         const string k_SettingsPath = "Project/Project AssetDatabase";
 
@@ -29,6 +31,8 @@ namespace AssetBank.Settings
             m_OptimiseExport = m_Settings.FindProperty("m_OptimiseExport");
             m_CategoriesToOptimise = m_Settings.FindProperty("m_CategoriesToOptimise");
             m_SafeComponents = m_Settings.FindProperty("m_SafeComponents");
+            m_HardcodedComponents = m_Settings.FindProperty("m_HardcodedComponents");
+            m_OverrideHardcodedDefaults = m_Settings.FindProperty("m_OverrideHardcodedDefaults");
         }
 
         public override void OnGUI(string searchContext)
@@ -53,6 +57,17 @@ namespace AssetBank.Settings
             {
                 DrawCategoriesToOptimise();
                 EditorGUILayout.Space();
+
+                EditorGUILayout.LabelField("Hardcoded Rules", EditorStyles.boldLabel);
+                EditorGUILayout.PropertyField(m_OverrideHardcodedDefaults, new GUIContent("Override Defaults", "Check this to ignore the hardcoded safety rules and use only the 'Safe Components' list below. Warning: This can break scene hierarchy if not configured correctly."));
+                
+                EditorGUI.BeginDisabledGroup(true);
+                EditorGUILayout.PropertyField(m_HardcodedComponents, new GUIContent("Hardcoded Safe Components (Read-Only)"), true);
+                EditorGUI.EndDisabledGroup();
+                
+                EditorGUILayout.Space();
+
+                EditorGUILayout.LabelField("User-Defined Rules", EditorStyles.boldLabel);
                 EditorGUILayout.PropertyField(m_SafeComponents, new GUIContent("Safe Components"), true);
             }
 

+ 0 - 1
Assets/AssetBank/Editor/Tools/ComponentStats.cs

@@ -7,7 +7,6 @@ namespace AssetBank.Editor.Tools
     public class ComponentStats
     {
         public string Name;
-        public bool IsWhitelisted;
         public int TotalOccurrences;
         public int MaxProperties;
         public long TotalProperties;

+ 6 - 7
Assets/AssetBank/Editor/Tools/ComponentWhitelistController.cs

@@ -11,9 +11,9 @@ using Newtonsoft.Json.Linq;
 namespace AssetBank.Editor.Tools
 {
     /// <summary>
-    /// Handles the core logic for scanning the project and managing the component whitelist.
+    /// Handles the core logic for scanning the project and managing the component stats.
     /// </summary>
-    public class ComponentWhitelistController
+    public class ComponentStatsController
     {
         private static readonly string ProjectRoot = Path.GetDirectoryName(Application.dataPath);
         
@@ -202,7 +202,7 @@ namespace AssetBank.Editor.Tools
 
         public void UpdateAndSaveScanResults(Dictionary<string, ComponentStats> stats)
         {
-            var settings = ComponentWhitelistSettings.GetOrCreateSettings();
+            var settings = ComponentStatsSettings.GetOrCreateSettings();
             settings.ComponentStats.Clear();
             settings.ComponentStats.AddRange(stats.Values.OrderBy(s => s.Name));
             settings.LastScanTime = DateTime.Now.ToString("g"); // "g" for general short date/time
@@ -211,17 +211,16 @@ namespace AssetBank.Editor.Tools
             AssetDatabase.SaveAssets();
         }
 
-        public void SaveWhitelistSelections(Dictionary<string, ComponentStats> stats)
+        public void SaveStats(Dictionary<string, ComponentStats> stats)
         {
-            var settings = ComponentWhitelistSettings.GetOrCreateSettings();
+            var settings = ComponentStatsSettings.GetOrCreateSettings();
             settings.ComponentStats.Clear();
             settings.ComponentStats.AddRange(stats.Values.OrderBy(s => s.Name));
             
             EditorUtility.SetDirty(settings);
             AssetDatabase.SaveAssets();
 
-            var whitelistedCount = settings.ComponentStats.Count(s => s.IsWhitelisted);
-            EditorUtility.DisplayDialog("Success", $"Whitelist saved with {whitelistedCount} components.", "OK");
+            EditorUtility.DisplayDialog("Success", $"Saved {settings.ComponentStats.Count} component stats.", "OK");
         }
     }
 }

Assets/AssetBank/Editor/Tools/ComponentWhitelistController.cs.meta → Assets/AssetBank/Editor/Tools/ComponentStatsController.cs.meta


+ 113 - 65
Assets/AssetBank/Editor/Tools/JsonDataTrimmer.cs

@@ -2,108 +2,156 @@ using System.Collections.Generic;
 using System.Linq;
 using AssetBank.Settings;
 using Newtonsoft.Json.Linq;
+using UnityEngine;
 
 namespace AssetBank.Editor.Tools
 {
     public static class JsonDataTrimmer
     {
-        // The list of default MonoBehaviour properties to be used for comparison.
-        private static readonly HashSet<string> DefaultMonoBehaviourProperties = new HashSet<string>
-        {
-            "m_ObjectHideFlags",
-            "m_CorrespondingSourceObject",
-            "m_PrefabInstance",
-            "m_PrefabAsset",
-            "m_GameObject",
-            "m_Enabled",
-            "m_EditorHideFlags",
-            "m_Script",
-            "m_Name",
-            "m_EditorClassIdentifier"
-        };
-
         public static string Process(string rawJsonText, ProjectExporterSettings settings)
         {
             var allComponents = JArray.Parse(rawJsonText);
-            var rules = settings.SafeComponents.ToDictionary(r => r.Component, r => r.ExposedFields);
-
-            // Pass 1: Index all components by their anchor_id
-            var componentMap = allComponents.Children<JObject>()
-                .Where(c => c["anchor_id"] != null)
-                .ToDictionary(c => c["anchor_id"].ToString(), c => c);
+            
+            // Pass 1: Build the definitive ruleset
+            var rules = settings.SafeComponents.ToDictionary(r => r.Component, r => r.ExposedFields.ToHashSet());
+            if (!settings.OverrideHardcodedDefaults)
+            {
+                foreach (var hardcodedRule in settings.HardcodedComponents)
+                {
+                    if (rules.TryGetValue(hardcodedRule.Component, out var userRules))
+                    {
+                        userRules.UnionWith(hardcodedRule.ExposedFields);
+                    }
+                    else
+                    {
+                        rules[hardcodedRule.Component] = hardcodedRule.ExposedFields.ToHashSet();
+                    }
+                }
+            }
 
-            // Pass 2: Process and trim each component in the map
-            foreach (var component in componentMap.Values)
+            // Pass 2: Create a fully trimmed copy of every component
+            var trimmedComponentMap = new Dictionary<string, JObject>();
+            foreach (var component in allComponents.Children<JObject>())
             {
-                var dataBlock = (JObject)component["data"];
-                if (dataBlock == null || !dataBlock.HasValues) continue;
+                var anchorId = component["anchor_id"]?.ToString();
+                if (string.IsNullOrEmpty(anchorId)) continue;
+
+                var trimmedComponent = component.DeepClone() as JObject;
+                var dataBlock = trimmedComponent["data"] as JObject;
+                if (dataBlock == null || !dataBlock.HasValues)
+                {
+                    trimmedComponentMap[anchorId] = trimmedComponent;
+                    continue;
+                }
 
                 var componentProperty = dataBlock.Properties().FirstOrDefault();
-                if (componentProperty == null) continue;
+                if (componentProperty == null)
+                {
+                    trimmedComponentMap[anchorId] = trimmedComponent;
+                    continue;
+                }
 
                 var componentName = componentProperty.Name;
-                var componentData = (JObject)componentProperty.Value;
+                var componentJObject = componentProperty.Value as JObject;
+                if (componentJObject == null)
+                {
+                    trimmedComponentMap[anchorId] = trimmedComponent;
+                    continue;
+                }
 
                 if (rules.TryGetValue(componentName, out var exposedFields))
                 {
-                    if (exposedFields.Contains("*")) continue; // Keep everything
-
-                    var newComponentData = new JObject();
-                    if (componentName == "MonoBehaviour")
+                    if (exposedFields.Contains("*"))
                     {
-                        foreach (var field in exposedFields)
-                        {
-                            if (componentData.TryGetValue(field, out var value))
-                                newComponentData.Add(field, value);
-                        }
-                        foreach (var property in componentData.Properties())
-                        {
-                            if (!DefaultMonoBehaviourProperties.Contains(property.Name) && newComponentData[property.Name] == null)
-                                newComponentData.Add(property.Name, property.Value);
-                        }
+                        trimmedComponentMap[anchorId] = trimmedComponent;
+                        continue;
                     }
-                    else
+
+                    var propertiesToKeep = new HashSet<string>(exposedFields);
+                    var currentKeys = componentJObject.Properties().Select(p => p.Name).ToList();
+                    foreach (var key in currentKeys)
                     {
-                        foreach (var field in exposedFields)
+                        if (!propertiesToKeep.Contains(key))
                         {
-                            if (componentData.TryGetValue(field, out var value))
-                                newComponentData.Add(field, value);
+                            componentJObject.Remove(key);
                         }
                     }
-                    dataBlock[componentName] = newComponentData;
                 }
                 else
                 {
-                    dataBlock[componentName] = new JObject();
+                    componentJObject.RemoveAll();
                 }
+                trimmedComponentMap[anchorId] = trimmedComponent;
             }
-
-            // Pass 3: Build the final list of GameObjects with embedded components
+            
+            // Pass 3: Final Assembly
             var finalOutput = new JArray();
-            foreach (var component in componentMap.Values)
+            var embeddedIds = new HashSet<string>();
+
+            // First, identify all components that will be embedded into GameObjects
+            foreach (var originalComponent in allComponents.Children<JObject>())
+            {
+                if (originalComponent["data"]?["GameObject"]?["m_Component"] is JArray componentList)
+                {
+                    foreach (var compRef in componentList.Children<JObject>())
+                    {
+                        if (compRef["component"]?["fileID"]?.ToString() is var fileID && !string.IsNullOrEmpty(fileID))
+                        {
+                            embeddedIds.Add(fileID);
+                        }
+                    }
+                }
+            }
+
+            // Now, build the final output, preserving order
+            foreach (var originalComponent in allComponents.Children<JObject>())
             {
-                var dataBlock = (JObject)component["data"];
-                if (dataBlock?["GameObject"] == null) continue; // We only want GameObjects in the final list
+                var anchorId = originalComponent["anchor_id"]?.ToString();
+                if (string.IsNullOrEmpty(anchorId) || embeddedIds.Contains(anchorId))
+                {
+                    // If a component has no ID, or it's a child of a GameObject, skip it.
+                    // Children will be added via their parent GameObject.
+                    continue;
+                }
 
-                var gameObjectData = (JObject)dataBlock["GameObject"];
-                var componentList = (JArray)gameObjectData["m_Component"];
-                
-                if (componentList == null) continue;
+                // Get the trimmed version of the current component
+                if (!trimmedComponentMap.TryGetValue(anchorId, out var trimmedComponent))
+                {
+                    // Should not happen, but as a safeguard, add the original.
+                    finalOutput.Add(originalComponent.DeepClone());
+                    continue;
+                }
 
-                var newComponentList = new JArray();
-                foreach (var compRef in componentList.Children<JObject>())
+                // If it's a GameObject, embed its already-trimmed children
+                if (originalComponent["data"]?["GameObject"] is JObject originalGameObjectData)
                 {
-                    var fileID = compRef["component"]?["fileID"]?.ToString();
-                    if (fileID != null && componentMap.TryGetValue(fileID, out var linkedComponent))
+                    var trimmedGameObjectData = trimmedComponent["data"]["GameObject"] as JObject;
+                    var componentList = originalGameObjectData["m_Component"] as JArray;
+                    if (trimmedGameObjectData != null && componentList != null)
                     {
-                        // Add a clone of the linked component's 'data' object
-                        newComponentList.Add(linkedComponent["data"].DeepClone());
+                        var newComponentList = new JArray();
+                        var gameObjectName = originalGameObjectData["m_Name"]?.ToString() ?? "Unnamed";
+                        foreach (var compRef in componentList.Children<JObject>())
+                        {
+                            var fileID = compRef["component"]?["fileID"]?.ToString();
+                            if (string.IsNullOrEmpty(fileID)) continue;
+
+                            if (trimmedComponentMap.TryGetValue(fileID, out var linkedComponent))
+                            {
+                                var clonedData = linkedComponent["data"].DeepClone() as JObject;
+                                (clonedData?.Properties().FirstOrDefault()?.Value as JObject)?.Remove("m_GameObject");
+                                newComponentList.Add(clonedData);
+                            }
+                            else
+                            {
+                                Debug.LogWarning($"JsonDataTrimmer: Could not find component with anchor_id '{fileID}' referenced by GameObject '{gameObjectName}'.");
+                            }
+                        }
+                        trimmedGameObjectData["m_Component"] = newComponentList;
                     }
                 }
-                // Replace the old list of fileIDs with the new list of embedded data
-                gameObjectData["m_Component"] = newComponentList;
                 
-                finalOutput.Add(component);
+                finalOutput.Add(trimmedComponent);
             }
 
             return finalOutput.ToString(Newtonsoft.Json.Formatting.None);

+ 3 - 1
Assets/AssetBank/Editor/Tools/UnifiedExporter.cs

@@ -104,14 +104,16 @@ namespace AssetBank.Editor.Tools
 
         private void CopyScripts(string savePath)
         {
+            if (!_copyScripts) return;
             var exportPath = _exportScriptsIndependently ? Path.Combine(savePath, "Scripts") : Path.Combine(savePath, "Assets");
             ScriptExporter.ProcessAndCopyScripts(exportPath);
         }
         
         private void ExportGuidMappers(string savePath)
         {
+            if (!_exportAllGuidMappers) return;
             var exportPath = Path.Combine(savePath, "GuidMappers");
-            if (_exportAllGuidMappers) GuidMapperExporter.BulkExport(exportPath);
+            GuidMapperExporter.BulkExport(exportPath);
         }
 
         private void ExportAllOfType(string type, string savePath)

+ 4 - 22
Assets/AssetBank/source/convert_scene.py

@@ -61,20 +61,11 @@ def preprocess_unity_yaml(yaml_content):
 
     return '\n'.join(processed_lines)
 
-def convert_unity_yaml_to_json(yaml_content, whitelist=None):
+def convert_unity_yaml_to_json(yaml_content):
     """
     Parses a Unity YAML file string, preserving fileID references, and returns a JSON string.
     """
     json_data = []
-    
-    whitelist_set = None
-    allow_all = False
-    if whitelist is not None:
-        # If whitelist is an empty string, create an empty set, meaning nothing is whitelisted.
-        # Otherwise, split the string to create the set of whitelisted components.
-        whitelist_set = set(whitelist.split(',')) if whitelist else set()
-        if "*" in whitelist_set:
-            allow_all = True
 
     # First, find all the original headers
     headers = header_pattern.findall(yaml_content)
@@ -129,18 +120,10 @@ def convert_unity_yaml_to_json(yaml_content, whitelist=None):
         if i < len(headers):
             type_id, anchor_id = headers[i]
             
-            component_doc = doc
-            # Check against whitelist if it has been initialized and not allowing all
-            if not allow_all and whitelist_set is not None and isinstance(doc, dict):
-                component_name = next(iter(doc), None)
-                if component_name and component_name not in whitelist_set:
-                    # If not in whitelist, replace data with an empty object
-                    component_doc = {component_name: {}}
-
             structured_doc = {
                 'type_id': type_id,
                 'anchor_id': anchor_id,
-                'data': component_doc
+                'data': doc
             }
             json_data.append(structured_doc)
         else:
@@ -155,7 +138,6 @@ def main():
     parser = argparse.ArgumentParser(description='Convert Unity YAML assets to JSON.')
     parser.add_argument('input_path', type=str, help='Absolute path to the input Unity asset file.')
     parser.add_argument('output_path', type=str, help='Absolute path for the output JSON file.')
-    parser.add_argument('--whitelist', type=str, help='Comma-separated list of component types to include.')
     parser.add_argument('--debug', action='store_true', help='Enable debug output')
     args = parser.parse_args()
 
@@ -175,7 +157,7 @@ def main():
             print(f"Input file size: {len(content)} characters", file=sys.stderr)
             print(f"First 500 characters:\n{content[:500]}", file=sys.stderr)
 
-        json_output = convert_unity_yaml_to_json(content, args.whitelist)
+        json_output = convert_unity_yaml_to_json(content)
 
         with open(output_path, 'w', encoding='utf-8') as f:
             f.write(json_output)
@@ -190,4 +172,4 @@ def main():
         sys.exit(1)
 
 if __name__ == "__main__":
-    main()
+    main()

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

@@ -27,6 +27,7 @@ namespace IntelligentProjectAnalyzer.Editor
         {
             _mSettings ??= new SerializedObject(AnalyzerSettingsCrud.GetOrCreateSettings());
 
+            EditorGUILayout.HelpBox("This settings is used to determine which types are system types, when the code is analyzed to find the dependencies till it reaches the root (e.g., 'System', 'UnityEngine', 'UnityEditor').", MessageType.Info);
             EditorGUILayout.LabelField("Default System Types", EditorStyles.boldLabel);
             
             EditorGUI.BeginDisabledGroup(true);