fix: support renderers other than SMR (#1042)

This commit is contained in:
nekobako 2024-08-26 10:04:04 +09:00 committed by GitHub
parent b2ada9fe05
commit f96b2627aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -468,10 +468,10 @@ namespace nadena.dev.modular_avatar.core.editor
path = RuntimeUtil.RelativePath(context.AvatarRootObject, go);
componentType = typeof(GameObject);
}
else if (key.TargetObject is SkinnedMeshRenderer smr)
else if (key.TargetObject is Renderer r)
{
path = RuntimeUtil.RelativePath(context.AvatarRootObject, smr.gameObject);
componentType = typeof(SkinnedMeshRenderer);
path = RuntimeUtil.RelativePath(context.AvatarRootObject, r.gameObject);
componentType = r.GetType();
}
else
{

View File

@ -49,6 +49,7 @@ namespace nadena.dev.modular_avatar.core.editor
{
var renderer = context.GetComponent<Renderer>(target);
if (renderer == null) continue;
if (renderer is not MeshRenderer and not SkinnedMeshRenderer) continue;
var matCount = context.Observe(renderer, r => r.sharedMaterials.Length);
@ -94,6 +95,7 @@ namespace nadena.dev.modular_avatar.core.editor
var (original, proxy) = proxyPairs.First();
if (original == null || proxy == null) return null;
if (original is not MeshRenderer and not SkinnedMeshRenderer || proxy is not MeshRenderer and not SkinnedMeshRenderer) return null;
var mats = new Material[proxy.sharedMaterials.Length];
@ -131,6 +133,7 @@ namespace nadena.dev.modular_avatar.core.editor
public void OnFrame(Renderer original, Renderer proxy)
{
if (original == null || proxy == null) return;
if (original is not MeshRenderer and not SkinnedMeshRenderer || proxy is not MeshRenderer and not SkinnedMeshRenderer) return;
var mats = proxy.sharedMaterials;