Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
- [Core] handle HasMesh exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
Razmoth committed Feb 6, 2024
1 parent 3d5a1bc commit 14a6115
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions AssetStudio/Classes/GameObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,35 @@ public GameObject(ObjectReader reader) : base(reader)
public bool HasModel() => HasMesh(m_Transform, new List<bool>());
private static bool HasMesh(Transform m_Transform, List<bool> meshes)
{
m_Transform.m_GameObject.TryGet(out var m_GameObject);

if (m_GameObject.m_MeshRenderer != null)
try
{
var mesh = GetMesh(m_GameObject.m_MeshRenderer);
meshes.Add(mesh != null);
}
m_Transform.m_GameObject.TryGet(out var m_GameObject);

if (m_GameObject.m_SkinnedMeshRenderer != null)
{
var mesh = GetMesh(m_GameObject.m_SkinnedMeshRenderer);
meshes.Add(mesh != null);
}
if (m_GameObject.m_MeshRenderer != null)
{
var mesh = GetMesh(m_GameObject.m_MeshRenderer);
meshes.Add(mesh != null);
}

if (m_GameObject.m_SkinnedMeshRenderer != null)
{
var mesh = GetMesh(m_GameObject.m_SkinnedMeshRenderer);
meshes.Add(mesh != null);
}

foreach (var pptr in m_Transform.m_Children)
foreach (var pptr in m_Transform.m_Children)
{
if (pptr.TryGet(out var child))
meshes.Add(HasMesh(child, meshes));
}

return meshes.Any(x => x == true);
}
catch(Exception e)
{
if (pptr.TryGet(out var child))
meshes.Add(HasMesh(child, meshes));
Logger.Warning($"Unable to verify if {m_Transform?.Name} has meshes, skipping...");
return false;
}

return meshes.Any(x => x == true);
}

private static Mesh GetMesh(Renderer meshR)
Expand Down

0 comments on commit 14a6115

Please sign in to comment.