Split functions from Aac into AacInternals
This commit is contained in:
+10
-81
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Animations;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace AnimatorAsCode.V1
|
||||
@@ -16,76 +15,6 @@ namespace AnimatorAsCode.V1
|
||||
{
|
||||
return new AacFlBase(configuration);
|
||||
}
|
||||
|
||||
internal static AnimatorController NewAnimatorController(AacConfiguration component, string suffix)
|
||||
{
|
||||
return RegisterAnimatorController(component, suffix, new AnimatorController());
|
||||
}
|
||||
|
||||
private 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)
|
||||
{
|
||||
return RegisterClip(component, suffix, new AnimationClip());
|
||||
}
|
||||
|
||||
internal static AnimationClip RegisterClip(AacConfiguration component, string suffix, AnimationClip clip)
|
||||
{
|
||||
clip.name = "zAutogenerated__" + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
|
||||
clip.hideFlags = HideFlags.None;
|
||||
AssetDatabase.AddObjectToAsset(clip, component.AssetContainer);
|
||||
return clip;
|
||||
}
|
||||
|
||||
internal static BlendTree NewBlendTreeAsRaw(AacConfiguration component, string suffix)
|
||||
{
|
||||
var clip = new BlendTree();
|
||||
clip.name = "zAutogenerated__" + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
|
||||
clip.hideFlags = HideFlags.None;
|
||||
AssetDatabase.AddObjectToAsset(clip, component.AssetContainer);
|
||||
return clip;
|
||||
}
|
||||
|
||||
internal static EditorCurveBinding Binding(AacConfiguration component, Type type, Transform transform, string propertyName)
|
||||
{
|
||||
return new EditorCurveBinding
|
||||
{
|
||||
path = ResolveRelativePath(component.AnimatorRoot, transform),
|
||||
type = type,
|
||||
propertyName = propertyName
|
||||
};
|
||||
}
|
||||
|
||||
internal static AnimationCurve OneFrame(float desiredValue)
|
||||
{
|
||||
return AnimationCurve.Constant(0f, 1 / 60f, desiredValue);
|
||||
}
|
||||
|
||||
internal static AnimationCurve ConstantSeconds(float seconds, float desiredValue)
|
||||
{
|
||||
return AnimationCurve.Constant(0f, seconds, desiredValue);
|
||||
}
|
||||
|
||||
internal static string ResolveRelativePath(Transform avatar, Transform item)
|
||||
{
|
||||
if (item.parent != avatar && item.parent != null)
|
||||
{
|
||||
return ResolveRelativePath(avatar, item.parent) + "/" + item.name;
|
||||
}
|
||||
|
||||
return item.name;
|
||||
}
|
||||
|
||||
internal static EditorCurveBinding ToSubBinding(EditorCurveBinding binding, string suffix)
|
||||
{
|
||||
return new EditorCurveBinding {path = binding.path, type = binding.type, propertyName = binding.propertyName + "." + suffix};
|
||||
}
|
||||
}
|
||||
|
||||
public struct AacConfiguration
|
||||
@@ -321,7 +250,7 @@ namespace AnimatorAsCode.V1
|
||||
{
|
||||
var transform = paths[index];
|
||||
avatarMask.SetTransformActive(index, true);
|
||||
avatarMask.SetTransformPath(index, AacV1.ResolveRelativePath(_configuration.AnimatorRoot, transform));
|
||||
avatarMask.SetTransformPath(index, AacInternals.ResolveRelativePath(_configuration.AnimatorRoot, transform));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +298,7 @@ namespace AnimatorAsCode.V1
|
||||
/// Create a new clip. The asset is generated into the container.
|
||||
public AacFlClip NewClip()
|
||||
{
|
||||
var clip = AacV1.NewClip(_configuration, Guid.NewGuid().ToString());
|
||||
var clip = AacInternals.NewClip(_configuration, Guid.NewGuid().ToString());
|
||||
return new AacFlClip(_configuration, clip);
|
||||
}
|
||||
|
||||
@@ -377,33 +306,33 @@ namespace AnimatorAsCode.V1
|
||||
public AacFlClip CopyClip(AnimationClip originalClip)
|
||||
{
|
||||
var newClip = UnityEngine.Object.Instantiate(originalClip);
|
||||
var clip = AacV1.RegisterClip(_configuration, Guid.NewGuid().ToString(), newClip);
|
||||
var clip = AacInternals.RegisterClip(_configuration, Guid.NewGuid().ToString(), newClip);
|
||||
return new AacFlClip(_configuration, clip);
|
||||
}
|
||||
|
||||
/// Create a new BlendTree asset. The asset is generated into the container.
|
||||
public AacFlNonInitializedBlendTree NewBlendTree()
|
||||
{
|
||||
return new AacFlNonInitializedBlendTree(AacV1.NewBlendTreeAsRaw(_configuration, Guid.NewGuid().ToString()));
|
||||
return new AacFlNonInitializedBlendTree(AacInternals.NewBlendTreeAsRaw(_configuration, Guid.NewGuid().ToString()));
|
||||
}
|
||||
|
||||
/// Create a new BlendTree asset and returns a native BlendTree object. The asset is generated into the container. You may use NewBlendTree() instead to obtain a fluent interface.
|
||||
public BlendTree NewBlendTreeAsRaw()
|
||||
{
|
||||
return AacV1.NewBlendTreeAsRaw(_configuration, Guid.NewGuid().ToString());
|
||||
return AacInternals.NewBlendTreeAsRaw(_configuration, Guid.NewGuid().ToString());
|
||||
}
|
||||
|
||||
/// Create a new clip with a name. However, the name is only used as a suffix for the asset. The asset is generated into the container.
|
||||
public AacFlClip NewClip(string name)
|
||||
{
|
||||
var clip = AacV1.NewClip(_configuration, name);
|
||||
var clip = AacInternals.NewClip(_configuration, name);
|
||||
return new AacFlClip(_configuration, clip);
|
||||
}
|
||||
|
||||
/// Create a new clip which animates a dummy transform for a specific duration specified in an unit (Frames or Seconds).
|
||||
public AacFlClip DummyClipLasting(float numberOf, AacFlUnit unit)
|
||||
{
|
||||
var dummyClip = AacV1.NewClip(_configuration, $"D({numberOf} {Enum.GetName(typeof(AacFlUnit), unit)})");
|
||||
var dummyClip = AacInternals.NewClip(_configuration, $"D({numberOf} {Enum.GetName(typeof(AacFlUnit), unit)})");
|
||||
|
||||
return new AacFlClip(_configuration, dummyClip)
|
||||
.Animating(clip => clip.Animates("_ignored", typeof(GameObject), "m_IsActive")
|
||||
@@ -421,7 +350,7 @@ namespace AnimatorAsCode.V1
|
||||
var numberOf = 1f;
|
||||
var unit = AacFlUnit.Frames;
|
||||
|
||||
var dummyClip = AacV1.NewClip(_configuration, $"D({numberOf} {Enum.GetName(typeof(AacFlUnit), unit)})");
|
||||
var dummyClip = AacInternals.NewClip(_configuration, $"D({numberOf} {Enum.GetName(typeof(AacFlUnit), unit)})");
|
||||
|
||||
var duration = unit == AacFlUnit.Frames ? numberOf / 60f : numberOf;
|
||||
return new AacFlClip(_configuration, dummyClip)
|
||||
@@ -432,14 +361,14 @@ namespace AnimatorAsCode.V1
|
||||
/// Create a new animator controller. The asset is generated into the container.
|
||||
public AacFlController NewAnimatorController()
|
||||
{
|
||||
var animatorController = AacV1.NewAnimatorController(_configuration, Guid.NewGuid().ToString());
|
||||
var animatorController = AacInternals.NewAnimatorController(_configuration, Guid.NewGuid().ToString());
|
||||
return new AacFlController(_configuration, animatorController, this);
|
||||
}
|
||||
|
||||
/// Create a new animator controller with a name. However, the name is only used as a suffix for the asset. The asset is generated into the container.
|
||||
public AacFlController NewAnimatorController(string name)
|
||||
{
|
||||
var animatorController = AacV1.NewAnimatorController(_configuration, name);
|
||||
var animatorController = AacInternals.NewAnimatorController(_configuration, name);
|
||||
return new AacFlController(_configuration, animatorController, this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user