Last active
October 26, 2023 03:50
-
-
Save xiaoxiao921/499361341751761f12514caaec8afb7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Awake method of your mod | |
RoR2Application.onLoad += Thing; | |
// Code partially taken from https://github.com/PassivePicasso/ThunderKit/blob/master/Editor/Addressable/Tools/AddressableBrowser.cs | |
private void Thing() | |
{ | |
var assetlazy = Addressables.LoadAssetAsync<UnityEngine.Object>("RoR2/Base/Huntress/Skins.Huntress.Alt1.asset").WaitForCompletion(); | |
//Logger.LogError(assetlazy); | |
var sb = new StringBuilder(); | |
var i = 0; | |
using (var table = new Table(sb)) | |
{ | |
using (var headerRow = table.AddRow()) | |
{ | |
headerRow.AddCell("Key"); | |
headerRow.AddCell("Type"); | |
} | |
Logger.LogError("Starting DUMPING"); | |
foreach (var item in Addressables.ResourceLocators) | |
{ | |
var set = new HashSet<IResourceLocation>(); | |
switch (item) | |
{ | |
case ResourceLocationMap rlm: | |
foreach (var location in rlm.Locations.SelectMany(loc => loc.Value).Where(val => val.ResourceType != typeof(IAssetBundleResource))) | |
set.Add(location); | |
break; | |
} | |
var l = set.ToArray(); | |
static bool IsLoadableAsset(IResourceLocation key) | |
{ | |
return key.ResourceType != typeof(SceneInstance) && | |
key.ResourceType != typeof(IAssetBundleResource) && | |
key.ProviderId != "UnityEngine.ResourceManagement.ResourceProviders.LegacyResourcesProvider" && | |
typeof(Object).IsAssignableFrom(key.ResourceType); | |
} | |
foreach (var key in l) | |
{ | |
try | |
{ | |
i++; | |
if (IsLoadableAsset(key)) | |
{ | |
var asset = Addressables.LoadAssetAsync<UnityObject>(key).WaitForCompletion(); | |
using (var row = table.AddRow()) | |
{ | |
row.AddCell(key.PrimaryKey); | |
row.AddCell(key.ResourceType.FullName); | |
} | |
} | |
} | |
catch (Exception) | |
{ | |
} | |
} | |
} | |
} | |
Logger.LogError(sb.ToString()); | |
} | |
public class Table : IDisposable { | |
private StringBuilder _sb; | |
public Table(StringBuilder sb, string id = "default", string classValue = "") { | |
_sb = sb; | |
_sb.Append($"<table id=\"{id}\" class=\"{classValue}\">\n"); | |
} | |
public void Dispose() { | |
_sb.Append("</table>"); | |
} | |
public Row AddRow() { | |
return new Row(_sb); | |
} | |
public Row AddHeaderRow() { | |
return new Row(_sb, true); | |
} | |
public void StartTableBody() { | |
_sb.Append("<tbody>"); | |
} | |
public void EndTableBody() { | |
_sb.Append("</tbody>"); | |
} | |
} | |
public class Row : IDisposable { | |
private StringBuilder _sb; | |
private bool _isHeader; | |
public Row(StringBuilder sb, bool isHeader = false) { | |
_sb = sb; | |
_isHeader = isHeader; | |
if (_isHeader) { | |
_sb.Append("<thead>\n"); | |
} | |
_sb.Append("\t<tr>\n"); | |
} | |
public void Dispose() { | |
_sb.Append("\t</tr>\n"); | |
if (_isHeader) { | |
_sb.Append("</thead>\n"); | |
} | |
} | |
public void AddCell(string innerText) { | |
_sb.Append("\t\t<td>\n"); | |
_sb.Append("\t\t\t" + innerText); | |
_sb.Append("\t\t</td>\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment