diff --git a/Editor/ActiveAnimationRetargeter.cs b/Editor/ActiveAnimationRetargeter.cs index 4eff920f..c558c9bc 100644 --- a/Editor/ActiveAnimationRetargeter.cs +++ b/Editor/ActiveAnimationRetargeter.cs @@ -4,7 +4,6 @@ using System.Linq; using nadena.dev.modular_avatar.animation; using UnityEditor; using UnityEngine; -using VRC.SDK3.Avatars.Components; using Object = UnityEngine.Object; namespace nadena.dev.modular_avatar.core.editor diff --git a/Editor/Animation/AnimationDatabase.cs b/Editor/Animation/AnimationDatabase.cs index 29ccd92b..93a34645 100644 --- a/Editor/Animation/AnimationDatabase.cs +++ b/Editor/Animation/AnimationDatabase.cs @@ -7,7 +7,11 @@ using nadena.dev.modular_avatar.editor.ErrorReporting; using UnityEditor; using UnityEditor.Animations; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Avatars.Components; +#endif + using Object = UnityEngine.Object; namespace nadena.dev.modular_avatar.animation @@ -110,6 +114,7 @@ namespace nadena.dev.modular_avatar.animation AnimationUtil.CloneAllControllers(context); +#if MA_VRCSDK3_AVATARS var avatarDescriptor = context.AvatarDescriptor; foreach (var layer in avatarDescriptor.baseAnimationLayers) @@ -136,6 +141,7 @@ namespace nadena.dev.modular_avatar.animation }); } } +#endif } /// diff --git a/Editor/Animation/AnimationUtil.cs b/Editor/Animation/AnimationUtil.cs index 8c4570b8..819ade03 100644 --- a/Editor/Animation/AnimationUtil.cs +++ b/Editor/Animation/AnimationUtil.cs @@ -6,7 +6,10 @@ using nadena.dev.ndmf; using UnityEditor; using UnityEditor.Animations; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Avatars.Components; +#endif #endregion @@ -47,12 +50,15 @@ namespace nadena.dev.modular_avatar.animation // Ensure all of the controllers on the avatar descriptor point to temporary assets. // This helps reduce the risk that we'll accidentally modify the original assets. +#if MA_VRCSDK3_AVATARS context.AvatarDescriptor.baseAnimationLayers = CloneLayers(context, context.AvatarDescriptor.baseAnimationLayers); context.AvatarDescriptor.specialAnimationLayers = CloneLayers(context, context.AvatarDescriptor.specialAnimationLayers); +#endif } +#if MA_VRCSDK3_AVATARS private static VRCAvatarDescriptor.CustomAnimLayer[] CloneLayers( BuildContext context, VRCAvatarDescriptor.CustomAnimLayer[] layers @@ -167,6 +173,7 @@ namespace nadena.dev.modular_avatar.animation return controller; } +#endif public static bool IsProxyAnimation(this Motion m) { diff --git a/Editor/Animation/AnimatorCombiner.cs b/Editor/Animation/AnimatorCombiner.cs index a9a73071..6864f8fd 100644 --- a/Editor/Animation/AnimatorCombiner.cs +++ b/Editor/Animation/AnimatorCombiner.cs @@ -31,7 +31,11 @@ using nadena.dev.modular_avatar.core.editor; using UnityEditor; using UnityEditor.Animations; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Avatars.Components; +#endif + using Object = UnityEngine.Object; #endregion @@ -275,6 +279,7 @@ namespace nadena.dev.modular_avatar.animation private void AdjustBehavior(StateMachineBehaviour behavior) { +#if MA_VRCSDK3_AVATARS switch (behavior) { case VRCAnimatorLayerControl layerControl: @@ -285,6 +290,7 @@ namespace nadena.dev.modular_avatar.animation break; } } +#endif } private static string MapPath(EditorCurveBinding binding, string basePath) diff --git a/Editor/AnimatorMerger.cs b/Editor/AnimatorMerger.cs index a2090c48..1d5df241 100644 --- a/Editor/AnimatorMerger.cs +++ b/Editor/AnimatorMerger.cs @@ -29,7 +29,11 @@ using nadena.dev.modular_avatar.editor.ErrorReporting; using UnityEditor; using UnityEditor.Animations; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Avatars.Components; +#endif + using Object = UnityEngine.Object; namespace nadena.dev.modular_avatar.core.editor @@ -254,6 +258,7 @@ namespace nadena.dev.modular_avatar.core.editor private void AdjustBehavior(StateMachineBehaviour behavior) { +#if MA_VRCSDK3_AVATARS switch (behavior) { case VRCAnimatorLayerControl layerControl: @@ -264,6 +269,7 @@ namespace nadena.dev.modular_avatar.core.editor break; } } +#endif } private static string MapPath(EditorCurveBinding binding, string basePath) diff --git a/Editor/BlendshapeSyncAnimationProcessor.cs b/Editor/BlendshapeSyncAnimationProcessor.cs index 38fe818b..c4db4847 100644 --- a/Editor/BlendshapeSyncAnimationProcessor.cs +++ b/Editor/BlendshapeSyncAnimationProcessor.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +#if MA_VRCSDK3_AVATARS + +using System.Collections.Generic; using nadena.dev.modular_avatar.editor.ErrorReporting; using UnityEditor; using UnityEditor.Animations; @@ -227,4 +229,6 @@ namespace nadena.dev.modular_avatar.core.editor } } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/BuildContext.cs b/Editor/BuildContext.cs index 26a6749f..5f63afc8 100644 --- a/Editor/BuildContext.cs +++ b/Editor/BuildContext.cs @@ -4,8 +4,12 @@ using nadena.dev.modular_avatar.animation; using UnityEditor; using UnityEditor.Animations; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Avatars.Components; using VRC.SDK3.Avatars.ScriptableObjects; +#endif + using Object = UnityEngine.Object; namespace nadena.dev.modular_avatar.core.editor @@ -14,7 +18,9 @@ namespace nadena.dev.modular_avatar.core.editor { internal readonly nadena.dev.ndmf.BuildContext PluginBuildContext; +#if MA_VRCSDK3_AVATARS internal VRCAvatarDescriptor AvatarDescriptor => PluginBuildContext.AvatarDescriptor; +#endif internal GameObject AvatarRootObject => PluginBuildContext.AvatarRootObject; internal Transform AvatarRootTransform => PluginBuildContext.AvatarRootTransform; @@ -28,12 +34,10 @@ namespace nadena.dev.modular_avatar.core.editor private bool SaveImmediate = false; +#if MA_VRCSDK3_AVATARS internal readonly Dictionary ClonedMenus = new Dictionary(); - public static implicit operator BuildContext(ndmf.BuildContext ctx) => - ctx.Extension().BuildContext; - /// /// This dictionary overrides the _original contents_ of ModularAvatarMenuInstallers. Notably, this does not /// replace the source menu for the purposes of identifying any other MAMIs that might install to the same @@ -41,16 +45,21 @@ namespace nadena.dev.modular_avatar.core.editor /// internal readonly Dictionary> PostProcessControls = new Dictionary>(); +#endif + public static implicit operator BuildContext(ndmf.BuildContext ctx) => + ctx.Extension().BuildContext; public BuildContext(nadena.dev.ndmf.BuildContext PluginBuildContext) { this.PluginBuildContext = PluginBuildContext; } +#if MA_VRCSDK3_AVATARS public BuildContext(VRCAvatarDescriptor avatarDescriptor) : this(new ndmf.BuildContext(avatarDescriptor, null)) { } +#endif public BuildContext(GameObject avatarGameObject) : this(new ndmf.BuildContext(avatarGameObject, null)) @@ -108,6 +117,7 @@ namespace nadena.dev.modular_avatar.core.editor return merger.Finish(); } +#if MA_VRCSDK3_AVATARS public VRCExpressionsMenu CloneMenu(VRCExpressionsMenu menu) { if (menu == null) return null; @@ -126,5 +136,6 @@ namespace nadena.dev.modular_avatar.core.editor return newMenu; } +#endif } } \ No newline at end of file diff --git a/Editor/ErrorReporting/ComponentValidation.cs b/Editor/ErrorReporting/ComponentValidation.cs index 14a96734..81bb0946 100644 --- a/Editor/ErrorReporting/ComponentValidation.cs +++ b/Editor/ErrorReporting/ComponentValidation.cs @@ -1,6 +1,10 @@ using System.Collections.Generic; using nadena.dev.modular_avatar.core; + +#if MA_VRCSDK3_AVATARS using nadena.dev.modular_avatar.core.menu; +#endif + using UnityEngine; namespace nadena.dev.modular_avatar.editor.ErrorReporting @@ -20,10 +24,12 @@ namespace nadena.dev.modular_avatar.editor.ErrorReporting return CheckInternal(bs); case ModularAvatarBoneProxy bp: return CheckInternal(bp); +#if MA_VRCSDK3_AVATARS case ModularAvatarMenuInstaller mi: return CheckInternal(mi); case ModularAvatarMergeAnimator obj: return CheckInternal(obj); +#endif case ModularAvatarMergeArmature obj: return CheckInternal(obj); default: @@ -134,6 +140,7 @@ namespace nadena.dev.modular_avatar.editor.ErrorReporting return null; } +#if MA_VRCSDK3_AVATARS private static List CheckInternal(ModularAvatarMenuInstaller mi) { // TODO - check that target menu is in the avatar @@ -160,6 +167,7 @@ namespace nadena.dev.modular_avatar.editor.ErrorReporting return null; } +#endif private static List CheckInternal(ModularAvatarMergeArmature ma) { diff --git a/Editor/FixupPasses/FixupExpressionsMenuPass.cs b/Editor/FixupPasses/FixupExpressionsMenuPass.cs index 16c049fd..f4b549ee 100644 --- a/Editor/FixupPasses/FixupExpressionsMenuPass.cs +++ b/Editor/FixupPasses/FixupExpressionsMenuPass.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -157,4 +159,6 @@ namespace nadena.dev.modular_avatar.core.editor return name.StartsWith("DXT") || name.StartsWith("ASTC"); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Inspector/AvatarParametersEditor.cs b/Editor/Inspector/AvatarParametersEditor.cs index 76543d6b..ff330cc1 100644 --- a/Editor/Inspector/AvatarParametersEditor.cs +++ b/Editor/Inspector/AvatarParametersEditor.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -476,4 +478,6 @@ namespace nadena.dev.modular_avatar.core.editor Localization.ShowLanguageUI(); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Inspector/MAAssetBundleEditor.cs b/Editor/Inspector/MAAssetBundleEditor.cs index e8240023..081b290b 100644 --- a/Editor/Inspector/MAAssetBundleEditor.cs +++ b/Editor/Inspector/MAAssetBundleEditor.cs @@ -3,7 +3,11 @@ using System.Collections.Generic; using System.Linq; using UnityEditor; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Avatars.ScriptableObjects; +#endif + using Object = UnityEngine.Object; namespace nadena.dev.modular_avatar.core.editor @@ -31,8 +35,10 @@ namespace nadena.dev.modular_avatar.core.editor typeof(Mesh), typeof(AnimationClip), typeof(RuntimeAnimatorController), +#if MA_VRCSDK3_AVATARS typeof(VRCExpressionParameters), typeof(VRCExpressionsMenu), +#endif }; private Dictionary _assets; @@ -60,10 +66,15 @@ namespace nadena.dev.modular_avatar.core.editor public void PopulateReferences(Dictionary assets) { - if (Asset is Mesh || Asset is AnimationClip || Asset is VRCExpressionsMenu || - Asset is VRCExpressionsMenu) + switch (Asset) { - return; // No child objects + case Mesh _: + case AnimationClip _: +#if MA_VRCSDK3_AVATARS + case VRCExpressionsMenu _: + case VRCExpressionParameters _: +#endif + return; // No child objects } var so = new SerializedObject(Asset); diff --git a/Editor/Inspector/Menu/AvMenuTreeView.cs b/Editor/Inspector/Menu/AvMenuTreeView.cs index c0b604a9..9e8996c9 100644 --- a/Editor/Inspector/Menu/AvMenuTreeView.cs +++ b/Editor/Inspector/Menu/AvMenuTreeView.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -231,4 +233,6 @@ namespace nadena.dev.modular_avatar.core.editor } } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Inspector/Menu/MAMenuItemInspector.cs b/Editor/Inspector/Menu/MAMenuItemInspector.cs index 4bb4aaae..1ddec4a5 100644 --- a/Editor/Inspector/Menu/MAMenuItemInspector.cs +++ b/Editor/Inspector/Menu/MAMenuItemInspector.cs @@ -1,4 +1,6 @@ -using UnityEditor; +#if MA_VRCSDK3_AVATARS + +using UnityEditor; using static nadena.dev.modular_avatar.core.editor.Localization; namespace nadena.dev.modular_avatar.core.editor @@ -52,4 +54,6 @@ namespace nadena.dev.modular_avatar.core.editor ShowLanguageUI(); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Inspector/Menu/MenuInstallTargetEditor.cs b/Editor/Inspector/Menu/MenuInstallTargetEditor.cs index 2e1507bf..df6db514 100644 --- a/Editor/Inspector/Menu/MenuInstallTargetEditor.cs +++ b/Editor/Inspector/Menu/MenuInstallTargetEditor.cs @@ -1,4 +1,6 @@ -using UnityEditor; +#if MA_VRCSDK3_AVATARS + +using UnityEditor; namespace nadena.dev.modular_avatar.core.editor { @@ -13,4 +15,6 @@ namespace nadena.dev.modular_avatar.core.editor serializedObject.ApplyModifiedProperties(); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Inspector/Menu/MenuInstallerEditor.cs b/Editor/Inspector/Menu/MenuInstallerEditor.cs index 90f8fcd7..c447adc3 100644 --- a/Editor/Inspector/Menu/MenuInstallerEditor.cs +++ b/Editor/Inspector/Menu/MenuInstallerEditor.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -585,4 +587,6 @@ namespace nadena.dev.modular_avatar.core.editor return ValidateExpressionMenuIconResult.Success; } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Inspector/Menu/MenuItemGUI.cs b/Editor/Inspector/Menu/MenuItemGUI.cs index bbf6875e..ee658158 100644 --- a/Editor/Inspector/Menu/MenuItemGUI.cs +++ b/Editor/Inspector/Menu/MenuItemGUI.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Linq; using System.Runtime.Serialization; using nadena.dev.modular_avatar.core.menu; @@ -488,4 +490,6 @@ namespace nadena.dev.modular_avatar.core.editor } } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Inspector/Menu/MenuPreviewGUI.cs b/Editor/Inspector/Menu/MenuPreviewGUI.cs index e0fe7aa2..dc605814 100644 --- a/Editor/Inspector/Menu/MenuPreviewGUI.cs +++ b/Editor/Inspector/Menu/MenuPreviewGUI.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using nadena.dev.modular_avatar.core.menu; using static nadena.dev.modular_avatar.core.editor.Localization; @@ -273,4 +275,6 @@ namespace nadena.dev.modular_avatar.core.editor } } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Inspector/Menu/ParameterField.cs b/Editor/Inspector/Menu/ParameterField.cs index 5da54a84..9b66d07c 100644 --- a/Editor/Inspector/Menu/ParameterField.cs +++ b/Editor/Inspector/Menu/ParameterField.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using UnityEditor; using UnityEditor.IMGUI.Controls; @@ -283,4 +285,6 @@ namespace nadena.dev.modular_avatar.core.editor } } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Inspector/MergeAnimationEditor.cs b/Editor/Inspector/MergeAnimationEditor.cs index 3d7c0bf1..2f136b84 100644 --- a/Editor/Inspector/MergeAnimationEditor.cs +++ b/Editor/Inspector/MergeAnimationEditor.cs @@ -1,4 +1,6 @@ -using UnityEditor; +#if MA_VRCSDK3_AVATARS + +using UnityEditor; using static nadena.dev.modular_avatar.core.editor.Localization; namespace nadena.dev.modular_avatar.core.editor @@ -45,4 +47,6 @@ namespace nadena.dev.modular_avatar.core.editor ShowLanguageUI(); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Menu/MenuExtractor.cs b/Editor/Menu/MenuExtractor.cs index f223faed..7c1bf059 100644 --- a/Editor/Menu/MenuExtractor.cs +++ b/Editor/Menu/MenuExtractor.cs @@ -1,4 +1,6 @@ -using System.Linq; +#if MA_VRCSDK3_AVATARS + +using System.Linq; using UnityEditor; using UnityEngine; using VRC.SDK3.Avatars.Components; @@ -128,4 +130,6 @@ namespace nadena.dev.modular_avatar.core.editor }; } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/Menu/VirtualMenu.cs b/Editor/Menu/VirtualMenu.cs index 7505fed0..24b5971f 100644 --- a/Editor/Menu/VirtualMenu.cs +++ b/Editor/Menu/VirtualMenu.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -477,4 +479,6 @@ namespace nadena.dev.modular_avatar.core.editor.menu return _visitedNodes.Contains(item); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/MenuInstallHook.cs b/Editor/MenuInstallHook.cs index 973bf2b2..2d1efd81 100644 --- a/Editor/MenuInstallHook.cs +++ b/Editor/MenuInstallHook.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Linq; using nadena.dev.modular_avatar.core.editor.menu; @@ -84,4 +86,6 @@ namespace nadena.dev.modular_avatar.core.editor } } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/MergeAnimatorProcessor.cs b/Editor/MergeAnimatorProcessor.cs index 6c4ab9ac..727e7b1e 100644 --- a/Editor/MergeAnimatorProcessor.cs +++ b/Editor/MergeAnimatorProcessor.cs @@ -22,6 +22,8 @@ * SOFTWARE. */ +#if MA_VRCSDK3_AVATARS + using System.Collections.Generic; using nadena.dev.modular_avatar.editor.ErrorReporting; using UnityEditor; @@ -247,4 +249,6 @@ namespace nadena.dev.modular_avatar.core.editor return controller; } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/MergeArmatureHook.cs b/Editor/MergeArmatureHook.cs index 59e0618d..59bd93ed 100644 --- a/Editor/MergeArmatureHook.cs +++ b/Editor/MergeArmatureHook.cs @@ -30,8 +30,12 @@ using nadena.dev.modular_avatar.editor.ErrorReporting; using UnityEditor; using UnityEngine; using UnityEngine.Animations; + +#if MA_VRCSDK3_AVATARS using VRC.Dynamics; using VRC.SDK3.Dynamics.PhysBone.Components; +#endif + using Object = UnityEngine.Object; namespace nadena.dev.modular_avatar.core.editor @@ -71,6 +75,7 @@ namespace nadena.dev.modular_avatar.core.editor TopoProcessMergeArmatures(mergeArmatures); +#if MA_VRCSDK3_AVATARS foreach (var c in avatarGameObject.transform.GetComponentsInChildren(true)) { if (c.rootTransform == null) c.rootTransform = c.transform; @@ -88,6 +93,7 @@ namespace nadena.dev.modular_avatar.core.editor if (c.rootTransform == null) c.rootTransform = c.transform; RetainBoneReferences(c); } +#endif foreach (var c in avatarGameObject.transform.GetComponentsInChildren(true)) { @@ -176,7 +182,9 @@ namespace nadena.dev.modular_avatar.core.editor mergedObjects.Clear(); thisPassAdded.Clear(); MergeArmature(config, target); +#if MA_VRCSDK3_AVATARS PruneDuplicatePhysBones(); +#endif UnityEngine.Object.DestroyImmediate(config); }); } @@ -386,6 +394,7 @@ namespace nadena.dev.modular_avatar.core.editor return merged; } +#if MA_VRCSDK3_AVATARS /** * Sometimes outfit authors copy the entire armature, including PhysBones components. If we merge these and * end up with multiple PB components referencing the same target, PB refuses to animate the bone. So detect @@ -425,5 +434,6 @@ namespace nadena.dev.modular_avatar.core.editor } } } +#endif } } \ No newline at end of file diff --git a/Editor/MeshSettingsPass.cs b/Editor/MeshSettingsPass.cs index c46e5c7a..f5573e5d 100644 --- a/Editor/MeshSettingsPass.cs +++ b/Editor/MeshSettingsPass.cs @@ -22,7 +22,7 @@ namespace nadena.dev.modular_avatar.core.editor public void OnPreprocessAvatar() { - foreach (var mesh in context.AvatarDescriptor.GetComponentsInChildren(true)) + foreach (var mesh in context.AvatarRootObject.GetComponentsInChildren(true)) { ProcessMesh(mesh); } @@ -94,7 +94,7 @@ namespace nadena.dev.modular_avatar.core.editor private void ProcessMesh(Renderer mesh) { - MergedSettings settings = MergeSettings(context.AvatarDescriptor.transform, mesh.transform); + MergedSettings settings = MergeSettings(context.AvatarRootTransform, mesh.transform); if (settings.SetAnchor) { diff --git a/Editor/OptimizationPasses/GCGameObjectsPass.cs b/Editor/OptimizationPasses/GCGameObjectsPass.cs index 23c2e939..2266b00b 100644 --- a/Editor/OptimizationPasses/GCGameObjectsPass.cs +++ b/Editor/OptimizationPasses/GCGameObjectsPass.cs @@ -2,7 +2,10 @@ using System.Collections.Generic; using UnityEditor; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Dynamics.PhysBone.Components; +#endif namespace nadena.dev.modular_avatar.core.editor { @@ -56,10 +59,12 @@ namespace nadena.dev.modular_avatar.core.editor { case Transform t: break; +#if MA_VRCSDK3_AVATARS case VRCPhysBone pb: MarkObject(obj); MarkPhysBone(pb); break; +#endif case AvatarTagComponent _: // Tag components will not be retained at runtime, so pretend they're not there. @@ -123,6 +128,7 @@ namespace nadena.dev.modular_avatar.core.editor } } +#if MA_VRCSDK3_AVATARS private void MarkPhysBone(VRCPhysBone pb) { var rootTransform = pb.GetRootTransform(); @@ -137,6 +143,7 @@ namespace nadena.dev.modular_avatar.core.editor // Mark colliders, etc MarkAllReferencedObjects(pb); } +#endif private void MarkAllReferencedObjects(Component component) { diff --git a/Editor/ParameterPolicy.cs b/Editor/ParameterPolicy.cs index 57f4a9cb..42f82e53 100644 --- a/Editor/ParameterPolicy.cs +++ b/Editor/ParameterPolicy.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +#if MA_VRCSDK3_AVATARS + +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using UnityEditor.Animations; @@ -319,4 +321,6 @@ namespace nadena.dev.modular_avatar.core.editor parameters = newParams; } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/PhysboneBlockerPass.cs b/Editor/PhysboneBlockerPass.cs index 918e4442..4c83904f 100644 --- a/Editor/PhysboneBlockerPass.cs +++ b/Editor/PhysboneBlockerPass.cs @@ -1,18 +1,18 @@ /* * MIT License - * + * * Copyright (c) 2022 bd_ - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -22,6 +22,8 @@ * SOFTWARE. */ +#if MA_VRCSDK3_AVATARS + using System.Collections.Generic; using nadena.dev.modular_avatar.editor.ErrorReporting; using UnityEngine; @@ -75,4 +77,6 @@ namespace nadena.dev.modular_avatar.core.editor } } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/PluginDefinition/PluginDefinition.cs b/Editor/PluginDefinition/PluginDefinition.cs index bd34d10d..46352f06 100644 --- a/Editor/PluginDefinition/PluginDefinition.cs +++ b/Editor/PluginDefinition/PluginDefinition.cs @@ -33,9 +33,11 @@ namespace nadena.dev.modular_avatar.core.editor.plugin { seq.Run(ClearEditorOnlyTags.Instance); seq.Run(MeshSettingsPluginPass.Instance); +#if MA_VRCSDK3_AVATARS seq.Run(RenameParametersPluginPass.Instance); seq.Run(MergeAnimatorPluginPass.Instance); seq.Run(MenuInstallPluginPass.Instance); +#endif seq.WithRequiredExtension(typeof(AnimationServicesContext), _s2 => { seq.Run(MergeArmaturePluginPass.Instance); @@ -45,14 +47,18 @@ namespace nadena.dev.modular_avatar.core.editor.plugin ctx => new WorldFixedObjectProcessor().Process(ctx) ); seq.Run(ReplaceObjectPluginPass.Instance); +#if MA_VRCSDK3_AVATARS seq.Run(BlendshapeSyncAnimationPluginPass.Instance); +#endif }); +#if MA_VRCSDK3_AVATARS seq.Run(PhysbonesBlockerPluginPass.Instance); seq.Run("Fixup Expressions Menu", ctx => { var maContext = ctx.Extension().BuildContext; FixupExpressionsMenuPass.FixupExpressionsMenu(maContext); }); +#endif seq.Run("Rebind humanoid avatar", ctx => { // workaround problem with avatar matching @@ -142,6 +148,7 @@ namespace nadena.dev.modular_avatar.core.editor.plugin } } +#if MA_VRCSDK3_AVATARS class RenameParametersPluginPass : MAPass { protected override void Execute(ndmf.BuildContext context) @@ -165,6 +172,7 @@ namespace nadena.dev.modular_avatar.core.editor.plugin new MenuInstallHook().OnPreprocessAvatar(context.AvatarRootObject, MAContext(context)); } } +#endif class MergeArmaturePluginPass : MAPass { @@ -198,6 +206,7 @@ namespace nadena.dev.modular_avatar.core.editor.plugin } } +#if MA_VRCSDK3_AVATARS class BlendshapeSyncAnimationPluginPass : MAPass { protected override void Execute(ndmf.BuildContext context) @@ -213,6 +222,7 @@ namespace nadena.dev.modular_avatar.core.editor.plugin PhysboneBlockerPass.Process(context.AvatarRootObject); } } +#endif class GCGameObjectsPluginPass : MAPass { diff --git a/Editor/PreventStripTagObjects.cs b/Editor/PreventStripTagObjects.cs index 972a4882..4268e272 100644 --- a/Editor/PreventStripTagObjects.cs +++ b/Editor/PreventStripTagObjects.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -63,4 +65,6 @@ namespace nadena.dev.modular_avatar.core.editor return true; } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/RenameParametersHook.cs b/Editor/RenameParametersHook.cs index 11a0336a..d2e5cb5c 100644 --- a/Editor/RenameParametersHook.cs +++ b/Editor/RenameParametersHook.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -493,4 +495,6 @@ namespace nadena.dev.modular_avatar.core.editor return x; } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Editor/ReplaceObjectPass.cs b/Editor/ReplaceObjectPass.cs index 7d13e772..86bd291e 100644 --- a/Editor/ReplaceObjectPass.cs +++ b/Editor/ReplaceObjectPass.cs @@ -29,9 +29,9 @@ namespace nadena.dev.modular_avatar.core.editor public void Process() { - var avatarDescriptor = _buildContext.AvatarDescriptor; + var avatarRootTransform = _buildContext.AvatarRootTransform; var replacementComponents = - avatarDescriptor.GetComponentsInChildren(true); + avatarRootTransform.GetComponentsInChildren(true); if (replacementComponents.Length == 0) return; @@ -43,7 +43,7 @@ namespace nadena.dev.modular_avatar.core.editor foreach (var component in replacementComponents) { - var targetObject = component.targetObject?.Get(_buildContext.AvatarDescriptor); + var targetObject = component.targetObject?.Get(avatarRootTransform); if (targetObject == null) { @@ -154,7 +154,7 @@ namespace nadena.dev.modular_avatar.core.editor { Dictionary> refIndex = new Dictionary>(); - IndexObject(_buildContext.AvatarDescriptor.gameObject); + IndexObject(_buildContext.AvatarRootObject); return refIndex; diff --git a/Editor/Util.cs b/Editor/Util.cs index 14e87f44..127ffee5 100644 --- a/Editor/Util.cs +++ b/Editor/Util.cs @@ -28,7 +28,7 @@ using System.Reflection; using UnityEditor; using UnityEditor.Animations; using UnityEngine; -using VRC.SDKBase.Editor.BuildPipeline; + using Object = UnityEngine.Object; namespace nadena.dev.modular_avatar.core.editor diff --git a/Editor/VisibleHeadAccessoryProcessor.cs b/Editor/VisibleHeadAccessoryProcessor.cs index cc7bfe4d..869a2326 100644 --- a/Editor/VisibleHeadAccessoryProcessor.cs +++ b/Editor/VisibleHeadAccessoryProcessor.cs @@ -2,7 +2,10 @@ using nadena.dev.modular_avatar.editor.ErrorReporting; using UnityEngine; using UnityEngine.Animations; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Dynamics.PhysBone.Components; +#endif namespace nadena.dev.modular_avatar.core.editor { @@ -34,6 +37,7 @@ namespace nadena.dev.modular_avatar.core.editor var animator = _avatarTransform.GetComponent(); _headBone = animator != null ? animator.GetBoneTransform(HumanBodyBones.Head) : null; +#if MA_VRCSDK3_AVATARS foreach (var physBone in _avatarTransform.GetComponentsInChildren(true)) { var boneRoot = physBone.rootTransform != null ? physBone.rootTransform : physBone.transform; @@ -55,6 +59,7 @@ namespace nadena.dev.modular_avatar.core.editor Traverse(child, ignored); } } +#endif } public void Process() diff --git a/Editor/nadena.dev.modular-avatar.core.editor.asmdef b/Editor/nadena.dev.modular-avatar.core.editor.asmdef index 24bfa43c..ec3e4482 100644 --- a/Editor/nadena.dev.modular-avatar.core.editor.asmdef +++ b/Editor/nadena.dev.modular-avatar.core.editor.asmdef @@ -33,6 +33,11 @@ "name": "com.anatawa12.avatar-optimizer", "expression": "(,1.5.0-rc.8)", "define": "LEGACY_AVATAR_OPTIMIZER" + }, + { + "name": "com.vrchat.avatars", + "expression": "", + "define": "MA_VRCSDK3_AVATARS" } ], "noEngineReferences": false diff --git a/Runtime/Activator.cs b/Runtime/Activator.cs index e47a00d7..9d45d930 100644 --- a/Runtime/Activator.cs +++ b/Runtime/Activator.cs @@ -1,7 +1,10 @@ #if UNITY_EDITOR using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDKBase; +#endif namespace nadena.dev.modular_avatar.core { diff --git a/Runtime/AvatarTagComponent.cs b/Runtime/AvatarTagComponent.cs index 40be90bd..6e0fff8f 100644 --- a/Runtime/AvatarTagComponent.cs +++ b/Runtime/AvatarTagComponent.cs @@ -24,7 +24,10 @@ using System; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDKBase; +#endif namespace nadena.dev.modular_avatar.core { @@ -55,4 +58,15 @@ namespace nadena.dev.modular_avatar.core { } } + +#if !MA_VRCSDK3_AVATARS + + /** + * Placeholder of VRC.SDKBase.IEditorOnly for environments without VRCSDK + */ + interface IEditorOnly + { + } + +#endif } \ No newline at end of file diff --git a/Runtime/MAMoveIndependently.cs b/Runtime/MAMoveIndependently.cs index c200f4b5..179bb108 100644 --- a/Runtime/MAMoveIndependently.cs +++ b/Runtime/MAMoveIndependently.cs @@ -3,7 +3,10 @@ using System.Collections.Generic; using nadena.dev.modular_avatar.core.armature_lock; using UnityEditor; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDKBase; +#endif namespace nadena.dev.modular_avatar.core.ArmatureAwase { diff --git a/Runtime/Menu/ModularAvatarMenuGroup.cs b/Runtime/Menu/ModularAvatarMenuGroup.cs index 1ab37c9d..fcab3da2 100644 --- a/Runtime/Menu/ModularAvatarMenuGroup.cs +++ b/Runtime/Menu/ModularAvatarMenuGroup.cs @@ -1,4 +1,6 @@ -using nadena.dev.modular_avatar.core.menu; +#if MA_VRCSDK3_AVATARS + +using nadena.dev.modular_avatar.core.menu; using UnityEngine; namespace nadena.dev.modular_avatar.core @@ -19,4 +21,6 @@ namespace nadena.dev.modular_avatar.core // no-op } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Runtime/Menu/ModularAvatarMenuInstaller.cs b/Runtime/Menu/ModularAvatarMenuInstaller.cs index 1f877628..96a78cc5 100644 --- a/Runtime/Menu/ModularAvatarMenuInstaller.cs +++ b/Runtime/Menu/ModularAvatarMenuInstaller.cs @@ -1,4 +1,6 @@ -using UnityEngine; +#if MA_VRCSDK3_AVATARS + +using UnityEngine; using VRC.SDK3.Avatars.ScriptableObjects; namespace nadena.dev.modular_avatar.core @@ -29,4 +31,6 @@ namespace nadena.dev.modular_avatar.core // no-op } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Runtime/Menu/VirtualMenuAPI.cs b/Runtime/Menu/VirtualMenuAPI.cs index e0a992cd..364196b2 100644 --- a/Runtime/Menu/VirtualMenuAPI.cs +++ b/Runtime/Menu/VirtualMenuAPI.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -172,4 +174,6 @@ namespace nadena.dev.modular_avatar.core.menu public abstract void Visit(NodeContext context); } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Runtime/ModularAvatarMenuInstallTarget.cs b/Runtime/ModularAvatarMenuInstallTarget.cs index 1c777ef2..463e6ade 100644 --- a/Runtime/ModularAvatarMenuInstallTarget.cs +++ b/Runtime/ModularAvatarMenuInstallTarget.cs @@ -1,4 +1,6 @@ -using nadena.dev.modular_avatar.core.menu; +#if MA_VRCSDK3_AVATARS + +using nadena.dev.modular_avatar.core.menu; using UnityEngine; namespace nadena.dev.modular_avatar.core @@ -29,4 +31,6 @@ namespace nadena.dev.modular_avatar.core // no-op } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Runtime/ModularAvatarMenuItem.cs b/Runtime/ModularAvatarMenuItem.cs index a254c215..6dc56e8b 100644 --- a/Runtime/ModularAvatarMenuItem.cs +++ b/Runtime/ModularAvatarMenuItem.cs @@ -1,4 +1,6 @@ -using nadena.dev.modular_avatar.core.menu; +#if MA_VRCSDK3_AVATARS + +using nadena.dev.modular_avatar.core.menu; using UnityEngine; using VRC.SDK3.Avatars.ScriptableObjects; @@ -76,4 +78,6 @@ namespace nadena.dev.modular_avatar.core context.PushControl(cloned); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Runtime/ModularAvatarMergeAnimator.cs b/Runtime/ModularAvatarMergeAnimator.cs index e6846016..997a25e9 100644 --- a/Runtime/ModularAvatarMergeAnimator.cs +++ b/Runtime/ModularAvatarMergeAnimator.cs @@ -22,6 +22,8 @@ * SOFTWARE. */ +#if MA_VRCSDK3_AVATARS + using UnityEngine; using VRC.SDK3.Avatars.Components; @@ -48,4 +50,6 @@ namespace nadena.dev.modular_avatar.core // no-op } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Runtime/RuntimeUtil.cs b/Runtime/RuntimeUtil.cs index 2e9ba0f2..c5b6f9a3 100644 --- a/Runtime/RuntimeUtil.cs +++ b/Runtime/RuntimeUtil.cs @@ -26,7 +26,11 @@ using System; using System.Collections.Generic; using JetBrains.Annotations; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Avatars.Components; +#endif + #if UNITY_EDITOR using System.Reflection; #endif @@ -77,6 +81,7 @@ namespace nadena.dev.modular_avatar.core return ndmf.runtime.RuntimeUtil.IsAvatarRoot(target); } +#if MA_VRCSDK3_AVATARS public static VRCAvatarDescriptor FindAvatarInParents(Transform target) { while (target != null) @@ -88,6 +93,7 @@ namespace nadena.dev.modular_avatar.core return null; } +#endif public static Transform FindAvatarTransformInParents(Transform target) { diff --git a/Runtime/nadena.dev.modular-avatar.core.asmdef b/Runtime/nadena.dev.modular-avatar.core.asmdef index c9975271..85ce1efc 100644 --- a/Runtime/nadena.dev.modular-avatar.core.asmdef +++ b/Runtime/nadena.dev.modular-avatar.core.asmdef @@ -17,6 +17,12 @@ ], "autoReferenced": true, "defineConstraints": [], - "versionDefines": [], + "versionDefines": [ + { + "name": "com.vrchat.avatars", + "expression": "", + "define": "MA_VRCSDK3_AVATARS" + } + ], "noEngineReferences": false } \ No newline at end of file diff --git a/UnitTests~/ActiveAnimationRetargeterTests/ActiveAnimationRetargeterTests.cs b/UnitTests~/ActiveAnimationRetargeterTests/ActiveAnimationRetargeterTests.cs index 176ca900..742c9f06 100644 --- a/UnitTests~/ActiveAnimationRetargeterTests/ActiveAnimationRetargeterTests.cs +++ b/UnitTests~/ActiveAnimationRetargeterTests/ActiveAnimationRetargeterTests.cs @@ -1,10 +1,11 @@ +#if MA_VRCSDK3_AVATARS + using modular_avatar_tests; using nadena.dev.modular_avatar.animation; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEditor; using UnityEngine; -using VRC.SDK3.Avatars.Components; public class ActiveAnimationRetargeterTests : TestBase { @@ -12,10 +13,9 @@ public class ActiveAnimationRetargeterTests : TestBase public void SimpleRetarget() { var avatar = CreatePrefab("SimpleRetarget.prefab"); - var descriptor = avatar.GetComponent(); // initialize context - var buildContext = new BuildContext(descriptor); + var buildContext = new BuildContext(avatar); var pathMappings = buildContext.PluginBuildContext.ActivateExtensionContext() .PathMappings; @@ -41,4 +41,6 @@ public class ActiveAnimationRetargeterTests : TestBase Assert.That(curveBindings, Does.Contain(EditorCurveBinding.FloatCurve( pathMappings.GetObjectIdentifier(created), typeof(GameObject), "m_IsActive"))); } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/AnimateAddedBones/AnimateAddedBones.cs b/UnitTests~/AnimateAddedBones/AnimateAddedBones.cs index 9fcbb999..2e411120 100644 --- a/UnitTests~/AnimateAddedBones/AnimateAddedBones.cs +++ b/UnitTests~/AnimateAddedBones/AnimateAddedBones.cs @@ -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; @@ -30,4 +32,6 @@ namespace modular_avatar_tests.AnimateAddedBones Assert.NotNull(AnimationUtility.GetEditorCurve(motion, binding)); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/Animation/MiscAnimationTests.cs b/UnitTests~/Animation/MiscAnimationTests.cs index 7b77394d..23d33068 100644 --- a/UnitTests~/Animation/MiscAnimationTests.cs +++ b/UnitTests~/Animation/MiscAnimationTests.cs @@ -1,4 +1,6 @@ -using nadena.dev.ndmf; +#if MA_VRCSDK3_AVATARS + +using nadena.dev.ndmf; using nadena.dev.modular_avatar.animation; using NUnit.Framework; using UnityEditor; @@ -24,4 +26,6 @@ namespace modular_avatar_tests Assert.False(new SerializedObject(hq_off.motion).FindProperty("m_UseHighQualityCurve").boolValue); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/Animation/TrackObjectRenamesContextTests.cs b/UnitTests~/Animation/TrackObjectRenamesContextTests.cs index 21243ee7..554d05d2 100644 --- a/UnitTests~/Animation/TrackObjectRenamesContextTests.cs +++ b/UnitTests~/Animation/TrackObjectRenamesContextTests.cs @@ -4,7 +4,10 @@ using NUnit.Framework; using UnityEditor; using UnityEditor.Animations; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Avatars.Components; +#endif namespace modular_avatar_tests { @@ -92,6 +95,7 @@ namespace modular_avatar_tests Assert.AreEqual("a/b/c/d", toc.PathMappings.MapPath("a/b/c/d", true)); } +#if MA_VRCSDK3_AVATARS [Test] public void TestAnimatorControllerUpdates() { @@ -143,5 +147,6 @@ namespace modular_avatar_tests } } } +#endif } } \ No newline at end of file diff --git a/UnitTests~/BlendshapeSyncTests/BlendshapeSyncIntegrationTest.cs b/UnitTests~/BlendshapeSyncTests/BlendshapeSyncIntegrationTest.cs index e95d217f..9afae49c 100644 --- a/UnitTests~/BlendshapeSyncTests/BlendshapeSyncIntegrationTest.cs +++ b/UnitTests~/BlendshapeSyncTests/BlendshapeSyncIntegrationTest.cs @@ -1,4 +1,6 @@ -using System.Collections.Immutable; +#if MA_VRCSDK3_AVATARS + +using System.Collections.Immutable; using System.Linq; using modular_avatar_tests; using nadena.dev.modular_avatar.animation; @@ -38,4 +40,6 @@ namespace modular_avatar_tests Assert.AreEqual(bindings.Count, 7); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/DirectBlendTreeParameters/DirectBlendTreeParameters.cs b/UnitTests~/DirectBlendTreeParameters/DirectBlendTreeParameters.cs index 260d96f6..444332e4 100644 --- a/UnitTests~/DirectBlendTreeParameters/DirectBlendTreeParameters.cs +++ b/UnitTests~/DirectBlendTreeParameters/DirectBlendTreeParameters.cs @@ -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.Animations; @@ -23,4 +25,6 @@ namespace modular_avatar_tests.DirectBlendTreeParameters Assert.AreEqual(children[1].directBlendParameter, "C"); //remapped } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/DuplicatePBStripping/DuplicatePBStripping.cs b/UnitTests~/DuplicatePBStripping/DuplicatePBStripping.cs index c1b4a457..cd87ce90 100644 --- a/UnitTests~/DuplicatePBStripping/DuplicatePBStripping.cs +++ b/UnitTests~/DuplicatePBStripping/DuplicatePBStripping.cs @@ -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 VRC.SDK3.Dynamics.PhysBone.Components; @@ -65,4 +67,6 @@ namespace modular_avatar_tests.DuplicatePBStripping Assert.AreEqual(2, prefab.GetComponentsInChildren().Length); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/EasySetupOutfit/ArmatureConfusionTest.cs b/UnitTests~/EasySetupOutfit/ArmatureConfusionTest.cs index 786a9ef9..57eca28a 100644 --- a/UnitTests~/EasySetupOutfit/ArmatureConfusionTest.cs +++ b/UnitTests~/EasySetupOutfit/ArmatureConfusionTest.cs @@ -3,7 +3,11 @@ using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEditor; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Avatars.Components; +#endif + using UnityObject = UnityEngine.Object; public class ArmatureConfusionTest : TestBase @@ -24,7 +28,9 @@ public class ArmatureConfusionTest : TestBase var inner = CreatePrefab("shapell.fbx"); var outerAnimator = outer.GetComponent(); +#if MA_VRCSDK3_AVATARS outer.AddComponent(); +#endif inner.gameObject.name = "inner"; inner.transform.parent = outer.transform; diff --git a/UnitTests~/ExpressionMenuFixupTests/ExpressionMenuFixupTests.cs b/UnitTests~/ExpressionMenuFixupTests/ExpressionMenuFixupTests.cs index 91f8ac6e..5ed15e4a 100644 --- a/UnitTests~/ExpressionMenuFixupTests/ExpressionMenuFixupTests.cs +++ b/UnitTests~/ExpressionMenuFixupTests/ExpressionMenuFixupTests.cs @@ -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 VRC.SDK3.Avatars.Components; @@ -35,4 +37,6 @@ namespace modular_avatar_tests } } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/GameObjectGC/GameObjectGC.cs b/UnitTests~/GameObjectGC/GameObjectGC.cs index 711cad4e..1bfb7908 100644 --- a/UnitTests~/GameObjectGC/GameObjectGC.cs +++ b/UnitTests~/GameObjectGC/GameObjectGC.cs @@ -3,7 +3,6 @@ using modular_avatar_tests; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEngine; -using VRC.SDK3.Avatars.Components; public class GameObjectGC : TestBase { @@ -11,9 +10,9 @@ public class GameObjectGC : TestBase public void FakeHumanoidHandling() { var fake_humanoid = CreatePrefab("FakeHumanoid.prefab"); - var avdesc = fake_humanoid.GetComponent(); + var context = new BuildContext(fake_humanoid); - new GCGameObjectsPass(new BuildContext(avdesc), fake_humanoid).OnPreprocessAvatar(); + new GCGameObjectsPass(context, fake_humanoid).OnPreprocessAvatar(); AvatarProcessor.ProcessAvatar(fake_humanoid); var animator = fake_humanoid.GetComponent(); @@ -26,13 +25,13 @@ public class GameObjectGC : TestBase public void RetainEndBones() { var fake_humanoid = CreatePrefab("FakeHumanoid.prefab"); - var avdesc = fake_humanoid.GetComponent(); + 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(new BuildContext(avdesc), fake_humanoid).OnPreprocessAvatar(); + new GCGameObjectsPass(context, fake_humanoid).OnPreprocessAvatar(); AvatarProcessor.ProcessAvatar(fake_humanoid); Assert.True(bone1 != null); @@ -44,17 +43,17 @@ public class GameObjectGC : TestBase public void RetainArmatureHack() { var fake_humanoid = CreatePrefab("FakeHumanoid.prefab"); - var avdesc = fake_humanoid.GetComponent(); + 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(new BuildContext(avdesc), fake_humanoid).OnPreprocessAvatar(); + new GCGameObjectsPass(context, fake_humanoid).OnPreprocessAvatar(); AvatarProcessor.ProcessAvatar(fake_humanoid); Assert.AreEqual(2, - avdesc.GetComponentsInChildren().Count(t => t.gameObject.name == "Armature")); + context.AvatarRootObject.GetComponentsInChildren().Count(t => t.gameObject.name == "Armature")); } } \ No newline at end of file diff --git a/UnitTests~/MergeArmatureTests/MultiLevelMergeTest.cs b/UnitTests~/MergeArmatureTests/MultiLevelMergeTest.cs index 6ab29424..dc65c5d1 100644 --- a/UnitTests~/MergeArmatureTests/MultiLevelMergeTest.cs +++ b/UnitTests~/MergeArmatureTests/MultiLevelMergeTest.cs @@ -4,7 +4,6 @@ using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEngine; -using VRC.SDK3.Avatars.Components; namespace modular_avatar_tests.MergeArmatureTests { @@ -53,7 +52,7 @@ namespace modular_avatar_tests.MergeArmatureTests m2_leaf3.AddComponent(); nadena.dev.ndmf.BuildContext context = - new nadena.dev.ndmf.BuildContext(root.GetComponent(), null); + new nadena.dev.ndmf.BuildContext(root, null); context.ActivateExtensionContext(); context.ActivateExtensionContext(); new MergeArmatureHook().OnPreprocessAvatar(context, root); @@ -81,7 +80,7 @@ namespace modular_avatar_tests.MergeArmatureTests ma.mangleNames = false; nadena.dev.ndmf.BuildContext context = - new nadena.dev.ndmf.BuildContext(root.GetComponent(), null); + new nadena.dev.ndmf.BuildContext(root, null); context.ActivateExtensionContext(); context.ActivateExtensionContext(); new MergeArmatureHook().OnPreprocessAvatar(context, root); @@ -105,7 +104,7 @@ namespace modular_avatar_tests.MergeArmatureTests ma.mergeTarget.referencePath = RuntimeUtil.AvatarRootPath(armature); nadena.dev.ndmf.BuildContext context = - new nadena.dev.ndmf.BuildContext(root.GetComponent(), null); + new nadena.dev.ndmf.BuildContext(root, null); context.ActivateExtensionContext(); context.ActivateExtensionContext(); new MergeArmatureHook().OnPreprocessAvatar(context, root); diff --git a/UnitTests~/MeshSettingsTests/MeshSettingsTests.cs b/UnitTests~/MeshSettingsTests/MeshSettingsTests.cs index edd82d45..ed92dd87 100644 --- a/UnitTests~/MeshSettingsTests/MeshSettingsTests.cs +++ b/UnitTests~/MeshSettingsTests/MeshSettingsTests.cs @@ -1,7 +1,6 @@ using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEngine; -using VRC.SDK3.Avatars.Components; namespace modular_avatar_tests { @@ -13,7 +12,7 @@ namespace modular_avatar_tests public void TestProbeAnchor() { var prefab = CreatePrefab(PREFAB_NAME); - var context = new BuildContext(prefab.GetComponent()); + var context = new BuildContext(prefab); new MeshSettingsPass(context).OnPreprocessAvatar(); var root = prefab.transform.Find("RendererRoot"); @@ -33,7 +32,7 @@ namespace modular_avatar_tests public void TestProbeAnchorOverrides() { var prefab = CreatePrefab(PREFAB_NAME); - var context = new BuildContext(prefab.GetComponent()); + var context = new BuildContext(prefab); new MeshSettingsPass(context).OnPreprocessAvatar(); var noninherit = prefab.transform.Find("ProbeTargetRenderers/NonInherited").GetComponent(); @@ -47,7 +46,7 @@ namespace modular_avatar_tests public void TestSetBounds() { var prefab = CreatePrefab(PREFAB_NAME); - var context = new BuildContext(prefab.GetComponent()); + var context = new BuildContext(prefab); new MeshSettingsPass(context).OnPreprocessAvatar(); var target = prefab.transform.Find("ProbeTarget"); diff --git a/UnitTests~/MiscAnimationTests/MiscAnimationTests.cs b/UnitTests~/MiscAnimationTests/MiscAnimationTests.cs index 94d2cafc..650b3703 100644 --- a/UnitTests~/MiscAnimationTests/MiscAnimationTests.cs +++ b/UnitTests~/MiscAnimationTests/MiscAnimationTests.cs @@ -1,4 +1,6 @@ -using modular_avatar_tests; +#if MA_VRCSDK3_AVATARS + +using modular_avatar_tests; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEditor; @@ -19,4 +21,6 @@ public class MiscAnimationTests : TestBase Assert.True(new SerializedObject(hq_on.motion).FindProperty("m_UseHighQualityCurve").boolValue); Assert.False(new SerializedObject(hq_off.motion).FindProperty("m_UseHighQualityCurve").boolValue); } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/NullSubparameterTest.cs b/UnitTests~/NullSubparameterTest.cs index 50cd97e9..ec775dfc 100644 --- a/UnitTests~/NullSubparameterTest.cs +++ b/UnitTests~/NullSubparameterTest.cs @@ -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 UnityEngine; using VRC.SDK3.Avatars.Components; @@ -21,4 +23,6 @@ namespace modular_avatar_tests ParameterPolicy.ProbeParameters(root); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/RenameParametersTests/RenameParametersTests.cs b/UnitTests~/RenameParametersTests/RenameParametersTests.cs index c37374a1..00bfb7ad 100644 --- a/UnitTests~/RenameParametersTests/RenameParametersTests.cs +++ b/UnitTests~/RenameParametersTests/RenameParametersTests.cs @@ -1,4 +1,6 @@ -using nadena.dev.modular_avatar.core; +#if MA_VRCSDK3_AVATARS + +using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using VRC.SDK3.Avatars.Components; @@ -61,4 +63,6 @@ namespace modular_avatar_tests.RenameParametersTests AvatarProcessor.ProcessAvatar(avatar); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/ReplaceObject/ReplaceObjectTests.cs b/UnitTests~/ReplaceObject/ReplaceObjectTests.cs index 16d0945b..eeca298e 100644 --- a/UnitTests~/ReplaceObject/ReplaceObjectTests.cs +++ b/UnitTests~/ReplaceObject/ReplaceObjectTests.cs @@ -5,7 +5,6 @@ using nadena.dev.modular_avatar.core.editor; using nadena.dev.modular_avatar.editor.ErrorReporting; using NUnit.Framework; using UnityEngine; -using VRC.SDK3.Avatars.Components; namespace modular_avatar_tests.ReplaceObject { @@ -15,8 +14,7 @@ namespace modular_avatar_tests.ReplaceObject void Process(GameObject root) { - var avDesc = root.GetComponent(); - var buildContext = new nadena.dev.ndmf.BuildContext(avDesc, null); + var buildContext = new nadena.dev.ndmf.BuildContext(root, null); pathMappings = buildContext.ActivateExtensionContext().PathMappings; new ReplaceObjectPass(buildContext).Process(); } diff --git a/UnitTests~/RetargetMeshesTest.cs b/UnitTests~/RetargetMeshesTest.cs index 11f36e03..b3fc1d57 100644 --- a/UnitTests~/RetargetMeshesTest.cs +++ b/UnitTests~/RetargetMeshesTest.cs @@ -2,7 +2,6 @@ using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEngine; -using VRC.SDK3.Avatars.Components; namespace modular_avatar_tests { @@ -21,8 +20,7 @@ namespace modular_avatar_tests skinnedMeshRenderer.rootBone = b.transform; Debug.Assert(skinnedMeshRenderer.bones.Length == 0); - var build_context = - new nadena.dev.ndmf.BuildContext(root.GetComponent(), null); + var build_context = new nadena.dev.ndmf.BuildContext(root, null); var torc = new AnimationServicesContext(); torc.OnActivate(build_context); @@ -48,8 +46,7 @@ namespace modular_avatar_tests skinnedMeshRenderer.rootBone = b.transform; Debug.Assert(skinnedMeshRenderer.bones.Length == 0); - var build_context = - new nadena.dev.ndmf.BuildContext(root.GetComponent(), null); + var build_context = new nadena.dev.ndmf.BuildContext(root, null); var torc = new AnimationServicesContext(); torc.OnActivate(build_context); diff --git a/UnitTests~/SerializationTests/SerializationTests.cs b/UnitTests~/SerializationTests/SerializationTests.cs index 6861d7b8..b7272b90 100644 --- a/UnitTests~/SerializationTests/SerializationTests.cs +++ b/UnitTests~/SerializationTests/SerializationTests.cs @@ -1,4 +1,6 @@ -using System.Linq; +#if MA_VRCSDK3_AVATARS + +using System.Linq; using modular_avatar_tests; using nadena.dev.ndmf.runtime; using nadena.dev.modular_avatar.core; @@ -64,4 +66,6 @@ namespace _ModularAvatar.EditModeTests.SerializationTests Assert.IsInstanceOf(mainAsset); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/SimpleArmatureToggle/SimpleArmatureToggle.cs b/UnitTests~/SimpleArmatureToggle/SimpleArmatureToggle.cs index 526f8fe1..3c83e874 100644 --- a/UnitTests~/SimpleArmatureToggle/SimpleArmatureToggle.cs +++ b/UnitTests~/SimpleArmatureToggle/SimpleArmatureToggle.cs @@ -1,4 +1,6 @@ -using nadena.dev.modular_avatar.core; +#if MA_VRCSDK3_AVATARS + +using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEditor; @@ -29,4 +31,6 @@ namespace modular_avatar_tests.SimpleArmatureToggle Assert.NotNull(AnimationUtility.GetEditorCurve(motion, binding2)); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/SyncedLayerHandling/SyncedLayerHandling.cs b/UnitTests~/SyncedLayerHandling/SyncedLayerHandling.cs index 417512ca..fb0fd678 100644 --- a/UnitTests~/SyncedLayerHandling/SyncedLayerHandling.cs +++ b/UnitTests~/SyncedLayerHandling/SyncedLayerHandling.cs @@ -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 VRC.SDK3.Avatars.Components; @@ -94,4 +96,6 @@ namespace modular_avatar_tests.SyncedLayerHandling Assert.AreEqual(2, layercontrol.layer); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/TestBase.cs b/UnitTests~/TestBase.cs index 84890282..86f5c22e 100644 --- a/UnitTests~/TestBase.cs +++ b/UnitTests~/TestBase.cs @@ -7,7 +7,10 @@ using NUnit.Framework; using UnityEditor; using UnityEditor.Animations; using UnityEngine; + +#if MA_VRCSDK3_AVATARS using VRC.SDK3.Avatars.Components; +#endif namespace modular_avatar_tests { @@ -95,6 +98,7 @@ namespace modular_avatar_tests return obj; } +#if MA_VRCSDK3_AVATARS protected static AnimationClip findFxClip(GameObject prefab, string layerName) { var motion = findFxMotion(prefab, layerName) as AnimationClip; @@ -110,6 +114,7 @@ namespace modular_avatar_tests return state.motion; } +#endif protected static AnimatorState FindStateInLayer(AnimatorControllerLayer layer, string stateName) { @@ -121,6 +126,7 @@ namespace modular_avatar_tests return null; } +#if MA_VRCSDK3_AVATARS protected static AnimatorControllerLayer findFxLayer(GameObject prefab, string layerName) { var fx = prefab.GetComponent().baseAnimationLayers @@ -135,5 +141,6 @@ namespace modular_avatar_tests Assert.NotNull(layer); return layer; } +#endif } } \ No newline at end of file diff --git a/UnitTests~/Tests.asmdef b/UnitTests~/Tests.asmdef index e5cd2b6e..6e7b31cf 100644 --- a/UnitTests~/Tests.asmdef +++ b/UnitTests~/Tests.asmdef @@ -25,6 +25,12 @@ "defineConstraints": [ "UNITY_INCLUDE_TESTS" ], - "versionDefines": [], + "versionDefines": [ + { + "name": "com.vrchat.avatars", + "expression": "", + "define": "MA_VRCSDK3_AVATARS" + } + ], "noEngineReferences": false } \ No newline at end of file diff --git a/UnitTests~/TransformMappingThroughSwitchedObject/TransformMappingThroughSwitchedObject.cs b/UnitTests~/TransformMappingThroughSwitchedObject/TransformMappingThroughSwitchedObject.cs index c0016c9e..006022c6 100644 --- a/UnitTests~/TransformMappingThroughSwitchedObject/TransformMappingThroughSwitchedObject.cs +++ b/UnitTests~/TransformMappingThroughSwitchedObject/TransformMappingThroughSwitchedObject.cs @@ -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; @@ -24,4 +26,6 @@ namespace modular_avatar_tests.TransformMappingThroughSwitchedObject Assert.IsNotNull(curve); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/VirtualMenuTests/VirtualMenuTests.cs b/UnitTests~/VirtualMenuTests/VirtualMenuTests.cs index 3ae66d9d..04669ef5 100644 --- a/UnitTests~/VirtualMenuTests/VirtualMenuTests.cs +++ b/UnitTests~/VirtualMenuTests/VirtualMenuTests.cs @@ -1,4 +1,6 @@ -using System; +#if MA_VRCSDK3_AVATARS + +using System; using System.Collections.Generic; using System.Linq; using nadena.dev.modular_avatar.core; @@ -767,4 +769,6 @@ namespace modular_avatar_tests.VirtualMenuTests return null; } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/UnitTests~/WorldFixedObjectTest/WorldFixedObjectTest.cs b/UnitTests~/WorldFixedObjectTest/WorldFixedObjectTest.cs index 538de66f..904c46ab 100644 --- a/UnitTests~/WorldFixedObjectTest/WorldFixedObjectTest.cs +++ b/UnitTests~/WorldFixedObjectTest/WorldFixedObjectTest.cs @@ -3,7 +3,6 @@ using nadena.dev.modular_avatar.animation; using nadena.dev.modular_avatar.core.editor; using NUnit.Framework; using UnityEngine.Animations; -using VRC.SDK3.Avatars.Components; public class WorldFixedObjectTest : TestBase { @@ -11,12 +10,11 @@ public class WorldFixedObjectTest : TestBase public void SimpleTest() { var avatar = CreatePrefab("Simple.prefab"); - var descriptor = avatar.GetComponent(); var fixedObject = avatar.transform.Find("FixedObject"); // initialize context - var buildContext = new BuildContext(descriptor); + var buildContext = new BuildContext(avatar); buildContext.PluginBuildContext.ActivateExtensionContext(); new WorldFixedObjectProcessor().Process(buildContext); @@ -37,13 +35,12 @@ public class WorldFixedObjectTest : TestBase public void NestedTest() { var avatar = CreatePrefab("Nested.prefab"); - var descriptor = avatar.GetComponent(); var fixedObject = avatar.transform.Find("FixedObject"); var nestedFixed = avatar.transform.Find("FixedObject/NestedFixed"); // initialize context - var buildContext = new BuildContext(descriptor); + var buildContext = new BuildContext(avatar); buildContext.PluginBuildContext.ActivateExtensionContext(); new WorldFixedObjectProcessor().Process(buildContext);