modular-avatar/UnitTests~/MeshSettingsTests/MeshSettingsTests.cs
kaikoga 3667dc319a
chore: Wrap VRC dependencies and VRCAvatarDescriptors (#504)
* 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
2023-11-10 15:37:56 +09:00

71 lines
3.2 KiB
C#

using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
using UnityEngine;
namespace modular_avatar_tests
{
internal class MeshSettingsTests : TestBase
{
private static readonly string PREFAB_NAME = "MeshSettingsTests.prefab";
[Test]
public void TestProbeAnchor()
{
var prefab = CreatePrefab(PREFAB_NAME);
var context = new BuildContext(prefab);
new MeshSettingsPass(context).OnPreprocessAvatar();
var root = prefab.transform.Find("RendererRoot");
var target = prefab.transform.Find("ProbeTarget");
var obj1 = prefab.transform.Find("ProbeTargetRenderers/SkinnedMeshRenderer").GetComponent<Renderer>();
var obj2 = prefab.transform.Find("ProbeTargetRenderers/MeshRenderer").GetComponent<Renderer>();
var obj3 = prefab.transform.Find("ProbeTargetRenderers/ParticleSystemRenderer").GetComponent<Renderer>();
var obj4 = prefab.transform.Find("ProbeTargetRenderers/TrailRenderer").GetComponent<Renderer>();
Assert.AreEqual(target, obj1.probeAnchor);
Assert.AreEqual(target, obj2.probeAnchor);
Assert.AreEqual(target, obj3.probeAnchor);
Assert.AreEqual(target, obj4.probeAnchor);
}
[Test]
public void TestProbeAnchorOverrides()
{
var prefab = CreatePrefab(PREFAB_NAME);
var context = new BuildContext(prefab);
new MeshSettingsPass(context).OnPreprocessAvatar();
var noninherit = prefab.transform.Find("ProbeTargetRenderers/NonInherited").GetComponent<MeshRenderer>();
var overrideset = prefab.transform.Find("ProbeTargetRenderers/OverrideSet").GetComponent<MeshRenderer>();
Assert.AreEqual(noninherit.transform.Find("Target"), noninherit.probeAnchor);
Assert.AreEqual(overrideset.transform.Find("Target"), overrideset.probeAnchor);
}
[Test]
public void TestSetBounds()
{
var prefab = CreatePrefab(PREFAB_NAME);
var context = new BuildContext(prefab);
new MeshSettingsPass(context).OnPreprocessAvatar();
var target = prefab.transform.Find("ProbeTarget");
var inherit = prefab.transform.Find("Bounds/Inherit").GetComponent<SkinnedMeshRenderer>();
var overridden = prefab.transform.Find("Bounds/Overridden").GetComponent<SkinnedMeshRenderer>();
var notset = prefab.transform.Find("Bounds/NotSet").GetComponent<SkinnedMeshRenderer>();
Assert.AreEqual(new Vector3(1, 2, 3), inherit.bounds.center);
Assert.AreEqual(new Vector3(4, 5, 6), inherit.bounds.extents);
Assert.AreEqual(target, inherit.rootBone);
Assert.AreEqual(new Vector3(8, 8, 8), overridden.bounds.center);
Assert.AreEqual(new Vector3(9, 9, 9), overridden.bounds.extents);
Assert.AreEqual(overridden.transform.Find("Target"), overridden.rootBone);
Assert.AreEqual(new Vector3(0, 0, 0), notset.bounds.center);
Assert.AreEqual(new Vector3(2, 2, 2), notset.bounds.extents);
Assert.AreEqual(notset.transform.Find("Target"), notset.rootBone);
}
}
}