(BREAKING) Add AnimatorAsCode V1:
- Breaking changes: - Remove dependency to VRChat in the AnimatorAsCode.V1 namespace. The namespace should now be usable in non-VRChat projects. - All VRChat-specific methods are now extension functions in a separate namespace, AnimatorAsCode.V1.VRC. - VRChat methods that modify existing assets are split into a separate namespace, AnimatorAsCode.V1.VRCDestructiveWorkflow. - Breaking fixes: - Fix incorrect type signature on AacFlFloatParameterGroup.ToList() and AacFlIntParameterGroup.ToList(). - Add AacFlBase.NewBlendTree(): - This allows creating blend trees as code. - Add AacFlState.WithAnimation(AacFlBlendTree). - Add AacFlBase.NoAnimator(): - This can be used to obtain AacFlParameter objects for use in the generation of BlendTrees and other systems, without requiring the existence of a backing animator controller. - This can also be used in some cases where there are type casts (Bool to Float, Float to Bool). - Add AacFlBase.NewAnimatorController(): - This is meant to be used for non-destructive workflows. - This creates an animator controller inside the asset container. This animator controller will be reaped in the same way as other assets are reaped.
This commit is contained in:
+246
-107
@@ -16,6 +16,19 @@ namespace AnimatorAsCode.V1
|
|||||||
return new AacFlBase(configuration);
|
return new AacFlBase(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static AnimatorController NewAnimatorController(AacConfiguration component, string suffix)
|
||||||
|
{
|
||||||
|
return RegisterAnimatorController(component, suffix, new AnimatorController());
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static AnimatorController RegisterAnimatorController(AacConfiguration component, string suffix, AnimatorController animatorController)
|
||||||
|
{
|
||||||
|
animatorController.name = "zAutogenerated__" + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
|
||||||
|
animatorController.hideFlags = HideFlags.None;
|
||||||
|
AssetDatabase.AddObjectToAsset(animatorController, component.AssetContainer);
|
||||||
|
return animatorController;
|
||||||
|
}
|
||||||
|
|
||||||
internal static AnimationClip NewClip(AacConfiguration component, string suffix)
|
internal static AnimationClip NewClip(AacConfiguration component, string suffix)
|
||||||
{
|
{
|
||||||
return RegisterClip(component, suffix, new AnimationClip());
|
return RegisterClip(component, suffix, new AnimationClip());
|
||||||
@@ -77,6 +90,8 @@ namespace AnimatorAsCode.V1
|
|||||||
public struct AacConfiguration
|
public struct AacConfiguration
|
||||||
{
|
{
|
||||||
public string SystemName;
|
public string SystemName;
|
||||||
|
// Please consult "MigratingFromV0ToV1.md" on how to migrate this property
|
||||||
|
// public VRCAvatarDescriptor AvatarDescriptor;
|
||||||
public Transform AnimatorRoot;
|
public Transform AnimatorRoot;
|
||||||
public Transform DefaultValueRoot;
|
public Transform DefaultValueRoot;
|
||||||
public AnimatorController AssetContainer;
|
public AnimatorController AssetContainer;
|
||||||
@@ -157,19 +172,18 @@ namespace AnimatorAsCode.V1
|
|||||||
return _stateMachine.EntryTransitionsTo(destination);
|
return _stateMachine.EntryTransitionsTo(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AacFlBoolParameter BoolParameter(string parameterName) => _stateMachine.BackingAnimator().BoolParameter(parameterName);
|
public AacFlBoolParameter BoolParameter(string parameterName) => _stateMachine.InternalBackingAnimator().BoolParameter(parameterName);
|
||||||
public AacFlBoolParameter TriggerParameterAsBool(string parameterName) => _stateMachine.BackingAnimator().TriggerParameter(parameterName);
|
public AacFlBoolParameter TriggerParameterAsBool(string parameterName) => _stateMachine.InternalBackingAnimator().TriggerParameter(parameterName);
|
||||||
public AacFlFloatParameter FloatParameter(string parameterName) => _stateMachine.BackingAnimator().FloatParameter(parameterName);
|
public AacFlFloatParameter FloatParameter(string parameterName) => _stateMachine.InternalBackingAnimator().FloatParameter(parameterName);
|
||||||
public AacFlIntParameter IntParameter(string parameterName) => _stateMachine.BackingAnimator().IntParameter(parameterName);
|
public AacFlIntParameter IntParameter(string parameterName) => _stateMachine.InternalBackingAnimator().IntParameter(parameterName);
|
||||||
public AacFlBoolParameterGroup BoolParameters(params string[] parameterNames) => _stateMachine.BackingAnimator().BoolParameters(parameterNames);
|
public AacFlBoolParameterGroup BoolParameters(params string[] parameterNames) => _stateMachine.InternalBackingAnimator().BoolParameters(parameterNames);
|
||||||
public AacFlBoolParameterGroup TriggerParametersAsBools(params string[] parameterNames) => _stateMachine.BackingAnimator().TriggerParameters(parameterNames);
|
public AacFlBoolParameterGroup TriggerParametersAsBools(params string[] parameterNames) => _stateMachine.InternalBackingAnimator().TriggerParameters(parameterNames);
|
||||||
public AacFlFloatParameterGroup FloatParameters(params string[] parameterNames) => _stateMachine.BackingAnimator().FloatParameters(parameterNames);
|
public AacFlFloatParameterGroup FloatParameters(params string[] parameterNames) => _stateMachine.InternalBackingAnimator().FloatParameters(parameterNames);
|
||||||
public AacFlIntParameterGroup IntParameters(params string[] parameterNames) => _stateMachine.BackingAnimator().IntParameters(parameterNames);
|
public AacFlIntParameterGroup IntParameters(params string[] parameterNames) => _stateMachine.InternalBackingAnimator().IntParameters(parameterNames);
|
||||||
public AacFlBoolParameterGroup BoolParameters(params AacFlBoolParameter[] parameters) => _stateMachine.BackingAnimator().BoolParameters(parameters);
|
public AacFlBoolParameterGroup BoolParameters(params AacFlBoolParameter[] parameters) => _stateMachine.InternalBackingAnimator().BoolParameters(parameters);
|
||||||
public AacFlBoolParameterGroup TriggerParametersAsBools(params AacFlBoolParameter[] parameters) => _stateMachine.BackingAnimator().TriggerParameters(parameters);
|
public AacFlBoolParameterGroup TriggerParametersAsBools(params AacFlBoolParameter[] parameters) => _stateMachine.InternalBackingAnimator().TriggerParameters(parameters);
|
||||||
public AacFlFloatParameterGroup FloatParameters(params AacFlFloatParameter[] parameters) => _stateMachine.BackingAnimator().FloatParameters(parameters);
|
public AacFlFloatParameterGroup FloatParameters(params AacFlFloatParameter[] parameters) => _stateMachine.InternalBackingAnimator().FloatParameters(parameters);
|
||||||
public AacFlIntParameterGroup IntParameters(params AacFlIntParameter[] parameters) => _stateMachine.BackingAnimator().IntParameters(parameters);
|
public AacFlIntParameterGroup IntParameters(params AacFlIntParameter[] parameters) => _stateMachine.InternalBackingAnimator().IntParameters(parameters);
|
||||||
public AacAv3 Av3() => new AacAv3(_stateMachine.BackingAnimator());
|
|
||||||
|
|
||||||
public AacFlLayer OverrideValue(AacFlBoolParameter toBeForced, bool value)
|
public AacFlLayer OverrideValue(AacFlBoolParameter toBeForced, bool value)
|
||||||
{
|
{
|
||||||
@@ -285,6 +299,11 @@ namespace AnimatorAsCode.V1
|
|||||||
_stateMachine.WithDefaultState(newDefaultState);
|
_stateMachine.WithDefaultState(newDefaultState);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AacFlStateMachine InternalStateMachine()
|
||||||
|
{
|
||||||
|
return _stateMachine;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AacFlBase
|
public class AacFlBase
|
||||||
@@ -314,6 +333,11 @@ namespace AnimatorAsCode.V1
|
|||||||
return new AacFlClip(_configuration, clip);
|
return new AacFlClip(_configuration, clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AacFlNonInitializedBlendTree NewBlendTree()
|
||||||
|
{
|
||||||
|
return new AacFlNonInitializedBlendTree(AacV1.NewBlendTreeAsRaw(_configuration, Guid.NewGuid().ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
public BlendTree NewBlendTreeAsRaw()
|
public BlendTree NewBlendTreeAsRaw()
|
||||||
{
|
{
|
||||||
return AacV1.NewBlendTreeAsRaw(_configuration, Guid.NewGuid().ToString());
|
return AacV1.NewBlendTreeAsRaw(_configuration, Guid.NewGuid().ToString());
|
||||||
@@ -353,6 +377,18 @@ namespace AnimatorAsCode.V1
|
|||||||
.WithUnit(unit, keyframes => keyframes.Constant(0, 0f).Constant(duration, 0f)));
|
.WithUnit(unit, keyframes => keyframes.Constant(0, 0f).Constant(duration, 0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AacFlController NewAnimatorController()
|
||||||
|
{
|
||||||
|
var animatorController = AacV1.NewAnimatorController(_configuration, Guid.NewGuid().ToString());
|
||||||
|
return new AacFlController(_configuration, animatorController, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlController NewAnimatorController(string name)
|
||||||
|
{
|
||||||
|
var animatorController = AacV1.NewAnimatorController(_configuration, name);
|
||||||
|
return new AacFlController(_configuration, animatorController, this);
|
||||||
|
}
|
||||||
|
|
||||||
public AacFlLayer CreateMainArbitraryControllerLayer(AnimatorController controller) => InternalDoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerName(_configuration.SystemName));
|
public AacFlLayer CreateMainArbitraryControllerLayer(AnimatorController controller) => InternalDoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerName(_configuration.SystemName));
|
||||||
public AacFlLayer CreateSupportingArbitraryControllerLayer(AnimatorController controller, string suffix) => InternalDoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerNameWithSuffix(_configuration.SystemName, suffix));
|
public AacFlLayer CreateSupportingArbitraryControllerLayer(AnimatorController controller, string suffix) => InternalDoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerNameWithSuffix(_configuration.SystemName, suffix));
|
||||||
public AacFlLayer CreateFirstArbitraryControllerLayer(AnimatorController controller) => InternalDoCreateLayer(controller, controller.layers[0].name);
|
public AacFlLayer CreateFirstArbitraryControllerLayer(AnimatorController controller) => InternalDoCreateLayer(controller, controller.layers[0].name);
|
||||||
@@ -365,17 +401,20 @@ namespace AnimatorAsCode.V1
|
|||||||
return new AacFlLayer(animator, _configuration, machine, layerName);
|
return new AacFlLayer(animator, _configuration, machine, layerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal AacFlLayer DoCreateLayerWithoutDeleting(AnimatorController animator, string layerName)
|
||||||
|
{
|
||||||
|
var ag = new AacAnimatorGenerator(animator, CreateEmptyClip().Clip, _configuration.DefaultsProvider);
|
||||||
|
var machine = ag.CreateOrClearLayerAtSameIndex(layerName, 1f, null, false);
|
||||||
|
|
||||||
|
return new AacFlLayer(animator, _configuration, machine, layerName);
|
||||||
|
}
|
||||||
|
|
||||||
private AacFlClip CreateEmptyClip()
|
private AacFlClip CreateEmptyClip()
|
||||||
{
|
{
|
||||||
var emptyClip = AnomalousSingleKeyframeClip();
|
var emptyClip = AnomalousSingleKeyframeClip();
|
||||||
return emptyClip;
|
return emptyClip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AacVrcAssetLibrary VrcAssets()
|
|
||||||
{
|
|
||||||
return new AacVrcAssetLibrary();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearPreviousAssets()
|
public void ClearPreviousAssets()
|
||||||
{
|
{
|
||||||
var allSubAssets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(_configuration.AssetContainer));
|
var allSubAssets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(_configuration.AssetContainer));
|
||||||
@@ -388,111 +427,207 @@ namespace AnimatorAsCode.V1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class AacAv3
|
public AacFlNoAnimator NoAnimator()
|
||||||
{
|
{
|
||||||
private readonly AacBackingAnimator _backingAnimator;
|
return new AacFlNoAnimator();
|
||||||
|
|
||||||
internal AacAv3(AacBackingAnimator backingAnimator)
|
|
||||||
{
|
|
||||||
_backingAnimator = backingAnimator;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReSharper disable InconsistentNaming
|
|
||||||
public AacFlBoolParameter IsLocal => _backingAnimator.BoolParameter("IsLocal");
|
|
||||||
public AacFlEnumIntParameter<Av3Viseme> Viseme => _backingAnimator.EnumParameter<Av3Viseme>("Viseme");
|
|
||||||
public AacFlEnumIntParameter<Av3Gesture> GestureLeft => _backingAnimator.EnumParameter<Av3Gesture>("GestureLeft");
|
|
||||||
public AacFlEnumIntParameter<Av3Gesture> GestureRight => _backingAnimator.EnumParameter<Av3Gesture>("GestureRight");
|
|
||||||
public AacFlFloatParameter GestureLeftWeight => _backingAnimator.FloatParameter("GestureLeftWeight");
|
|
||||||
public AacFlFloatParameter GestureRightWeight => _backingAnimator.FloatParameter("GestureRightWeight");
|
|
||||||
public AacFlFloatParameter AngularY => _backingAnimator.FloatParameter("AngularY");
|
|
||||||
public AacFlFloatParameter VelocityX => _backingAnimator.FloatParameter("VelocityX");
|
|
||||||
public AacFlFloatParameter VelocityY => _backingAnimator.FloatParameter("VelocityY");
|
|
||||||
public AacFlFloatParameter VelocityZ => _backingAnimator.FloatParameter("VelocityZ");
|
|
||||||
public AacFlFloatParameter Upright => _backingAnimator.FloatParameter("Upright");
|
|
||||||
public AacFlBoolParameter Grounded => _backingAnimator.BoolParameter("Grounded");
|
|
||||||
public AacFlBoolParameter Seated => _backingAnimator.BoolParameter("Seated");
|
|
||||||
public AacFlBoolParameter AFK => _backingAnimator.BoolParameter("AFK");
|
|
||||||
public AacFlIntParameter TrackingType => _backingAnimator.IntParameter("TrackingType");
|
|
||||||
public AacFlIntParameter VRMode => _backingAnimator.IntParameter("VRMode");
|
|
||||||
public AacFlBoolParameter MuteSelf => _backingAnimator.BoolParameter("MuteSelf");
|
|
||||||
public AacFlBoolParameter InStation => _backingAnimator.BoolParameter("InStation");
|
|
||||||
public AacFlFloatParameter Voice => _backingAnimator.FloatParameter("Voice");
|
|
||||||
// ReSharper restore InconsistentNaming
|
|
||||||
|
|
||||||
public IAacFlCondition ItIsRemote() => IsLocal.IsFalse();
|
|
||||||
public IAacFlCondition ItIsLocal() => IsLocal.IsTrue();
|
|
||||||
|
|
||||||
public enum Av3Gesture
|
|
||||||
{
|
|
||||||
// Specify all the values explicitly because they should be dictated by VRChat, not enumeration order.
|
|
||||||
Neutral = 0,
|
|
||||||
Fist = 1,
|
|
||||||
HandOpen = 2,
|
|
||||||
Fingerpoint = 3,
|
|
||||||
Victory = 4,
|
|
||||||
RockNRoll = 5,
|
|
||||||
HandGun = 6,
|
|
||||||
ThumbsUp = 7
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Av3Viseme
|
|
||||||
{
|
|
||||||
// Specify all the values explicitly because they should be dictated by VRChat, not enumeration order.
|
|
||||||
// ReSharper disable InconsistentNaming
|
|
||||||
sil = 0,
|
|
||||||
pp = 1,
|
|
||||||
ff = 2,
|
|
||||||
th = 3,
|
|
||||||
dd = 4,
|
|
||||||
kk = 5,
|
|
||||||
ch = 6,
|
|
||||||
ss = 7,
|
|
||||||
nn = 8,
|
|
||||||
rr = 9,
|
|
||||||
aa = 10,
|
|
||||||
e = 11,
|
|
||||||
ih = 12,
|
|
||||||
oh = 13,
|
|
||||||
ou = 14
|
|
||||||
// ReSharper restore InconsistentNaming
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AacVrcAssetLibrary
|
public class AacFlNoAnimator
|
||||||
{
|
{
|
||||||
public AvatarMask LeftHandAvatarMask()
|
public AacFlFloatParameter FloatParameter(string parameterName) => AacFlFloatParameter.Internally(parameterName);
|
||||||
{
|
public AacFlIntParameter IntParameter(string parameterName) => AacFlIntParameter.Internally(parameterName);
|
||||||
return AssetDatabase.LoadAssetAtPath<AvatarMask>("Packages/com.vrchat.avatars/Samples/AV3 Demo Assets/Animation/Masks/vrc_Hand Left.mask");
|
public AacFlBoolParameter BoolParameter(string parameterName) => AacFlBoolParameter.Internally(parameterName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AvatarMask RightHandAvatarMask()
|
public class AacFlBlendTree
|
||||||
{
|
{
|
||||||
return AssetDatabase.LoadAssetAtPath<AvatarMask>("Packages/com.vrchat.avatars/Samples/AV3 Demo Assets/Animation/Masks/vrc_Hand Right.mask");
|
protected AacFlBlendTree(BlendTree blendTree)
|
||||||
|
{
|
||||||
|
BlendTree = blendTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimationClip ProxyForGesture(AacAv3.Av3Gesture gesture, bool masculine)
|
public BlendTree BlendTree { get; }
|
||||||
{
|
|
||||||
return AssetDatabase.LoadAssetAtPath<AnimationClip>("Packages/com.vrchat.avatars/Samples/AV3 Demo Assets/Animation/ProxyAnim/" + ResolveProxyFilename(gesture, masculine));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ResolveProxyFilename(AacAv3.Av3Gesture gesture, bool masculine)
|
public class AacFlNonInitializedBlendTree : AacFlBlendTree
|
||||||
{
|
{
|
||||||
switch (gesture)
|
public AacFlNonInitializedBlendTree(BlendTree blendTree) : base(blendTree)
|
||||||
{
|
{
|
||||||
case AacAv3.Av3Gesture.Neutral: return masculine ? "proxy_hands_idle.anim" : "proxy_hands_idle2.anim";
|
}
|
||||||
case AacAv3.Av3Gesture.Fist: return "proxy_hands_fist.anim";
|
|
||||||
case AacAv3.Av3Gesture.HandOpen: return "proxy_hands_open.anim";
|
public AacFlBlendTree2D FreeformCartesian(AacFlFloatParameter parameterX, AacFlFloatParameter parameterY)
|
||||||
case AacAv3.Av3Gesture.Fingerpoint: return "proxy_hands_point.anim";
|
{
|
||||||
case AacAv3.Av3Gesture.Victory: return "proxy_hands_peace.anim";
|
BlendTree.blendType = BlendTreeType.FreeformCartesian2D;
|
||||||
case AacAv3.Av3Gesture.RockNRoll: return "proxy_hands_rock.anim";
|
BlendTree.blendParameter = parameterX.Name;
|
||||||
case AacAv3.Av3Gesture.HandGun: return "proxy_hands_gun.anim";
|
BlendTree.blendParameterY = parameterY.Name;
|
||||||
case AacAv3.Av3Gesture.ThumbsUp: return "proxy_hands_thumbs_up.anim";
|
|
||||||
default:
|
return new AacFlBlendTree2D(BlendTree);
|
||||||
throw new ArgumentOutOfRangeException(nameof(gesture), gesture, null);
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree2D FreeformDirectional(AacFlFloatParameter parameterX, AacFlFloatParameter parameterY)
|
||||||
|
{
|
||||||
|
BlendTree.blendType = BlendTreeType.FreeformDirectional2D;
|
||||||
|
BlendTree.blendParameter = parameterX.Name;
|
||||||
|
BlendTree.blendParameterY = parameterY.Name;
|
||||||
|
|
||||||
|
return new AacFlBlendTree2D(BlendTree);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree2D SimpleDirectional(AacFlFloatParameter parameterX, AacFlFloatParameter parameterY)
|
||||||
|
{
|
||||||
|
BlendTree.blendType = BlendTreeType.SimpleDirectional2D;
|
||||||
|
BlendTree.blendParameter = parameterX.Name;
|
||||||
|
BlendTree.blendParameterY = parameterY.Name;
|
||||||
|
|
||||||
|
return new AacFlBlendTree2D(BlendTree);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree1D Simple(AacFlFloatParameter parameter)
|
||||||
|
{
|
||||||
|
BlendTree.blendType = BlendTreeType.Simple1D;
|
||||||
|
BlendTree.blendParameter = parameter.Name;
|
||||||
|
BlendTree.useAutomaticThresholds = false;
|
||||||
|
|
||||||
|
return new AacFlBlendTree1D(BlendTree);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTreeDirect Direct()
|
||||||
|
{
|
||||||
|
BlendTree.blendType = BlendTreeType.Direct;
|
||||||
|
|
||||||
|
return new AacFlBlendTreeDirect(BlendTree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AacFlBlendTree2D : AacFlBlendTree
|
||||||
|
{
|
||||||
|
public AacFlBlendTree2D(BlendTree blendTree) : base(blendTree)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree2D WithAnimation(AacFlBlendTree blendTree, Vector2 pos)
|
||||||
|
{
|
||||||
|
return WithAnimation(blendTree.BlendTree, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree2D WithAnimation(AacFlBlendTree blendTree, float x, float y)
|
||||||
|
{
|
||||||
|
return WithAnimation(blendTree.BlendTree, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree2D WithAnimation(AacFlClip clip, Vector2 pos)
|
||||||
|
{
|
||||||
|
return WithAnimation(clip.Clip, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree2D WithAnimation(AacFlClip clip, float x, float y)
|
||||||
|
{
|
||||||
|
return WithAnimation(clip.Clip, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree2D WithAnimation(Motion motion, Vector2 pos)
|
||||||
|
{
|
||||||
|
return WithAnimation(motion, pos.x, pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree2D WithAnimation(Motion motion, float x, float y)
|
||||||
|
{
|
||||||
|
var children = BlendTree.children ?? new ChildMotion[0];
|
||||||
|
var childrenList = children.ToList();
|
||||||
|
childrenList.Add(new ChildMotion
|
||||||
|
{
|
||||||
|
motion = motion,
|
||||||
|
position = new Vector2(x, y),
|
||||||
|
timeScale = 1f
|
||||||
|
});
|
||||||
|
BlendTree.children = childrenList.ToArray();
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AacFlBlendTree1D : AacFlBlendTree
|
||||||
|
{
|
||||||
|
public AacFlBlendTree1D(BlendTree blendTree) : base(blendTree)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree1D WithAnimation(AacFlClip clip, float threshold)
|
||||||
|
{
|
||||||
|
return WithAnimation(clip.Clip, threshold);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree1D WithAnimation(AacFlBlendTree blendTree, float threshold)
|
||||||
|
{
|
||||||
|
return WithAnimation(blendTree.BlendTree, threshold);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTree1D WithAnimation(Motion motion, float threshold)
|
||||||
|
{
|
||||||
|
var children = BlendTree.children ?? new ChildMotion[0];
|
||||||
|
var childrenList = children.ToList();
|
||||||
|
childrenList.Add(new ChildMotion
|
||||||
|
{
|
||||||
|
motion = motion,
|
||||||
|
threshold = threshold,
|
||||||
|
timeScale = 1f
|
||||||
|
});
|
||||||
|
BlendTree.children = childrenList.ToArray();
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AacFlBlendTreeDirect : AacFlBlendTree
|
||||||
|
{
|
||||||
|
public AacFlBlendTreeDirect(BlendTree blendTree) : base(blendTree)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTreeDirect WithAnimation(AacFlClip clip, AacFlFloatParameter parameter)
|
||||||
|
{
|
||||||
|
return WithAnimation(clip.Clip, parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTreeDirect WithAnimation(AacFlBlendTree blendTree, AacFlFloatParameter parameter)
|
||||||
|
{
|
||||||
|
return WithAnimation(blendTree.BlendTree, parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlBlendTreeDirect WithAnimation(Motion motion, AacFlFloatParameter parameter)
|
||||||
|
{
|
||||||
|
var children = BlendTree.children ?? new ChildMotion[0];
|
||||||
|
var childrenList = children.ToList();
|
||||||
|
childrenList.Add(new ChildMotion
|
||||||
|
{
|
||||||
|
motion = motion,
|
||||||
|
directBlendParameter = parameter.Name,
|
||||||
|
timeScale = 1f
|
||||||
|
});
|
||||||
|
BlendTree.children = childrenList.ToArray();
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AacFlController
|
||||||
|
{
|
||||||
|
public AnimatorController AnimatorController;
|
||||||
|
|
||||||
|
private readonly AacConfiguration _configuration;
|
||||||
|
private readonly AacFlBase _base;
|
||||||
|
|
||||||
|
public AacFlController(AacConfiguration configuration, AnimatorController animatorController, AacFlBase originalBase)
|
||||||
|
{
|
||||||
|
AnimatorController = animatorController;
|
||||||
|
_configuration = configuration;
|
||||||
|
_base = originalBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AacFlLayer CreateLayer(string suffix) => _base.DoCreateLayerWithoutDeleting(AnimatorController, _configuration.DefaultsProvider.ConvertLayerNameWithSuffix(_configuration.SystemName, suffix));
|
||||||
|
public AacFlLayer CreateLayer() => _base.DoCreateLayerWithoutDeleting(AnimatorController, _configuration.SystemName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AacAnimatorRemoval
|
public class AacAnimatorRemoval
|
||||||
@@ -592,11 +727,15 @@ namespace AnimatorAsCode.V1
|
|||||||
.WithExitPosition(7, -1);
|
.WithExitPosition(7, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal AacFlStateMachine CreateOrClearLayerAtSameIndex(string layerName, float weightWhenCreating, AvatarMask maskWhenCreating = null)
|
internal AacFlStateMachine CreateOrClearLayerAtSameIndex(string layerName, float weightWhenCreating, AvatarMask maskWhenCreating = null, bool allowDeletion = true)
|
||||||
{
|
{
|
||||||
var originalIndexToPreserveOrdering = FindIndexOf(layerName);
|
var originalIndexToPreserveOrdering = FindIndexOf(layerName);
|
||||||
if (originalIndexToPreserveOrdering != -1)
|
if (originalIndexToPreserveOrdering != -1)
|
||||||
{
|
{
|
||||||
|
if (!allowDeletion)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"Cannot create layer with name {layerName} as it already exists. When creating layers using NewAnimatorController, you may only use unique names.");
|
||||||
|
}
|
||||||
RecursivelyClearChildrenMachines(_animatorController.layers[originalIndexToPreserveOrdering].stateMachine);
|
RecursivelyClearChildrenMachines(_animatorController.layers[originalIndexToPreserveOrdering].stateMachine);
|
||||||
|
|
||||||
_animatorController.layers[originalIndexToPreserveOrdering].stateMachine.stateMachines = new ChildAnimatorStateMachine[0];
|
_animatorController.layers[originalIndexToPreserveOrdering].stateMachine.stateMachines = new ChildAnimatorStateMachine[0];
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace AnimatorAsCode.V1
|
|||||||
internal static AacFlFloatParameterGroup Internally(params string[] names) => new AacFlFloatParameterGroup(names);
|
internal static AacFlFloatParameterGroup Internally(params string[] names) => new AacFlFloatParameterGroup(names);
|
||||||
private readonly string[] _names;
|
private readonly string[] _names;
|
||||||
private AacFlFloatParameterGroup(params string[] names) { _names = names; }
|
private AacFlFloatParameterGroup(params string[] names) { _names = names; }
|
||||||
public List<AacFlBoolParameter> ToList() => _names.Select(AacFlBoolParameter.Internally).ToList();
|
public List<AacFlFloatParameter> ToList() => _names.Select(AacFlFloatParameter.Internally).ToList();
|
||||||
|
|
||||||
public IAacFlCondition AreGreaterThan(float other) => ForEach(_names, (name, condition) => condition.Add(name, Greater, other));
|
public IAacFlCondition AreGreaterThan(float other) => ForEach(_names, (name, condition) => condition.Add(name, Greater, other));
|
||||||
public IAacFlCondition AreLessThan(float other) => ForEach(_names, (name, condition) => condition.Add(name, Less, other));
|
public IAacFlCondition AreLessThan(float other) => ForEach(_names, (name, condition) => condition.Add(name, Less, other));
|
||||||
@@ -135,7 +135,7 @@ namespace AnimatorAsCode.V1
|
|||||||
internal static AacFlIntParameterGroup Internally(params string[] names) => new AacFlIntParameterGroup(names);
|
internal static AacFlIntParameterGroup Internally(params string[] names) => new AacFlIntParameterGroup(names);
|
||||||
private readonly string[] _names;
|
private readonly string[] _names;
|
||||||
private AacFlIntParameterGroup(params string[] names) { _names = names; }
|
private AacFlIntParameterGroup(params string[] names) { _names = names; }
|
||||||
public List<AacFlBoolParameter> ToList() => _names.Select(AacFlBoolParameter.Internally).ToList();
|
public List<AacFlIntParameter> ToList() => _names.Select(AacFlIntParameter.Internally).ToList();
|
||||||
|
|
||||||
public IAacFlCondition AreGreaterThan(float other) => ForEach(_names, (name, condition) => condition.Add(name, Greater, other));
|
public IAacFlCondition AreGreaterThan(float other) => ForEach(_names, (name, condition) => condition.Add(name, Greater, other));
|
||||||
public IAacFlCondition AreLessThan(float other) => ForEach(_names, (name, condition) => condition.Add(name, Less, other));
|
public IAacFlCondition AreLessThan(float other) => ForEach(_names, (name, condition) => condition.Add(name, Less, other));
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using UnityEngine;
|
|||||||
// ReSharper disable once CheckNamespace
|
// ReSharper disable once CheckNamespace
|
||||||
namespace AnimatorAsCode.V1
|
namespace AnimatorAsCode.V1
|
||||||
{
|
{
|
||||||
internal class AacBackingAnimator
|
public class AacBackingAnimator
|
||||||
{
|
{
|
||||||
private readonly AacAnimatorGenerator _generator;
|
private readonly AacAnimatorGenerator _generator;
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ namespace AnimatorAsCode.V1
|
|||||||
_childNodes = new List<AacAnimatorNode>();
|
_childNodes = new List<AacAnimatorNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal AacBackingAnimator BackingAnimator()
|
public AacBackingAnimator InternalBackingAnimator()
|
||||||
{
|
{
|
||||||
return _backingAnimator;
|
return _backingAnimator;
|
||||||
}
|
}
|
||||||
@@ -332,6 +332,12 @@ namespace AnimatorAsCode.V1
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AacFlState WithAnimation(AacFlBlendTree blendTree)
|
||||||
|
{
|
||||||
|
State.motion = blendTree.BlendTree;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public AacFlTransition TransitionsTo(AacFlState destination)
|
public AacFlTransition TransitionsTo(AacFlState destination)
|
||||||
{
|
{
|
||||||
return new AacFlTransition(ConfigureTransition(State.AddTransition(destination.State)), _machine, State, destination.State);
|
return new AacFlTransition(ConfigureTransition(State.AddTransition(destination.State)), _machine, State, destination.State);
|
||||||
|
|||||||
+146
-15
@@ -1,12 +1,24 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
using VRC.SDK3.Avatars.Components;
|
using VRC.SDK3.Avatars.Components;
|
||||||
using VRC.SDKBase;
|
using VRC.SDKBase;
|
||||||
|
|
||||||
// ReSharper disable once CheckNamespace
|
// ReSharper disable once CheckNamespace
|
||||||
namespace AnimatorAsCode.V1.VRC
|
namespace AnimatorAsCode.V1.VRC
|
||||||
{
|
{
|
||||||
public static class VRChatExtensions
|
public static class AacVRCExtensions
|
||||||
{
|
{
|
||||||
|
public static AacVrcAssetLibrary VrcAssets(this AacFlBase that)
|
||||||
|
{
|
||||||
|
return new AacVrcAssetLibrary();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AacAv3 Av3(this AacFlLayer that)
|
||||||
|
{
|
||||||
|
return new AacAv3(that.InternalStateMachine().InternalBackingAnimator());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set <i>parameter</i> to a given <i>value</i>. For unsynced parameters, also see <i>DrivingLocally</i>.
|
/// Set <i>parameter</i> to a given <i>value</i>. For unsynced parameters, also see <i>DrivingLocally</i>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -196,7 +208,7 @@ namespace AnimatorAsCode.V1.VRC
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TNode TrackingTracks<TNode>(this TNode node, TrackingElement element) where TNode : AacAnimatorNode<TNode>
|
public static TNode TrackingTracks<TNode>(this TNode node, AacAv3.Av3TrackingElement element) where TNode : AacAnimatorNode<TNode>
|
||||||
{
|
{
|
||||||
var tracking = node.EnsureBehaviour<VRCAnimatorTrackingControl>();
|
var tracking = node.EnsureBehaviour<VRCAnimatorTrackingControl>();
|
||||||
SettingElementTo(tracking, element, VRC_AnimatorTrackingControl.TrackingType.Tracking);
|
SettingElementTo(tracking, element, VRC_AnimatorTrackingControl.TrackingType.Tracking);
|
||||||
@@ -204,7 +216,7 @@ namespace AnimatorAsCode.V1.VRC
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TNode TrackingAnimates<TNode>(this TNode node, TrackingElement element) where TNode : AacAnimatorNode<TNode>
|
public static TNode TrackingAnimates<TNode>(this TNode node, AacAv3.Av3TrackingElement element) where TNode : AacAnimatorNode<TNode>
|
||||||
{
|
{
|
||||||
var tracking = node.EnsureBehaviour<VRCAnimatorTrackingControl>();
|
var tracking = node.EnsureBehaviour<VRCAnimatorTrackingControl>();
|
||||||
SettingElementTo(tracking, element, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
SettingElementTo(tracking, element, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
@@ -212,7 +224,7 @@ namespace AnimatorAsCode.V1.VRC
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TNode TrackingSets<TNode>(this TNode node, TrackingElement element, VRC_AnimatorTrackingControl.TrackingType trackingType) where TNode : AacAnimatorNode<TNode>
|
public static TNode TrackingSets<TNode>(this TNode node, AacAv3.Av3TrackingElement element, VRC_AnimatorTrackingControl.TrackingType trackingType) where TNode : AacAnimatorNode<TNode>
|
||||||
{
|
{
|
||||||
var tracking = node.EnsureBehaviour<VRCAnimatorTrackingControl>();
|
var tracking = node.EnsureBehaviour<VRCAnimatorTrackingControl>();
|
||||||
SettingElementTo(tracking, element, trackingType);
|
SettingElementTo(tracking, element, trackingType);
|
||||||
@@ -220,38 +232,38 @@ namespace AnimatorAsCode.V1.VRC
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SettingElementTo(VRCAnimatorTrackingControl tracking, TrackingElement element, VRC_AnimatorTrackingControl.TrackingType target)
|
private static void SettingElementTo(VRCAnimatorTrackingControl tracking, AacAv3.Av3TrackingElement element, VRC_AnimatorTrackingControl.TrackingType target)
|
||||||
{
|
{
|
||||||
switch (element)
|
switch (element)
|
||||||
{
|
{
|
||||||
case TrackingElement.Head:
|
case AacAv3.Av3TrackingElement.Head:
|
||||||
tracking.trackingHead = target;
|
tracking.trackingHead = target;
|
||||||
break;
|
break;
|
||||||
case TrackingElement.LeftHand:
|
case AacAv3.Av3TrackingElement.LeftHand:
|
||||||
tracking.trackingLeftHand = target;
|
tracking.trackingLeftHand = target;
|
||||||
break;
|
break;
|
||||||
case TrackingElement.RightHand:
|
case AacAv3.Av3TrackingElement.RightHand:
|
||||||
tracking.trackingRightHand = target;
|
tracking.trackingRightHand = target;
|
||||||
break;
|
break;
|
||||||
case TrackingElement.Hip:
|
case AacAv3.Av3TrackingElement.Hip:
|
||||||
tracking.trackingHip = target;
|
tracking.trackingHip = target;
|
||||||
break;
|
break;
|
||||||
case TrackingElement.LeftFoot:
|
case AacAv3.Av3TrackingElement.LeftFoot:
|
||||||
tracking.trackingLeftFoot = target;
|
tracking.trackingLeftFoot = target;
|
||||||
break;
|
break;
|
||||||
case TrackingElement.RightFoot:
|
case AacAv3.Av3TrackingElement.RightFoot:
|
||||||
tracking.trackingRightFoot = target;
|
tracking.trackingRightFoot = target;
|
||||||
break;
|
break;
|
||||||
case TrackingElement.LeftFingers:
|
case AacAv3.Av3TrackingElement.LeftFingers:
|
||||||
tracking.trackingLeftFingers = target;
|
tracking.trackingLeftFingers = target;
|
||||||
break;
|
break;
|
||||||
case TrackingElement.RightFingers:
|
case AacAv3.Av3TrackingElement.RightFingers:
|
||||||
tracking.trackingRightFingers = target;
|
tracking.trackingRightFingers = target;
|
||||||
break;
|
break;
|
||||||
case TrackingElement.Eyes:
|
case AacAv3.Av3TrackingElement.Eyes:
|
||||||
tracking.trackingEyes = target;
|
tracking.trackingEyes = target;
|
||||||
break;
|
break;
|
||||||
case TrackingElement.Mouth:
|
case AacAv3.Av3TrackingElement.Mouth:
|
||||||
tracking.trackingMouth = target;
|
tracking.trackingMouth = target;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -335,4 +347,123 @@ namespace AnimatorAsCode.V1.VRC
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AacAv3
|
||||||
|
{
|
||||||
|
private readonly AacBackingAnimator _backingAnimator;
|
||||||
|
|
||||||
|
internal AacAv3(AacBackingAnimator backingAnimator)
|
||||||
|
{
|
||||||
|
_backingAnimator = backingAnimator;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
public AacFlBoolParameter IsLocal => _backingAnimator.BoolParameter("IsLocal");
|
||||||
|
public AacFlEnumIntParameter<Av3Viseme> Viseme => _backingAnimator.EnumParameter<Av3Viseme>("Viseme");
|
||||||
|
public AacFlEnumIntParameter<Av3Gesture> GestureLeft => _backingAnimator.EnumParameter<Av3Gesture>("GestureLeft");
|
||||||
|
public AacFlEnumIntParameter<Av3Gesture> GestureRight => _backingAnimator.EnumParameter<Av3Gesture>("GestureRight");
|
||||||
|
public AacFlFloatParameter GestureLeftWeight => _backingAnimator.FloatParameter("GestureLeftWeight");
|
||||||
|
public AacFlFloatParameter GestureRightWeight => _backingAnimator.FloatParameter("GestureRightWeight");
|
||||||
|
public AacFlFloatParameter AngularY => _backingAnimator.FloatParameter("AngularY");
|
||||||
|
public AacFlFloatParameter VelocityX => _backingAnimator.FloatParameter("VelocityX");
|
||||||
|
public AacFlFloatParameter VelocityY => _backingAnimator.FloatParameter("VelocityY");
|
||||||
|
public AacFlFloatParameter VelocityZ => _backingAnimator.FloatParameter("VelocityZ");
|
||||||
|
public AacFlFloatParameter Upright => _backingAnimator.FloatParameter("Upright");
|
||||||
|
public AacFlBoolParameter Grounded => _backingAnimator.BoolParameter("Grounded");
|
||||||
|
public AacFlBoolParameter Seated => _backingAnimator.BoolParameter("Seated");
|
||||||
|
public AacFlBoolParameter AFK => _backingAnimator.BoolParameter("AFK");
|
||||||
|
public AacFlIntParameter TrackingType => _backingAnimator.IntParameter("TrackingType");
|
||||||
|
public AacFlIntParameter VRMode => _backingAnimator.IntParameter("VRMode");
|
||||||
|
public AacFlBoolParameter MuteSelf => _backingAnimator.BoolParameter("MuteSelf");
|
||||||
|
public AacFlBoolParameter InStation => _backingAnimator.BoolParameter("InStation");
|
||||||
|
public AacFlFloatParameter Voice => _backingAnimator.FloatParameter("Voice");
|
||||||
|
// ReSharper restore InconsistentNaming
|
||||||
|
|
||||||
|
public IAacFlCondition ItIsRemote() => IsLocal.IsFalse();
|
||||||
|
public IAacFlCondition ItIsLocal() => IsLocal.IsTrue();
|
||||||
|
|
||||||
|
public enum Av3TrackingElement
|
||||||
|
{
|
||||||
|
Head,
|
||||||
|
LeftHand,
|
||||||
|
RightHand,
|
||||||
|
Hip,
|
||||||
|
LeftFoot,
|
||||||
|
RightFoot,
|
||||||
|
LeftFingers,
|
||||||
|
RightFingers,
|
||||||
|
Eyes,
|
||||||
|
Mouth
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Av3Gesture
|
||||||
|
{
|
||||||
|
// Specify all the values explicitly because they should be dictated by VRChat, not enumeration order.
|
||||||
|
Neutral = 0,
|
||||||
|
Fist = 1,
|
||||||
|
HandOpen = 2,
|
||||||
|
Fingerpoint = 3,
|
||||||
|
Victory = 4,
|
||||||
|
RockNRoll = 5,
|
||||||
|
HandGun = 6,
|
||||||
|
ThumbsUp = 7
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Av3Viseme
|
||||||
|
{
|
||||||
|
// Specify all the values explicitly because they should be dictated by VRChat, not enumeration order.
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
sil = 0,
|
||||||
|
pp = 1,
|
||||||
|
ff = 2,
|
||||||
|
th = 3,
|
||||||
|
dd = 4,
|
||||||
|
kk = 5,
|
||||||
|
ch = 6,
|
||||||
|
ss = 7,
|
||||||
|
nn = 8,
|
||||||
|
rr = 9,
|
||||||
|
aa = 10,
|
||||||
|
e = 11,
|
||||||
|
ih = 12,
|
||||||
|
oh = 13,
|
||||||
|
ou = 14
|
||||||
|
// ReSharper restore InconsistentNaming
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AacVrcAssetLibrary
|
||||||
|
{
|
||||||
|
public AvatarMask LeftHandAvatarMask()
|
||||||
|
{
|
||||||
|
return AssetDatabase.LoadAssetAtPath<AvatarMask>("Packages/com.vrchat.avatars/Samples/AV3 Demo Assets/Animation/Masks/vrc_Hand Left.mask");
|
||||||
|
}
|
||||||
|
|
||||||
|
public AvatarMask RightHandAvatarMask()
|
||||||
|
{
|
||||||
|
return AssetDatabase.LoadAssetAtPath<AvatarMask>("Packages/com.vrchat.avatars/Samples/AV3 Demo Assets/Animation/Masks/vrc_Hand Right.mask");
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnimationClip ProxyForGesture(AacAv3.Av3Gesture gesture, bool masculine)
|
||||||
|
{
|
||||||
|
return AssetDatabase.LoadAssetAtPath<AnimationClip>("Packages/com.vrchat.avatars/Samples/AV3 Demo Assets/Animation/ProxyAnim/" + ResolveProxyFilename(gesture, masculine));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ResolveProxyFilename(AacAv3.Av3Gesture gesture, bool masculine)
|
||||||
|
{
|
||||||
|
switch (gesture)
|
||||||
|
{
|
||||||
|
case AacAv3.Av3Gesture.Neutral: return masculine ? "proxy_hands_idle.anim" : "proxy_hands_idle2.anim";
|
||||||
|
case AacAv3.Av3Gesture.Fist: return "proxy_hands_fist.anim";
|
||||||
|
case AacAv3.Av3Gesture.HandOpen: return "proxy_hands_open.anim";
|
||||||
|
case AacAv3.Av3Gesture.Fingerpoint: return "proxy_hands_point.anim";
|
||||||
|
case AacAv3.Av3Gesture.Victory: return "proxy_hands_peace.anim";
|
||||||
|
case AacAv3.Av3Gesture.RockNRoll: return "proxy_hands_rock.anim";
|
||||||
|
case AacAv3.Av3Gesture.HandGun: return "proxy_hands_gun.anim";
|
||||||
|
case AacAv3.Av3Gesture.ThumbsUp: return "proxy_hands_thumbs_up.anim";
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(gesture), gesture, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
// ReSharper disable once CheckNamespace
|
|
||||||
namespace AnimatorAsCode.V1.VRC
|
|
||||||
{
|
|
||||||
public enum TrackingElement
|
|
||||||
{
|
|
||||||
Head,
|
|
||||||
LeftHand,
|
|
||||||
RightHand,
|
|
||||||
Hip,
|
|
||||||
LeftFoot,
|
|
||||||
RightFoot,
|
|
||||||
LeftFingers,
|
|
||||||
RightFingers,
|
|
||||||
Eyes,
|
|
||||||
Mouth
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 15a0b71b5f463174a894197698238912
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
Migrating from V0 to V1
|
||||||
|
======
|
||||||
|
|
||||||
|
AnimatorAsCode V1 introduces the following main breaking changes:
|
||||||
|
- VRChat Avatars is now an optional dependency. AnimatorAsCode can now be used in non-VRChat projects.
|
||||||
|
- All VRChat-related functions have been split between two classes of extension methods.
|
||||||
|
- You are now encouraged to use a non-destructive workflow by generating an animator controller asset without relying on an existing animator controller asset.
|
||||||
|
- VRChat methods that use a destructive workflow, such as `AacFlBase.CreateMainFxLayer()` are located on their own class of extension methods.
|
||||||
|
|
||||||
|
## Assembly definition
|
||||||
|
|
||||||
|
If you use assembly definitions, change the assembly reference from `AnimatorAsCodeFramework` to the following:
|
||||||
|
- `AnimatorAsCodeFramework.V1` in all cases.
|
||||||
|
- `AnimatorAsCodeFramework.V1.VRC` if you depend on VRChat.
|
||||||
|
- `AnimatorAsCodeFramework.V1.VRCDestructiveWorkflow` also if you need to edit the playable layers of the avatar directly.
|
||||||
|
- *Consider switching to a non-destructive workflow using VRCFury or Modular Avatar! See below.*
|
||||||
|
|
||||||
|
## Code changes
|
||||||
|
|
||||||
|
### Code
|
||||||
|
|
||||||
|
- Change `AacV0` to `AacV1`
|
||||||
|
- Change `using AnimatorAsCode.V0;` to `using AnimatorAsCode.V1;`
|
||||||
|
- If your project depends on VRChat, you will need to use extension methods.
|
||||||
|
- Add `using AnimatorAsCode.V1.VRC;` in your class imports to use the VRChat extension methods.
|
||||||
|
- The extension methods are contained within the class `AnimatorAsCode.V1.VRC.AacVRCExtensions`.
|
||||||
|
- Add `using AnimatorAsCode.V1.VRC;` in your class imports to use the extension methods.
|
||||||
|
- The extension methods are contained within the class `AnimatorAsCode.V1.VRCDestructiveWorkflow.AacVRCDestructiveWorkflowExtensions`
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
- TODO: Check TrackingElement being renamed to AacAv3.Av3TrackingElement
|
||||||
|
|
||||||
|
### AacConfiguration
|
||||||
|
|
||||||
|
Since `AacConfiguration` no longer contains the avatar descriptor, you will need to use the extension method `AacConfiguration.WithAvatarDescriptor(VRCAvatarDescriptor)` to define the avatar in the configuration.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
using AnimatorAsCode.V1;
|
||||||
|
using AnimatorAsCode.V1.VRCDestructiveWorkflow;
|
||||||
|
// ...
|
||||||
|
|
||||||
|
AacV1.Create(new AacConfiguration
|
||||||
|
{
|
||||||
|
SystemName = systemName,
|
||||||
|
AnimatorRoot = avatar.transform,
|
||||||
|
DefaultValueRoot = avatar.transform,
|
||||||
|
AssetContainer = assetContainer,
|
||||||
|
AssetKey = assetKey,
|
||||||
|
DefaultsProvider = new AacDefaultsProvider(writeDefaults: options.WriteDefaults)
|
||||||
|
}.WithAvatarDescriptor(avatar)); // The avatar descriptor is now defined by invoking an extension method.
|
||||||
|
```
|
||||||
|
|
||||||
|
# Non-destructive workflow
|
||||||
|
|
||||||
|
Animator As Code V1 encourages the use of a non-destructive workflow.
|
||||||
|
|
||||||
|
Here's a quick example:
|
||||||
|
|
||||||
|
|
||||||
|
Please open the file `Examples/GenExample4_NonDestructiveWorkflow.cs`.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7a4f3d8242e54ad1ac7571b9b0d92829
|
||||||
|
timeCreated: 1693748560
|
||||||
@@ -16,7 +16,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.Head;
|
var whichElement = AacAv3.Av3TrackingElement.Head;
|
||||||
first.TrackingTracks(whichElement);
|
first.TrackingTracks(whichElement);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -46,7 +46,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.Head;
|
var whichElement = AacAv3.Av3TrackingElement.Head;
|
||||||
first.TrackingAnimates(whichElement);
|
first.TrackingAnimates(whichElement);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -76,7 +76,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.Head;
|
var whichElement = AacAv3.Av3TrackingElement.Head;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Tracking);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Tracking);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -106,7 +106,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.Head;
|
var whichElement = AacAv3.Av3TrackingElement.Head;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -136,7 +136,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.LeftHand;
|
var whichElement = AacAv3.Av3TrackingElement.LeftHand;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -166,7 +166,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.RightHand;
|
var whichElement = AacAv3.Av3TrackingElement.RightHand;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -196,7 +196,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.Hip;
|
var whichElement = AacAv3.Av3TrackingElement.Hip;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -226,7 +226,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.LeftFoot;
|
var whichElement = AacAv3.Av3TrackingElement.LeftFoot;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -256,7 +256,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.RightFoot;
|
var whichElement = AacAv3.Av3TrackingElement.RightFoot;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -286,7 +286,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.LeftFingers;
|
var whichElement = AacAv3.Av3TrackingElement.LeftFingers;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -316,7 +316,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.RightFingers;
|
var whichElement = AacAv3.Av3TrackingElement.RightFingers;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -346,7 +346,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.Eyes;
|
var whichElement = AacAv3.Av3TrackingElement.Eyes;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -376,7 +376,7 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
var whichElement = TrackingElement.Mouth;
|
var whichElement = AacAv3.Av3TrackingElement.Mouth;
|
||||||
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(whichElement, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
@@ -406,9 +406,9 @@ namespace av3_animator_as_code.Tests.V1VRC.PlayMode.GenerationTests
|
|||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
var first = fx.NewState("First");
|
var first = fx.NewState("First");
|
||||||
first.TrackingSets(TrackingElement.Head, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(AacAv3.Av3TrackingElement.Head, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
first.TrackingSets(TrackingElement.LeftHand, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(AacAv3.Av3TrackingElement.LeftHand, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
first.TrackingSets(TrackingElement.RightHand, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
first.TrackingSets(AacAv3.Av3TrackingElement.RightHand, VRC_AnimatorTrackingControl.TrackingType.Animation);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
var eState = controller.layers[0].stateMachine.states[0].state;
|
var eState = controller.layers[0].stateMachine.states[0].state;
|
||||||
|
|||||||
Reference in New Issue
Block a user