Files
2024-08-23 15:49:34 +08:00

42 lines
1.2 KiB
C#

using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
public class BundleDebugManager : MonoBehaviour
{
private readonly List<string> bundles = new List<string>();
private readonly HashSet<string> ignoreBundles = new HashSet<string>();
private int _index;
private static BundleDebugManager _instance;
private void Awake()
{
_instance = this;
DontDestroyOnLoad(gameObject);
}
private void OnGUI()
{
if (GUILayout.Button("Record Bundles"))
{
var builder = new StringBuilder();
foreach (var bundle in bundles)
{
builder.AppendLine(bundle);
ignoreBundles.Add(bundle);
}
bundles.Clear();
File.WriteAllText(Application.dataPath.MoveUp().Open(string.Format("Record_{0}.txt", _index)), builder.ToString());
_index++;
}
}
public static void AppendBundle(string bundle)
{
if (_instance &&
!_instance.bundles.Contains(bundle) &&
!_instance.ignoreBundles.Contains(bundle))
_instance.bundles.Add(bundle);
}
}