From afafb982c81341915c552084acdeb541a14952b2 Mon Sep 17 00:00:00 2001 From: bd_ Date: Fri, 21 Mar 2025 20:14:26 -0700 Subject: [PATCH] fix: compiler warnings --- Editor/Animation/MMDRelayPass.cs | 4 +++- Editor/MergeBlendTreePass.cs | 8 ++++++-- Editor/MiscPreview/RemoveVertexColorPreview.cs | 4 ++-- Editor/OptimizationPasses/ConstraintConverterPass.cs | 7 ++++--- Editor/ParameterPolicy.cs | 2 +- .../AnimationGeneration/AnimatedProperty.cs | 6 ++++-- .../AnimationGeneration/ReactiveObjectPrepass.cs | 2 +- Runtime/MAMoveIndependently.cs | 2 -- Runtime/ModularAvatarMergeAnimator.cs | 2 +- Runtime/ModularAvatarMergeBlendTree.cs | 4 +++- UnitTests~/Animation/MergeBlendTreeTest.cs | 1 + 11 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Editor/Animation/MMDRelayPass.cs b/Editor/Animation/MMDRelayPass.cs index d52dc580..21e4feab 100644 --- a/Editor/Animation/MMDRelayPass.cs +++ b/Editor/Animation/MMDRelayPass.cs @@ -63,10 +63,12 @@ namespace nadena.dev.modular_avatar.animation foreach (var layer in fx.Layers) { + if (layer.StateMachine == null) continue; + var rootMMDModeBehaviors = layer.StateMachine.Behaviours .OfType() .ToList(); - + if (rootMMDModeBehaviors.Count == 0) continue; if (rootMMDModeBehaviors.Count > 1) { diff --git a/Editor/MergeBlendTreePass.cs b/Editor/MergeBlendTreePass.cs index 492011a7..985caac2 100644 --- a/Editor/MergeBlendTreePass.cs +++ b/Editor/MergeBlendTreePass.cs @@ -2,6 +2,7 @@ #region +using System; using System.Collections.Generic; using nadena.dev.ndmf; using nadena.dev.ndmf.animator; @@ -9,6 +10,7 @@ using UnityEditor; using UnityEditor.Animations; using UnityEngine; using VRC.SDK3.Avatars.Components; +using Object = UnityEngine.Object; #endregion @@ -83,8 +85,6 @@ namespace nadena.dev.modular_avatar.core.editor return; } - string basePath = null; - var rootBlend = GetRootBlendTree(); rootBlend.Children = rootBlend.Children.Add(new() @@ -136,6 +136,10 @@ namespace nadena.dev.modular_avatar.core.editor var fx = _asc.ControllerContext.Controllers[VRCAvatarDescriptor.AnimLayerType.FX]; var controller = fx.AddLayer(new LayerPriority(int.MinValue), BlendTreeLayerName); var stateMachine = controller.StateMachine; + if (fx == null) + { + throw new Exception("FX layer not found"); + } _rootBlendTree = VirtualBlendTree.Create("Root"); var state = stateMachine.AddState("State", _rootBlendTree); diff --git a/Editor/MiscPreview/RemoveVertexColorPreview.cs b/Editor/MiscPreview/RemoveVertexColorPreview.cs index e4eba0a5..7eccc925 100644 --- a/Editor/MiscPreview/RemoveVertexColorPreview.cs +++ b/Editor/MiscPreview/RemoveVertexColorPreview.cs @@ -89,8 +89,8 @@ namespace nadena.dev.modular_avatar.core.editor public Task Refresh(IEnumerable<(Renderer, Renderer)> proxyPairs, ComputeContext context, RenderAspects updatedAspects) { - if (updatedAspects.HasFlag(RenderAspects.Mesh)) return Task.FromResult(null); - if (_theMesh == null) return Task.FromResult(null); + if (updatedAspects.HasFlag(RenderAspects.Mesh)) return Task.FromResult(null!); + if (_theMesh == null) return Task.FromResult(null!); return Task.FromResult(this); } diff --git a/Editor/OptimizationPasses/ConstraintConverterPass.cs b/Editor/OptimizationPasses/ConstraintConverterPass.cs index 743a1b32..53fc111e 100644 --- a/Editor/OptimizationPasses/ConstraintConverterPass.cs +++ b/Editor/OptimizationPasses/ConstraintConverterPass.cs @@ -52,13 +52,14 @@ namespace nadena.dev.modular_avatar.core.editor var constraintGameObjects = context.AvatarRootObject.GetComponentsInChildren(true) .Select(c => (c as Component)?.gameObject) + .Where(go => go != null) .Distinct() - .Where(go => go.GetComponentsInParent(true) + .Where(go => go!.GetComponentsInParent(true) .Select(c => c.gameObject) .Any(converters.Contains) ).ToArray(); var targetConstraintComponents = - constraintGameObjects.SelectMany(go => go.GetComponents()).ToArray(); + constraintGameObjects.SelectMany(go => go!.GetComponents()).ToArray(); AvatarDynamicsSetup.DoConvertUnityConstraints(targetConstraintComponents, null, false); @@ -72,7 +73,7 @@ namespace nadena.dev.modular_avatar.core.editor var targetPaths = constraintGameObjects .Union(existingVRCConstraints) - .Select(c => asc.ObjectPathRemapper.GetVirtualPathForObject(c)) + .Select(c => asc.ObjectPathRemapper.GetVirtualPathForObject(c!)) .ToHashSet(); // Update animation clips diff --git a/Editor/ParameterPolicy.cs b/Editor/ParameterPolicy.cs index 0defe6cf..59089aea 100644 --- a/Editor/ParameterPolicy.cs +++ b/Editor/ParameterPolicy.cs @@ -156,7 +156,7 @@ namespace nadena.dev.modular_avatar.core.editor case ModularAvatarMergeBlendTree mergeBlendTree: { - WalkBlendTree(parameters, mergeBlendTree.BlendTree as BlendTree); + WalkBlendTree(parameters, mergeBlendTree.Motion as BlendTree); break; } diff --git a/Editor/ReactiveObjects/AnimationGeneration/AnimatedProperty.cs b/Editor/ReactiveObjects/AnimationGeneration/AnimatedProperty.cs index 0ab948ec..b87f2d18 100644 --- a/Editor/ReactiveObjects/AnimationGeneration/AnimatedProperty.cs +++ b/Editor/ReactiveObjects/AnimationGeneration/AnimatedProperty.cs @@ -1,4 +1,6 @@ -using System; +#nullable enable + +using System; using System.Collections.Generic; using System.Linq; using Object = UnityEngine.Object; @@ -34,7 +36,7 @@ namespace nadena.dev.modular_avatar.core.editor TargetProp.Equals(other.TargetProp); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is null) return false; if (ReferenceEquals(this, obj)) return true; diff --git a/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectPrepass.cs b/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectPrepass.cs index cec2bf17..b1ae09e1 100644 --- a/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectPrepass.cs +++ b/Editor/ReactiveObjects/AnimationGeneration/ReactiveObjectPrepass.cs @@ -49,7 +49,7 @@ namespace nadena.dev.modular_avatar.core.editor var obj = new GameObject("MA SC Defaults"); obj.transform.SetParent(context.AvatarRootTransform); var mambt = obj.AddComponent(); - mambt.BlendTree = bt; + mambt.Motion = bt; mambt.PathMode = MergeAnimatorPathMode.Absolute; } } diff --git a/Runtime/MAMoveIndependently.cs b/Runtime/MAMoveIndependently.cs index 0ef36c6b..b4bdc155 100644 --- a/Runtime/MAMoveIndependently.cs +++ b/Runtime/MAMoveIndependently.cs @@ -16,8 +16,6 @@ namespace nadena.dev.modular_avatar.core [HelpURL("https://modular-avatar.nadena.dev/docs/reference/move-independently?lang=auto")] class MAMoveIndependently : MonoBehaviour, IEditorOnly { - private float EPSILON = 0.0000001f; - [SerializeField] private GameObject[] m_groupedBones; diff --git a/Runtime/ModularAvatarMergeAnimator.cs b/Runtime/ModularAvatarMergeAnimator.cs index e06a0fba..5ff78e83 100644 --- a/Runtime/ModularAvatarMergeAnimator.cs +++ b/Runtime/ModularAvatarMergeAnimator.cs @@ -85,7 +85,7 @@ namespace nadena.dev.modular_avatar.core set => animator = value; } - string IVirtualizeAnimatorController.GetMotionBasePath(object ndmfBuildContext, bool clearPath = true) + string IVirtualizeAnimatorController.GetMotionBasePath(object ndmfBuildContext, bool clearPath) { var path = GetMotionBasePathCallback(this, ndmfBuildContext); if (clearPath) pathMode = MergeAnimatorPathMode.Absolute; diff --git a/Runtime/ModularAvatarMergeBlendTree.cs b/Runtime/ModularAvatarMergeBlendTree.cs index 95342ade..a0b7b81d 100644 --- a/Runtime/ModularAvatarMergeBlendTree.cs +++ b/Runtime/ModularAvatarMergeBlendTree.cs @@ -39,11 +39,13 @@ namespace nadena.dev.modular_avatar.core Motion IVirtualizeMotion.Motion { +#pragma warning disable CS0618 // Type or member is obsolete get => (Motion)BlendTree; set => BlendTree = value; +#pragma warning restore CS0618 // Type or member is obsolete } - string IVirtualizeMotion.GetMotionBasePath(object ndmfBuildContext, bool clearPath = true) + string IVirtualizeMotion.GetMotionBasePath(object ndmfBuildContext, bool clearPath) { var path = GetMotionBasePathCallback(this, ndmfBuildContext); diff --git a/UnitTests~/Animation/MergeBlendTreeTest.cs b/UnitTests~/Animation/MergeBlendTreeTest.cs index 534e5d73..9da51e8a 100644 --- a/UnitTests~/Animation/MergeBlendTreeTest.cs +++ b/UnitTests~/Animation/MergeBlendTreeTest.cs @@ -11,6 +11,7 @@ using UnityEditor.Animations; using UnityEngine; using VRC.SDK3.Avatars.Components; using AvatarProcessor = nadena.dev.ndmf.AvatarProcessor; +#pragma warning disable CS0618 // Type or member is obsolete namespace modular_avatar_tests {