mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-03-09 23:34:56 +08:00
Support absolute referenced animator merging (#22)
also fix a bug where only one animator per layer could be merged, oops.
This commit is contained in:
parent
5455e0da87
commit
108df78f06
@ -27,13 +27,14 @@ using UnityEditor;
|
||||
using UnityEditor.Animations;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.Components;
|
||||
using VRC.SDKBase.Editor.BuildPipeline;
|
||||
|
||||
namespace net.fushizen.modular_avatar.core.editor
|
||||
{
|
||||
internal class MergeAnimatorProcessor
|
||||
{
|
||||
private const string SAMPLE_PATH_PACKAGE = "Packages/com.vrchat.avatars/Samples/AV3 Demo Assets/Animation/Controllers";
|
||||
private const string SAMPLE_PATH_PACKAGE =
|
||||
"Packages/com.vrchat.avatars/Samples/AV3 Demo Assets/Animation/Controllers";
|
||||
|
||||
private const string SAMPLE_PATH_LEGACY = "Assets/VRCSDK/Examples3/Animation/Controllers";
|
||||
|
||||
private Dictionary<VRCAvatarDescriptor.AnimLayerType, AnimatorController> defaultControllers_ =
|
||||
@ -58,6 +59,17 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
{
|
||||
if (merge.animator == null) continue;
|
||||
|
||||
string basePath;
|
||||
if (merge.pathMode == MergeAnimatorPathMode.Relative)
|
||||
{
|
||||
var relativePath = RuntimeUtil.RelativePath(avatarGameObject, merge.gameObject);
|
||||
basePath = relativePath != "" ? relativePath + "/" : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
basePath = "";
|
||||
}
|
||||
|
||||
if (!mergeSessions.TryGetValue(merge.layerType, out var session))
|
||||
{
|
||||
session = new AnimatorCombiner();
|
||||
@ -66,13 +78,10 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
{
|
||||
session.AddController("", defaultControllers_[merge.layerType]);
|
||||
}
|
||||
var relativePath = RuntimeUtil.RelativePath(avatarGameObject, merge.gameObject);
|
||||
mergeSessions[merge.layerType].AddController(
|
||||
relativePath != "" ? relativePath + "/" : "",
|
||||
(AnimatorController) merge.animator
|
||||
);
|
||||
}
|
||||
|
||||
mergeSessions[merge.layerType].AddController(basePath, (AnimatorController) merge.animator);
|
||||
|
||||
if (merge.deleteAttachedAnimator)
|
||||
{
|
||||
var animator = merge.GetComponent<Animator>();
|
||||
@ -114,7 +123,6 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static AnimatorController ResolveLayerController(VRCAvatarDescriptor.CustomAnimLayer layer)
|
||||
{
|
||||
AnimatorController controller = null;
|
||||
|
@ -27,10 +27,17 @@ using VRC.SDK3.Avatars.Components;
|
||||
|
||||
namespace net.fushizen.modular_avatar.core
|
||||
{
|
||||
public enum MergeAnimatorPathMode
|
||||
{
|
||||
Relative,
|
||||
Absolute
|
||||
}
|
||||
|
||||
public class ModularAvatarMergeAnimator : AvatarTagComponent
|
||||
{
|
||||
public RuntimeAnimatorController animator;
|
||||
public VRCAvatarDescriptor.AnimLayerType layerType;
|
||||
public bool deleteAttachedAnimator;
|
||||
public MergeAnimatorPathMode pathMode = MergeAnimatorPathMode.Relative;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user