mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
3667dc319a
* add version defines * refactor: prefer BuildContext.ctor() overload taking GameObject * wrap unit tests entirely with MA_VRCSDK3_AVATARS * wrap unit tests smart with MA_VRCSDK3_AVATARS * wrap runtime entirely with MA_VRCSDK3_AVATARS * wrap VRC.SDKBase.IEditorOnly with MA_VRCSDK3_AVATARS * wrap editor entirely with MA_VRCSDK3_AVATARS * fix AvatarObjectReference.Get(Component) * wrap editor smart with MA_VRCSDK3_AVATARS * wrap BuildContext smart with MA_VRCSDK3_AVATARS * wrap PluginDefinition smart with MA_VRCSDK3_AVATARS * style: move conditional compiles one step outside
59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using System.Linq;
|
|
using modular_avatar_tests;
|
|
using nadena.dev.modular_avatar.core.editor;
|
|
using NUnit.Framework;
|
|
using UnityEngine;
|
|
|
|
public class GameObjectGC : TestBase
|
|
{
|
|
[Test]
|
|
public void FakeHumanoidHandling()
|
|
{
|
|
var fake_humanoid = CreatePrefab("FakeHumanoid.prefab");
|
|
var context = new BuildContext(fake_humanoid);
|
|
|
|
new GCGameObjectsPass(context, fake_humanoid).OnPreprocessAvatar();
|
|
AvatarProcessor.ProcessAvatar(fake_humanoid);
|
|
|
|
var animator = fake_humanoid.GetComponent<Animator>();
|
|
Assert.NotNull(animator);
|
|
Assert.NotNull(animator.GetBoneTransform(HumanBodyBones.Chest));
|
|
Assert.True(fake_humanoid.transform.Find("Body") == null);
|
|
}
|
|
|
|
[Test]
|
|
public void RetainEndBones()
|
|
{
|
|
var fake_humanoid = CreatePrefab("FakeHumanoid.prefab");
|
|
var context = new BuildContext(fake_humanoid);
|
|
|
|
var bone1 = CreateChild(fake_humanoid, "bone1");
|
|
var bone2 = CreateChild(bone1, "bone2.end");
|
|
var bone3 = CreateChild(fake_humanoid, "bone2");
|
|
|
|
new GCGameObjectsPass(context, fake_humanoid).OnPreprocessAvatar();
|
|
AvatarProcessor.ProcessAvatar(fake_humanoid);
|
|
|
|
Assert.True(bone1 != null);
|
|
Assert.True(bone2 != null);
|
|
Assert.True(bone3 == null);
|
|
}
|
|
|
|
[Test]
|
|
public void RetainArmatureHack()
|
|
{
|
|
var fake_humanoid = CreatePrefab("FakeHumanoid.prefab");
|
|
var context = new BuildContext(fake_humanoid);
|
|
|
|
var armature = new GameObject();
|
|
armature.name = "Armature";
|
|
armature.transform.parent = fake_humanoid.transform;
|
|
armature.transform.SetSiblingIndex(0);
|
|
|
|
new GCGameObjectsPass(context, fake_humanoid).OnPreprocessAvatar();
|
|
AvatarProcessor.ProcessAvatar(fake_humanoid);
|
|
|
|
Assert.AreEqual(2,
|
|
context.AvatarRootObject.GetComponentsInChildren<Transform>().Count(t => t.gameObject.name == "Armature"));
|
|
}
|
|
} |