add ImportingMenuTools

This commit is contained in:
in0finite 2022-02-27 21:54:04 +01:00
parent fe3e6ddb22
commit f4772d63f6
2 changed files with 68 additions and 0 deletions

View file

@ -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<Clump>(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);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7493733e749ce54ba8263086dc477ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: