chore: Fix non-VRChat support (for MA 1.10.5) (#1324)

* feat: add version defines for VRCSDK

* chore: early return if VRCSDK project but not VRChat avatar
This commit is contained in:
kaikoga 2024-10-28 02:06:35 +09:00 committed by GitHub
parent 07b648dcc1
commit efa263b551
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 119 additions and 38 deletions

View File

@ -158,6 +158,7 @@ namespace nadena.dev.modular_avatar.animation
#if MA_VRCSDK3_AVATARS
var avatarDescriptor = context.AvatarDescriptor;
if (!avatarDescriptor) return;
foreach (var layer in avatarDescriptor.baseAnimationLayers)
{

View File

@ -92,6 +92,8 @@ namespace nadena.dev.modular_avatar.animation
public void AddPropertyDefinition(AnimatorControllerParameter paramDef)
{
#if MA_VRCSDK3_AVATARS
if (!_context.AvatarDescriptor) return;
var fx = (AnimatorController)
_context.AvatarDescriptor.baseAnimationLayers
.First(l => l.type == VRCAvatarDescriptor.AnimLayerType.FX)

View File

@ -53,6 +53,8 @@ namespace nadena.dev.modular_avatar.animation
// This helps reduce the risk that we'll accidentally modify the original assets.
#if MA_VRCSDK3_AVATARS
if (!context.AvatarDescriptor) return;
context.AvatarDescriptor.baseAnimationLayers =
CloneLayers(context, context.AvatarDescriptor.baseAnimationLayers);
context.AvatarDescriptor.specialAnimationLayers =

View File

@ -369,6 +369,8 @@ namespace nadena.dev.modular_avatar.animation
Profiler.EndSample();
#if MA_VRCSDK3_AVATARS
if (context.AvatarDescriptor)
{
var layers = context.AvatarDescriptor.baseAnimationLayers
.Concat(context.AvatarDescriptor.specialAnimationLayers);
@ -384,6 +386,7 @@ namespace nadena.dev.modular_avatar.animation
ApplyMappingsToAvatarMask(acLayer.avatarMask);
}
Profiler.EndSample();
}
#endif
Profiler.EndSample();

View File

@ -19,6 +19,8 @@ namespace nadena.dev.modular_avatar.core.editor
internal static void FixupExpressionsMenu(BuildContext context)
{
if (!context.AvatarDescriptor) return;
context.AvatarDescriptor.customExpressions = true;
var expressionsMenu = context.AvatarDescriptor.expressionsMenu;

View File

@ -65,6 +65,7 @@ namespace nadena.dev.modular_avatar.core.editor
mergeSessions.Clear();
var descriptor = avatarGameObject.GetComponent<VRCAvatarDescriptor>();
if (!descriptor) return;
if (descriptor.baseAnimationLayers != null) InitSessions(descriptor.baseAnimationLayers);
if (descriptor.specialAnimationLayers != null) InitSessions(descriptor.specialAnimationLayers);

View File

@ -9,6 +9,8 @@ namespace nadena.dev.modular_avatar.core.editor
{
protected override void Execute(ndmf.BuildContext context)
{
if (!context.AvatarDescriptor) return;
var expParams = context.AvatarDescriptor.expressionParameters;
if (expParams != null && context.IsTemporaryAsset(expParams))
{

View File

@ -34,6 +34,8 @@ namespace nadena.dev.modular_avatar.core.editor
internal void Execute()
{
if (!context.AvatarDescriptor) return;
// Having a WD OFF layer after WD ON layers can break WD. We match the behavior of the existing states,
// and if mixed, use WD ON to maximize compatibility.
_writeDefaults = MergeAnimatorProcessor.ProbeWriteDefaults(FindFxController().animatorController as AnimatorController) ?? true;

View File

@ -159,6 +159,8 @@ namespace nadena.dev.modular_avatar.core.editor
public void OnPreprocessAvatar(GameObject avatar, BuildContext context)
{
if (!context.AvatarDescriptor) return;
_context = context;
var syncParams = WalkTree(avatar);

View File

@ -1,4 +1,6 @@
using nadena.dev.modular_avatar.core.editor;
#if MA_VRCSDK3_AVATARS
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
using UnityEditor;
using UnityEngine;
@ -37,3 +39,5 @@ namespace modular_avatar_tests
}
}
}
#endif

View File

@ -1,4 +1,6 @@
using System;
#if MA_VRCSDK3_AVATARS
using System;
using System.Collections.Generic;
using System.Linq;
using nadena.dev.ndmf;
@ -159,3 +161,5 @@ namespace modular_avatar_tests
}
}
}
#endif

View File

@ -1,4 +1,6 @@
using System.Linq;
#if MA_VRCSDK3_AVATARS
using System.Linq;
using nadena.dev.ndmf;
using NUnit.Framework;
using UnityEditor.Animations;
@ -27,3 +29,5 @@ namespace modular_avatar_tests
}
}
}
#endif

