mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 12:03:04 +00:00
add ImportingMenuTools
This commit is contained in:
parent
fe3e6ddb22
commit
f4772d63f6
2 changed files with 68 additions and 0 deletions
57
Assets/Scripts/Editor/ImportingMenuTools.cs
Normal file
57
Assets/Scripts/Editor/ImportingMenuTools.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Editor/ImportingMenuTools.cs.meta
Normal file
11
Assets/Scripts/Editor/ImportingMenuTools.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d7493733e749ce54ba8263086dc477ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue