mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-28 10:15:06 +08:00
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
This commit is contained in:
parent
3a34079aef
commit
3667dc319a
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<VRCExpressionsMenu, VRCExpressionsMenu> ClonedMenus
|
||||
= new Dictionary<VRCExpressionsMenu, VRCExpressionsMenu>();
|
||||
|
||||
public static implicit operator BuildContext(ndmf.BuildContext ctx) =>
|
||||
ctx.Extension<ModularAvatarContext>().BuildContext;
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
internal readonly Dictionary<ModularAvatarMenuInstaller, Action<VRCExpressionsMenu.Control>> PostProcessControls
|
||||
= new Dictionary<ModularAvatarMenuInstaller, Action<VRCExpressionsMenu.Control>>();
|
||||
#endif
|
||||
public static implicit operator BuildContext(ndmf.BuildContext ctx) =>
|
||||
ctx.Extension<ModularAvatarContext>().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
|
||||
}
|
||||
}
|
@ -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<ErrorLog> 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<ErrorLog> CheckInternal(ModularAvatarMergeArmature ma)
|
||||
{
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<UnityEngine.Object, AssetInfo> _assets;
|
||||
@ -60,10 +66,15 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
public void PopulateReferences(Dictionary<UnityEngine.Object, AssetInfo> 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);
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<VRCPhysBone>(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<IConstraint>(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
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
public void OnPreprocessAvatar()
|
||||
{
|
||||
foreach (var mesh in context.AvatarDescriptor.GetComponentsInChildren<Renderer>(true))
|
||||
foreach (var mesh in context.AvatarRootObject.GetComponentsInChildren<Renderer>(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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<ModularAvatarContext>().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<RenameParametersPluginPass>
|
||||
{
|
||||
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<MergeArmaturePluginPass>
|
||||
{
|
||||
@ -198,6 +206,7 @@ namespace nadena.dev.modular_avatar.core.editor.plugin
|
||||
}
|
||||
}
|
||||
|
||||
#if MA_VRCSDK3_AVATARS
|
||||
class BlendshapeSyncAnimationPluginPass : MAPass<BlendshapeSyncAnimationPluginPass>
|
||||
{
|
||||
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<GCGameObjectsPluginPass>
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<ModularAvatarReplaceObject>(true);
|
||||
avatarRootTransform.GetComponentsInChildren<ModularAvatarReplaceObject>(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<UnityObject, List<Reference>> refIndex = new Dictionary<UnityObject, List<Reference>>();
|
||||
|
||||
IndexObject(_buildContext.AvatarDescriptor.gameObject);
|
||||
IndexObject(_buildContext.AvatarRootObject);
|
||||
|
||||
return refIndex;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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<Animator>();
|
||||
_headBone = animator != null ? animator.GetBoneTransform(HumanBodyBones.Head) : null;
|
||||
|
||||
#if MA_VRCSDK3_AVATARS
|
||||
foreach (var physBone in _avatarTransform.GetComponentsInChildren<VRCPhysBone>(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()
|
||||
|
@ -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
|
||||
|
@ -1,7 +1,10 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
#if MA_VRCSDK3_AVATARS
|
||||
using VRC.SDKBase;
|
||||
#endif
|
||||
|
||||
namespace nadena.dev.modular_avatar.core
|
||||
{
|
||||
|
@ -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
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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)
|
||||
{
|
||||
|
@ -17,6 +17,12 @@
|
||||
],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.vrchat.avatars",
|
||||
"expression": "",
|
||||
"define": "MA_VRCSDK3_AVATARS"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
@ -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<VRCAvatarDescriptor>();
|
||||
|
||||
// initialize context
|
||||
var buildContext = new BuildContext(descriptor);
|
||||
var buildContext = new BuildContext(avatar);
|
||||
var pathMappings = buildContext.PluginBuildContext.ActivateExtensionContext<AnimationServicesContext>()
|
||||
.PathMappings;
|
||||
|
||||
@ -41,4 +41,6 @@ public class ActiveAnimationRetargeterTests : TestBase
|
||||
Assert.That(curveBindings, Does.Contain(EditorCurveBinding.FloatCurve(
|
||||
pathMappings.GetObjectIdentifier(created), typeof(GameObject), "m_IsActive")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<VRCPhysBone>().Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<Animator>();
|
||||
#if MA_VRCSDK3_AVATARS
|
||||
outer.AddComponent<VRCAvatarDescriptor>();
|
||||
#endif
|
||||
|
||||
inner.gameObject.name = "inner";
|
||||
inner.transform.parent = outer.transform;
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<VRCAvatarDescriptor>();
|
||||
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<Animator>();
|
||||
@ -26,13 +25,13 @@ public class GameObjectGC : TestBase
|
||||
public void RetainEndBones()
|
||||
{
|
||||
var fake_humanoid = CreatePrefab("FakeHumanoid.prefab");
|
||||
var avdesc = fake_humanoid.GetComponent<VRCAvatarDescriptor>();
|
||||
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<VRCAvatarDescriptor>();
|
||||
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<Transform>().Count(t => t.gameObject.name == "Armature"));
|
||||
context.AvatarRootObject.GetComponentsInChildren<Transform>().Count(t => t.gameObject.name == "Armature"));
|
||||
}
|
||||
}
|
@ -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<TestComponentB>();
|
||||
|
||||
nadena.dev.ndmf.BuildContext context =
|
||||
new nadena.dev.ndmf.BuildContext(root.GetComponent<VRCAvatarDescriptor>(), null);
|
||||
new nadena.dev.ndmf.BuildContext(root, null);
|
||||
context.ActivateExtensionContext<ModularAvatarContext>();
|
||||
context.ActivateExtensionContext<AnimationServicesContext>();
|
||||
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<VRCAvatarDescriptor>(), null);
|
||||
new nadena.dev.ndmf.BuildContext(root, null);
|
||||
context.ActivateExtensionContext<ModularAvatarContext>();
|
||||
context.ActivateExtensionContext<AnimationServicesContext>();
|
||||
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<VRCAvatarDescriptor>(), null);
|
||||
new nadena.dev.ndmf.BuildContext(root, null);
|
||||
context.ActivateExtensionContext<ModularAvatarContext>();
|
||||
context.ActivateExtensionContext<AnimationServicesContext>();
|
||||
new MergeArmatureHook().OnPreprocessAvatar(context, root);
|
||||
|
@ -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<VRCAvatarDescriptor>());
|
||||
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<VRCAvatarDescriptor>());
|
||||
var context = new BuildContext(prefab);
|
||||
new MeshSettingsPass(context).OnPreprocessAvatar();
|
||||
|
||||
var noninherit = prefab.transform.Find("ProbeTargetRenderers/NonInherited").GetComponent<MeshRenderer>();
|
||||
@ -47,7 +46,7 @@ namespace modular_avatar_tests
|
||||
public void TestSetBounds()
|
||||
{
|
||||
var prefab = CreatePrefab(PREFAB_NAME);
|
||||
var context = new BuildContext(prefab.GetComponent<VRCAvatarDescriptor>());
|
||||
var context = new BuildContext(prefab);
|
||||
new MeshSettingsPass(context).OnPreprocessAvatar();
|
||||
|
||||
var target = prefab.transform.Find("ProbeTarget");
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<VRCAvatarDescriptor>();
|
||||
var buildContext = new nadena.dev.ndmf.BuildContext(avDesc, null);
|
||||
var buildContext = new nadena.dev.ndmf.BuildContext(root, null);
|
||||
pathMappings = buildContext.ActivateExtensionContext<AnimationServicesContext>().PathMappings;
|
||||
new ReplaceObjectPass(buildContext).Process();
|
||||
}
|
||||
|
@ -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<VRCAvatarDescriptor>(), 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<VRCAvatarDescriptor>(), null);
|
||||
var build_context = new nadena.dev.ndmf.BuildContext(root, null);
|
||||
var torc = new AnimationServicesContext();
|
||||
torc.OnActivate(build_context);
|
||||
|
||||
|
@ -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<GeneratedAssets>(mainAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<VRCAvatarDescriptor>().baseAnimationLayers
|
||||
@ -135,5 +141,6 @@ namespace modular_avatar_tests
|
||||
Assert.NotNull(layer);
|
||||
return layer;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
@ -25,6 +25,12 @@
|
||||
"defineConstraints": [
|
||||
"UNITY_INCLUDE_TESTS"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.vrchat.avatars",
|
||||
"expression": "",
|
||||
"define": "MA_VRCSDK3_AVATARS"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -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<VRCAvatarDescriptor>();
|
||||
|
||||
var fixedObject = avatar.transform.Find("FixedObject");
|
||||
|
||||
// initialize context
|
||||
var buildContext = new BuildContext(descriptor);
|
||||
var buildContext = new BuildContext(avatar);
|
||||
buildContext.PluginBuildContext.ActivateExtensionContext<AnimationServicesContext>();
|
||||
|
||||
new WorldFixedObjectProcessor().Process(buildContext);
|
||||
@ -37,13 +35,12 @@ public class WorldFixedObjectTest : TestBase
|
||||
public void NestedTest()
|
||||
{
|
||||
var avatar = CreatePrefab("Nested.prefab");
|
||||
var descriptor = avatar.GetComponent<VRCAvatarDescriptor>();
|
||||
|
||||
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<AnimationServicesContext>();
|
||||
|
||||
new WorldFixedObjectProcessor().Process(buildContext);
|
||||
|
Loading…
Reference in New Issue
Block a user