using UnityEditor; using System.Linq; namespace FBXImporter { public static class FBXContextMenu { [MenuItem("Assets/FBX Importer/Process this FBX", false, 1000)] static void ProcessSingle() { foreach (var obj in Selection.objects) { string path = AssetDatabase.GetAssetPath(obj); if (!path.EndsWith(".fbx", System.StringComparison.OrdinalIgnoreCase) && !path.EndsWith(".obj", System.StringComparison.OrdinalIgnoreCase)) continue; var source = FBXSourceDetector.Detect(path); FBXImportDialog.Show(path, source); } } [MenuItem("Assets/FBX Importer/Process this FBX", true)] static bool ProcessSingleValidate() => Selection.objects.Any(o => AssetDatabase.GetAssetPath(o) .EndsWith(".fbx", System.StringComparison.OrdinalIgnoreCase) || AssetDatabase.GetAssetPath(o).EndsWith(".obj", System.StringComparison.OrdinalIgnoreCase)); [MenuItem("Assets/FBX Importer/Remove from registry", false, 1001)] static void RemoveFromRegistry() { foreach (var obj in Selection.objects) { string path = AssetDatabase.GetAssetPath(obj); if (path.EndsWith(".fbx", System.StringComparison.OrdinalIgnoreCase) || path.EndsWith(".obj", System.StringComparison.OrdinalIgnoreCase)) ProcessedFBXRegistry.Unregister(path); } } [MenuItem("Assets/FBX Importer/Remove from registry", true)] static bool RemoveFromRegistryValidate() => Selection.objects.Any(o => AssetDatabase.GetAssetPath(o) .EndsWith(".fbx", System.StringComparison.OrdinalIgnoreCase) || AssetDatabase.GetAssetPath(o).EndsWith(".obj", System.StringComparison.OrdinalIgnoreCase)); [MenuItem("Assets/FBX Importer/Create Asset Folder Structure", false, 1020)] static void CreateFolderStructure() { string selectedPath = GetSelectedFolderPath(); if (string.IsNullOrEmpty(selectedPath)) return; string parent = System.IO.Path.GetDirectoryName(selectedPath).Replace("\\", "/"); FolderSetup.Create(parent, System.IO.Path.GetFileName(selectedPath), false); } [MenuItem("Assets/FBX Importer/Create Asset Folder Structure", true)] static bool CreateFolderStructureValidate() => !string.IsNullOrEmpty(GetSelectedFolderPath()); static string GetSelectedFolderPath() { if (Selection.activeObject == null) return null; string path = AssetDatabase.GetAssetPath(Selection.activeObject); return AssetDatabase.IsValidFolder(path) ? path : null; } } }