using UnityEditor; using System.Collections.Generic; namespace FBXImporter { public class FBXDropWatcher : AssetPostprocessor { static readonly List _pendingNewFBX = new List(); static bool _dialogScheduled = false; bool ShouldWatch() { return assetPath.StartsWith("Assets/") && assetPath.EndsWith(".fbx", System.StringComparison.OrdinalIgnoreCase) && !ProcessedFBXRegistry.IsRegistered(assetPath); } void OnPreprocessModel() { if (!ShouldWatch()) return; var importer = assetImporter as ModelImporter; importer.importCameras = false; importer.importLights = false; importer.importNormals = ModelImporterNormals.Import; importer.importTangents = ModelImporterTangents.CalculateMikk; importer.importBlendShapes = true; importer.importVisibility = true; importer.materialImportMode = ModelImporterMaterialImportMode.ImportViaMaterialDescription; importer.materialLocation = ModelImporterMaterialLocation.External; importer.materialName = ModelImporterMaterialName.BasedOnMaterialName; importer.materialSearch = ModelImporterMaterialSearch.RecursiveUp; importer.useFileScale = true; importer.globalScale = 1f; } void OnPostprocessModel(UnityEngine.GameObject root) { if (!ShouldWatch()) return; if (!_pendingNewFBX.Contains(assetPath)) _pendingNewFBX.Add(assetPath); if (!_dialogScheduled) { _dialogScheduled = true; EditorApplication.delayCall += ShowBatchDialog; } } static void ShowBatchDialog() { _dialogScheduled = false; if (_pendingNewFBX.Count == 0) return; var batch = new List(_pendingNewFBX); _pendingNewFBX.Clear(); // Register all immediately — won't appear again regardless of user choice ProcessedFBXRegistry.Register(batch); FBXBatchDialog.Show(batch); } } }