From f4772d63f6a01595fe52b51a51ae3e0e679b95ee Mon Sep 17 00:00:00 2001 From: in0finite Date: Sun, 27 Feb 2022 21:54:04 +0100 Subject: [PATCH] add ImportingMenuTools --- Assets/Scripts/Editor/ImportingMenuTools.cs | 57 +++++++++++++++++++ .../Scripts/Editor/ImportingMenuTools.cs.meta | 11 ++++ 2 files changed, 68 insertions(+) create mode 100644 Assets/Scripts/Editor/ImportingMenuTools.cs create mode 100644 Assets/Scripts/Editor/ImportingMenuTools.cs.meta diff --git a/Assets/Scripts/Editor/ImportingMenuTools.cs b/Assets/Scripts/Editor/ImportingMenuTools.cs new file mode 100644 index 00000000..3b814434 --- /dev/null +++ b/Assets/Scripts/Editor/ImportingMenuTools.cs @@ -0,0 +1,57 @@ +using SanAndreasUnity.Importing.Archive; +using SanAndreasUnity.Importing.RenderWareStream; +using SanAndreasUnity.Utilities; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace SanAndreasUnity.Editor +{ + public class ImportingMenuTools + { + private const string MenuItemPrefix = EditorCore.MenuName + "/Importing/"; + + + static void DisplayMessage(string msg) + { + EditorUtility.DisplayDialog("", msg, "Ok"); + } + + [MenuItem(MenuItemPrefix + "List clumps with collision")] + static void ListClumpsWithCollision() + { + var dffList = ArchiveManager.GetFileNamesWithExtension(".dff"); + + if (!EditorUtility.DisplayDialog("", $"Found {dffList.Count} DFF files.\r\nProceed ?", "Ok", "Cancel")) + return; + + var found = new List<(Clump clump, string dffName)>(); + + int i = 0; + foreach (string fileName in dffList) + { + Clump clump = null; + F.RunExceptionSafe(() => clump = ArchiveManager.ReadFile(fileName)); + if (clump != null && clump.Collision != null) + found.Add((clump, fileName)); + + if (EditorUtility.DisplayCancelableProgressBar("", $"{fileName} , found {found.Count}", i / (float)dffList.Count)) + { + break; + } + + i++; + } + + string msg = $"Finished searching for clumps with collision: num DFF files {dffList.Count}, num with collision {found.Count}"; + Debug.Log(msg); + + string logMsg = $"DFF | collision name | model id :\r\n{string.Join("\r\n", found.Select(_ => _.dffName + " | " + _.clump.Collision.Name + " | " + _.clump.Collision.ModelId))}"; + Debug.Log(logMsg); + + DisplayMessage(msg); + } + } +} diff --git a/Assets/Scripts/Editor/ImportingMenuTools.cs.meta b/Assets/Scripts/Editor/ImportingMenuTools.cs.meta new file mode 100644 index 00000000..60c08c69 --- /dev/null +++ b/Assets/Scripts/Editor/ImportingMenuTools.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d7493733e749ce54ba8263086dc477ae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: