add some stats

This commit is contained in:
in0finite 2022-01-16 19:26:25 +01:00
parent 8531e758e2
commit b3fb1870d6

View file

@ -2,6 +2,7 @@
using SanAndreasUnity.Utilities; using SanAndreasUnity.Utilities;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using UnityEditor; using UnityEditor;
@ -22,6 +23,9 @@ namespace SanAndreasUnity.Editor
private CoroutineInfo m_coroutineInfo; private CoroutineInfo m_coroutineInfo;
private int m_numNewlyExportedAssets = 0;
private int m_numAlreadyExportedAssets = 0;
private bool m_exportFromSelection = false; private bool m_exportFromSelection = false;
private bool m_exportCollisionMeshes = true; private bool m_exportCollisionMeshes = true;
@ -106,6 +110,9 @@ namespace SanAndreasUnity.Editor
{ {
yield return null; yield return null;
m_numNewlyExportedAssets = 0;
m_numAlreadyExportedAssets = 0;
if (string.IsNullOrWhiteSpace(m_selectedFolder)) if (string.IsNullOrWhiteSpace(m_selectedFolder))
{ {
EditorUtility.DisplayDialog("", "Select a folder first.", "Ok"); EditorUtility.DisplayDialog("", "Select a folder first.", "Ok");
@ -157,6 +164,8 @@ namespace SanAndreasUnity.Editor
if (EditorApplication.isPlaying) if (EditorApplication.isPlaying)
EditorApplication.isPaused = true; EditorApplication.isPaused = true;
var stopwatch = Stopwatch.StartNew();
EditorUtility.DisplayProgressBar("", "Creating folders...", 0f); EditorUtility.DisplayProgressBar("", "Creating folders...", 0f);
this.CreateFolders(); this.CreateFolders();
@ -196,7 +205,9 @@ namespace SanAndreasUnity.Editor
AssetDatabase.Refresh(); AssetDatabase.Refresh();
EditorUtility.ClearProgressBar(); EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("", "Finished !", "Ok"); string displayText = $"number of newly exported asssets {m_numNewlyExportedAssets}, number of already exported assets {m_numAlreadyExportedAssets}, time elapsed {stopwatch.Elapsed}";
UnityEngine.Debug.Log($"Exporting of assets finished, {displayText}");
EditorUtility.DisplayDialog("", $"Finished ! \r\n{displayText}", "Ok");
} }
void CreateFolders() void CreateFolders()
@ -272,16 +283,21 @@ namespace SanAndreasUnity.Editor
meshRenderer.sharedMaterials = mats; meshRenderer.sharedMaterials = mats;
} }
private static Object CreateAssetIfNotExists(Object asset, string path) private Object CreateAssetIfNotExists(Object asset, string path)
{ {
if (AssetDatabase.Contains(asset)) if (AssetDatabase.Contains(asset))
return asset; return asset;
if (File.Exists(Path.Combine(Application.dataPath + "/../", path))) if (File.Exists(Path.Combine(Application.dataPath + "/../", path)))
{
m_numAlreadyExportedAssets++;
return AssetDatabase.LoadMainAssetAtPath(path); return AssetDatabase.LoadMainAssetAtPath(path);
}
AssetDatabase.CreateAsset(asset, path); AssetDatabase.CreateAsset(asset, path);
m_numNewlyExportedAssets++;
return AssetDatabase.LoadMainAssetAtPath(path); return AssetDatabase.LoadMainAssetAtPath(path);
} }
} }