View File

@ -1,9 +1,10 @@
using nadena.dev.modular_avatar.core.editor;
#if MA_VRCSDK3_AVATARS_3_5_2_OR_NEWER
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
using UnityEditor.Animations;
using VRC.SDK3.Avatars.Components;
#if MA_VRCSDK3_AVATARS_3_5_2_OR_NEWER
namespace modular_avatar_tests
{
public class PlayAudioRemapping : TestBase
@ -28,4 +29,5 @@ namespace modular_avatar_tests
}
}
}
#endif

View File

@ -1,4 +1,6 @@
using modular_avatar_tests;
#if MA_VRCSDK3_AVATARS
using modular_avatar_tests;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor;
@ -48,3 +50,5 @@ namespace UnitTests.MergeAnimatorTests
}
}
}
#endif

View File

@ -1,3 +1,5 @@
#if MA_VRCSDK3_AVATARS
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@ -35,3 +37,4 @@ public class PreexistingParamsTest : TestBase
}
}
#endif

View File

@ -1,4 +1,6 @@
using modular_avatar_tests;
#if MA_VRCSDK3_AVATARS
using modular_avatar_tests;
using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
@ -26,3 +28,5 @@ namespace UnitTests.MergeAnimatorTests.ProxyAnim
}
}
}
#endif

View File

@ -1,4 +1,6 @@
using modular_avatar_tests;
#if MA_VRCSDK3_AVATARS
using modular_avatar_tests;
using nadena.dev.ndmf;
using NUnit.Framework;
using UnityEditor.Animations;
@ -39,3 +41,5 @@ namespace UnitTests.MergeAnimatorTests.SyncedLayerOverrideInSubStatemachine
}
}
}
#endif

View File

@ -1,3 +1,5 @@
#if MA_VRCSDK3_AVATARS
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@ -268,3 +270,4 @@ public class ConvertTransitionTypes : TestBase
}
}
#endif

View File

@ -1,3 +1,5 @@
#if MA_VRCSDK3_AVATARS
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
@ -24,3 +26,5 @@ public class MergeDirectBlendTreeTests : TestBase
Assert.AreEqual(0, parameters["DEF"]);
}
}
#endif

View File

@ -1,4 +1,6 @@
using System.Linq;
#if MA_VRCSDK3_AVATARS
using System.Linq;
using modular_avatar_tests;
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
@ -59,3 +61,5 @@ namespace UnitTests.ReactiveComponent
}
}
}
#endif

View File

@ -1,4 +1,6 @@
using System.Linq;
#if MA_VRCSDK3_AVATARS
using System.Linq;
using modular_avatar_tests;
using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor;
@ -48,3 +50,5 @@ namespace UnitTests.ReactiveComponent
}
}
}
#endif

View File

@ -1,4 +1,6 @@
using System;
#if MA_VRCSDK3_AVATARS
using System;
using System.Collections.Generic;
using System.Linq;
using modular_avatar_tests;
@ -113,3 +115,5 @@ namespace UnitTests.ReactiveComponent.ParameterAssignment
}
}
}
#endif

View File

@ -1,4 +1,6 @@
using System;
#if MA_VRCSDK3_AVATARS
using System;
using System.Linq;
using modular_avatar_tests;
using nadena.dev.modular_avatar.core;
@ -83,3 +85,5 @@ namespace UnitTests.ReactiveComponent.ParameterAssignment
}
}
}
#endif

View File

@ -1,3 +1,5 @@
#if MA_VRCSDK3_AVATARS
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@ -96,3 +98,5 @@ public class ShapeDeletionAnalysis : TestBase
Assert.AreEqual(originalSharedMesh, mesh.sharedMesh);
}
}
#endif

View File

@ -1,4 +1,6 @@
using modular_avatar_tests;
#if MA_VRCSDK3_AVATARS
using modular_avatar_tests;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
@ -122,3 +124,5 @@ namespace ShapeChangerTests
}
}
}
#endif

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
#if MA_VRCSDK3_AVATARS
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@ -58,3 +60,5 @@ namespace UnitTests.VisibleHeadAccessoryTest
}
}
}
#endif