Skip to content

Backend consistency #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ bld/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# Rider
/.idea

# Visual Studio 2017 auto generated files
Generated\ Files/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public AssetRipperGenerator(string unityVersionString) : base(unityVersionString
var nameSpace = lastDot == -1 ? "" : fullName.Substring(0, lastDot);
var className = lastDot == -1 ? fullName : fullName.Substring(lastDot + 1);

var assemblyNameNormalized = assemblyName.EndsWith(".dll") ? assemblyName[..^".dll".Length] : assemblyName;

var type = FindType(assemblyName, nameSpace, className);
var type = FindType(assemblyNameNormalized, nameSpace, className);
if (type == null)
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public override void LoadDll(Stream dllStream)

public override List<TypeTreeNode>? GenerateTreeNodes(string assemblyName, string fullName)
{
var typeDef = GetTypeDefinition(assemblyName, fullName);
var assemblyNameNormalized = assemblyName.EndsWith(".dll") ? assemblyName : $"{assemblyName}.dll";

var typeDef = GetTypeDefinition(assemblyNameNormalized, fullName);
if (typeDef != null)
{
return GenerateTreeNodes(typeDef);
Expand Down Expand Up @@ -80,12 +82,8 @@ private static bool IsMonoBehaviour(TypeDefinition type)

private List<TypeTreeNode> GenerateTreeNodes(TypeDefinition typeDef)
{
// from AssetStudioUtility.MonoBehaviourConverter
var m_Nodes = new List<TypeTreeNode>();
serializedTypeHelper.AddMonoBehaviour(m_Nodes, 0);
var converter = new TypeDefinitionConverter(typeDef, serializedTypeHelper, 1);
m_Nodes.AddRange(converter.ConvertToTypeTreeNodes());
return m_Nodes;
return converter.ConvertToTypeTreeNodes();
}

private TypeDefinition? GetTypeDefinition(string assemblyName, string fullName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ public SerializedTypeHelper(int[] version)
this.version = version;
}

public void AddMonoBehaviour(List<TypeTreeNode> nodes, int indent)
{
nodes.Add(new TypeTreeNode("MonoBehaviour", "Base", indent, false));
AddPPtr(nodes, "GameObject", "m_GameObject", indent + 1);
nodes.Add(new TypeTreeNode("UInt8", "m_Enabled", indent + 1, true));
AddPPtr(nodes, "MonoScript", "m_Script", indent + 1);
AddString(nodes, "m_Name", indent + 1);
}

public void AddPPtr(List<TypeTreeNode> nodes, string type, string name, int indent)
{
nodes.Add(new TypeTreeNode($"PPtr<{type}>", name, indent, false));
Expand Down