Split functions from Aac into AacInternals

This commit is contained in:
Haï~
2023-10-02 04:53:27 +02:00
parent 53da87438e
commit fd5c47e83c
5 changed files with 122 additions and 111 deletions
+10 -81
View File
@@ -4,7 +4,6 @@ using System.Linq;
using UnityEditor; using UnityEditor;
using UnityEditor.Animations; using UnityEditor.Animations;
using UnityEngine; using UnityEngine;
using Random = UnityEngine.Random;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace AnimatorAsCode.V1 namespace AnimatorAsCode.V1
@@ -16,76 +15,6 @@ 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());
}
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 public struct AacConfiguration
@@ -321,7 +250,7 @@ namespace AnimatorAsCode.V1
{ {
var transform = paths[index]; var transform = paths[index];
avatarMask.SetTransformActive(index, true); 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. /// Create a new clip. The asset is generated into the container.
public AacFlClip NewClip() public AacFlClip NewClip()
{ {
var clip = AacV1.NewClip(_configuration, Guid.NewGuid().ToString()); var clip = AacInternals.NewClip(_configuration, Guid.NewGuid().ToString());
return new AacFlClip(_configuration, clip); return new AacFlClip(_configuration, clip);
} }
@@ -377,33 +306,33 @@ namespace AnimatorAsCode.V1
public AacFlClip CopyClip(AnimationClip originalClip) public AacFlClip CopyClip(AnimationClip originalClip)
{ {
var newClip = UnityEngine.Object.Instantiate(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); return new AacFlClip(_configuration, clip);
} }
/// Create a new BlendTree asset. The asset is generated into the container. /// Create a new BlendTree asset. The asset is generated into the container.
public AacFlNonInitializedBlendTree NewBlendTree() 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. /// 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() 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. /// 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) public AacFlClip NewClip(string name)
{ {
var clip = AacV1.NewClip(_configuration, name); var clip = AacInternals.NewClip(_configuration, name);
return new AacFlClip(_configuration, clip); 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). /// 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) 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) return new AacFlClip(_configuration, dummyClip)
.Animating(clip => clip.Animates("_ignored", typeof(GameObject), "m_IsActive") .Animating(clip => clip.Animates("_ignored", typeof(GameObject), "m_IsActive")
@@ -421,7 +350,7 @@ namespace AnimatorAsCode.V1
var numberOf = 1f; var numberOf = 1f;
var unit = AacFlUnit.Frames; 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; var duration = unit == AacFlUnit.Frames ? numberOf / 60f : numberOf;
return new AacFlClip(_configuration, dummyClip) return new AacFlClip(_configuration, dummyClip)
@@ -432,14 +361,14 @@ namespace AnimatorAsCode.V1
/// Create a new animator controller. The asset is generated into the container. /// Create a new animator controller. The asset is generated into the container.
public AacFlController NewAnimatorController() 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); 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. /// 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) public AacFlController NewAnimatorController(string name)
{ {
var animatorController = AacV1.NewAnimatorController(_configuration, name); var animatorController = AacInternals.NewAnimatorController(_configuration, name);
return new AacFlController(_configuration, animatorController, this); return new AacFlController(_configuration, animatorController, this);
} }
+1
View File
@@ -16,6 +16,7 @@ namespace AnimatorAsCode.V1
protected readonly AacFlStateMachine ParentMachine; protected readonly AacFlStateMachine ParentMachine;
protected readonly IAacDefaultsProvider DefaultsProvider; protected readonly IAacDefaultsProvider DefaultsProvider;
// TODO: What is this for???
protected Dictionary<Type, object> behaviorCache = new Dictionary<Type, object>(); protected Dictionary<Type, object> behaviorCache = new Dictionary<Type, object>();
protected AacAnimatorNode(AacFlStateMachine parentMachine, IAacDefaultsProvider defaultsProvider) protected AacAnimatorNode(AacFlStateMachine parentMachine, IAacDefaultsProvider defaultsProvider)
+30 -30
View File
@@ -47,9 +47,9 @@ namespace AnimatorAsCode.V1
var defensiveObjects = gameObjectsWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array var defensiveObjects = gameObjectsWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array
foreach (var component in defensiveObjects) foreach (var component in defensiveObjects)
{ {
var binding = AacV1.Binding(_component, typeof(GameObject), component.transform, "m_IsActive"); var binding = AacInternals.Binding(_component, typeof(GameObject), component.transform, "m_IsActive");
AnimationUtility.SetEditorCurve(Clip, binding, AacV1.OneFrame(value ? 1f : 0f)); AnimationUtility.SetEditorCurve(Clip, binding, AacInternals.OneFrame(value ? 1f : 0f));
} }
return this; return this;
@@ -57,9 +57,9 @@ namespace AnimatorAsCode.V1
public AacFlClip BlendShape(SkinnedMeshRenderer renderer, string blendShapeName, float value) public AacFlClip BlendShape(SkinnedMeshRenderer renderer, string blendShapeName, float value)
{ {
var binding = AacV1.Binding(_component, typeof(SkinnedMeshRenderer), renderer.transform, $"blendShape.{blendShapeName}"); var binding = AacInternals.Binding(_component, typeof(SkinnedMeshRenderer), renderer.transform, $"blendShape.{blendShapeName}");
AnimationUtility.SetEditorCurve(Clip, binding, AacV1.OneFrame(value)); AnimationUtility.SetEditorCurve(Clip, binding, AacInternals.OneFrame(value));
return this; return this;
} }
@@ -69,9 +69,9 @@ namespace AnimatorAsCode.V1
var defensiveObjects = rendererWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array var defensiveObjects = rendererWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array
foreach (var component in defensiveObjects) foreach (var component in defensiveObjects)
{ {
var binding = AacV1.Binding(_component, typeof(SkinnedMeshRenderer), component.transform, $"blendShape.{blendShapeName}"); var binding = AacInternals.Binding(_component, typeof(SkinnedMeshRenderer), component.transform, $"blendShape.{blendShapeName}");
AnimationUtility.SetEditorCurve(Clip, binding, AacV1.OneFrame(value)); AnimationUtility.SetEditorCurve(Clip, binding, AacInternals.OneFrame(value));
} }
return this; return this;
@@ -82,9 +82,9 @@ namespace AnimatorAsCode.V1
var defensiveObjects = gameObjectsWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array var defensiveObjects = gameObjectsWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array
foreach (var component in defensiveObjects) foreach (var component in defensiveObjects)
{ {
AnimationUtility.SetEditorCurve(Clip, AacV1.Binding(_component, typeof(Transform), component.transform, "m_LocalScale.x"), AacV1.OneFrame(scale.x)); AnimationUtility.SetEditorCurve(Clip, AacInternals.Binding(_component, typeof(Transform), component.transform, "m_LocalScale.x"), AacInternals.OneFrame(scale.x));
AnimationUtility.SetEditorCurve(Clip, AacV1.Binding(_component, typeof(Transform), component.transform, "m_LocalScale.y"), AacV1.OneFrame(scale.y)); AnimationUtility.SetEditorCurve(Clip, AacInternals.Binding(_component, typeof(Transform), component.transform, "m_LocalScale.y"), AacInternals.OneFrame(scale.y));
AnimationUtility.SetEditorCurve(Clip, AacV1.Binding(_component, typeof(Transform), component.transform, "m_LocalScale.z"), AacV1.OneFrame(scale.z)); AnimationUtility.SetEditorCurve(Clip, AacInternals.Binding(_component, typeof(Transform), component.transform, "m_LocalScale.z"), AacInternals.OneFrame(scale.z));
} }
return this; return this;
@@ -92,9 +92,9 @@ namespace AnimatorAsCode.V1
public AacFlClip Toggling(GameObject gameObject, bool value) public AacFlClip Toggling(GameObject gameObject, bool value)
{ {
var binding = AacV1.Binding(_component, typeof(GameObject), gameObject.transform, "m_IsActive"); var binding = AacInternals.Binding(_component, typeof(GameObject), gameObject.transform, "m_IsActive");
AnimationUtility.SetEditorCurve(Clip, binding, AacV1.OneFrame(value ? 1f : 0f)); AnimationUtility.SetEditorCurve(Clip, binding, AacInternals.OneFrame(value ? 1f : 0f));
return this; return this;
} }
@@ -104,9 +104,9 @@ namespace AnimatorAsCode.V1
var defensiveComponents = componentsWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array var defensiveComponents = componentsWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array
foreach (var component in defensiveComponents) foreach (var component in defensiveComponents)
{ {
var binding = AacV1.Binding(_component, component.GetType(), component.transform, "m_Enabled"); var binding = AacInternals.Binding(_component, component.GetType(), component.transform, "m_Enabled");
AnimationUtility.SetEditorCurve(Clip, binding, AacV1.OneFrame(value ? 1f : 0f)); AnimationUtility.SetEditorCurve(Clip, binding, AacInternals.OneFrame(value ? 1f : 0f));
} }
return this; return this;
@@ -114,16 +114,16 @@ namespace AnimatorAsCode.V1
public AacFlClip TogglingComponent(Component component, bool value) public AacFlClip TogglingComponent(Component component, bool value)
{ {
var binding = AacV1.Binding(_component, component.GetType(), component.transform, "m_Enabled"); var binding = AacInternals.Binding(_component, component.GetType(), component.transform, "m_Enabled");
AnimationUtility.SetEditorCurve(Clip, binding, AacV1.OneFrame(value ? 1f : 0f)); AnimationUtility.SetEditorCurve(Clip, binding, AacInternals.OneFrame(value ? 1f : 0f));
return this; return this;
} }
public AacFlClip SwappingMaterial(Renderer renderer, int slot, Material material) public AacFlClip SwappingMaterial(Renderer renderer, int slot, Material material)
{ {
var binding = AacV1.Binding(_component, renderer.GetType(), renderer.transform, $"m_Materials.Array.data[{slot}]"); var binding = AacInternals.Binding(_component, renderer.GetType(), renderer.transform, $"m_Materials.Array.data[{slot}]");
AnimationUtility.SetObjectReferenceCurve(Clip, binding, new[] { AnimationUtility.SetObjectReferenceCurve(Clip, binding, new[] {
new ObjectReferenceKeyframe { time = 0f, value = material }, new ObjectReferenceKeyframe { time = 0f, value = material },
@@ -135,7 +135,7 @@ namespace AnimatorAsCode.V1
public AacFlClip SwappingMaterial(ParticleSystem particleSystem, int slot, Material material) public AacFlClip SwappingMaterial(ParticleSystem particleSystem, int slot, Material material)
{ {
var binding = AacV1.Binding(_component, typeof(ParticleSystemRenderer), particleSystem.transform, $"m_Materials.Array.data[{slot}]"); var binding = AacInternals.Binding(_component, typeof(ParticleSystemRenderer), particleSystem.transform, $"m_Materials.Array.data[{slot}]");
AnimationUtility.SetObjectReferenceCurve(Clip, binding, new[] { AnimationUtility.SetObjectReferenceCurve(Clip, binding, new[] {
new ObjectReferenceKeyframe { time = 0f, value = material }, new ObjectReferenceKeyframe { time = 0f, value = material },
@@ -170,14 +170,14 @@ namespace AnimatorAsCode.V1
public AacFlSettingCurve Animates(Transform transform, Type type, string propertyName) public AacFlSettingCurve Animates(Transform transform, Type type, string propertyName)
{ {
var binding = AacV1.Binding(_component, type, transform, propertyName); var binding = AacInternals.Binding(_component, type, transform, propertyName);
return new AacFlSettingCurve(Clip, new[] {binding}); return new AacFlSettingCurve(Clip, new[] {binding});
} }
public AacFlSettingCurve Animates(GameObject gameObject) public AacFlSettingCurve Animates(GameObject gameObject)
{ {
var binding = AacV1.Binding(_component, typeof(GameObject), gameObject.transform, "m_IsActive"); var binding = AacInternals.Binding(_component, typeof(GameObject), gameObject.transform, "m_IsActive");
return new AacFlSettingCurve(Clip, new[] {binding}); return new AacFlSettingCurve(Clip, new[] {binding});
} }
@@ -239,7 +239,7 @@ namespace AnimatorAsCode.V1
private EditorCurveBinding Internal_BindingFromComponent(Component anyComponent, string propertyName) private EditorCurveBinding Internal_BindingFromComponent(Component anyComponent, string propertyName)
{ {
return AacV1.Binding(_component, anyComponent.GetType(), anyComponent.transform, propertyName); return AacInternals.Binding(_component, anyComponent.GetType(), anyComponent.transform, propertyName);
} }
} }
@@ -258,7 +258,7 @@ namespace AnimatorAsCode.V1
{ {
foreach (var binding in _bindings) foreach (var binding in _bindings)
{ {
AnimationUtility.SetEditorCurve(_clip, binding, AacV1.OneFrame(desiredValue)); AnimationUtility.SetEditorCurve(_clip, binding, AacInternals.OneFrame(desiredValue));
} }
} }
@@ -266,7 +266,7 @@ namespace AnimatorAsCode.V1
{ {
foreach (var binding in _bindings) foreach (var binding in _bindings)
{ {
AnimationUtility.SetEditorCurve(_clip, binding, AacV1.ConstantSeconds(seconds, desiredValue)); AnimationUtility.SetEditorCurve(_clip, binding, AacInternals.ConstantSeconds(seconds, desiredValue));
} }
} }
@@ -323,10 +323,10 @@ namespace AnimatorAsCode.V1
{ {
foreach (var binding in _bindings) foreach (var binding in _bindings)
{ {
AnimationUtility.SetEditorCurve(_clip, AacV1.ToSubBinding(binding, _hdr ? "x" : "r"), AacV1.OneFrame(desiredValue.r)); AnimationUtility.SetEditorCurve(_clip, AacInternals.ToSubBinding(binding, _hdr ? "x" : "r"), AacInternals.OneFrame(desiredValue.r));
AnimationUtility.SetEditorCurve(_clip, AacV1.ToSubBinding(binding, _hdr ? "y" : "g"), AacV1.OneFrame(desiredValue.g)); AnimationUtility.SetEditorCurve(_clip, AacInternals.ToSubBinding(binding, _hdr ? "y" : "g"), AacInternals.OneFrame(desiredValue.g));
AnimationUtility.SetEditorCurve(_clip, AacV1.ToSubBinding(binding, _hdr ? "z" : "b"), AacV1.OneFrame(desiredValue.b)); AnimationUtility.SetEditorCurve(_clip, AacInternals.ToSubBinding(binding, _hdr ? "z" : "b"), AacInternals.OneFrame(desiredValue.b));
AnimationUtility.SetEditorCurve(_clip, AacV1.ToSubBinding(binding, _hdr ? "w" : "a"), AacV1.OneFrame(desiredValue.a)); AnimationUtility.SetEditorCurve(_clip, AacInternals.ToSubBinding(binding, _hdr ? "w" : "a"), AacInternals.OneFrame(desiredValue.a));
} }
} }
@@ -341,10 +341,10 @@ namespace AnimatorAsCode.V1
foreach (var binding in _bindings) foreach (var binding in _bindings)
{ {
AnimationUtility.SetEditorCurve(_clip, AacV1.ToSubBinding(binding, _hdr ? "x" : "r"), new AnimationCurve(mutatedKeyframesR.ToArray())); AnimationUtility.SetEditorCurve(_clip, AacInternals.ToSubBinding(binding, _hdr ? "x" : "r"), new AnimationCurve(mutatedKeyframesR.ToArray()));
AnimationUtility.SetEditorCurve(_clip, AacV1.ToSubBinding(binding, _hdr ? "y" : "g"), new AnimationCurve(mutatedKeyframesG.ToArray())); AnimationUtility.SetEditorCurve(_clip, AacInternals.ToSubBinding(binding, _hdr ? "y" : "g"), new AnimationCurve(mutatedKeyframesG.ToArray()));
AnimationUtility.SetEditorCurve(_clip, AacV1.ToSubBinding(binding, _hdr ? "z" : "b"), new AnimationCurve(mutatedKeyframesB.ToArray())); AnimationUtility.SetEditorCurve(_clip, AacInternals.ToSubBinding(binding, _hdr ? "z" : "b"), new AnimationCurve(mutatedKeyframesB.ToArray()));
AnimationUtility.SetEditorCurve(_clip, AacV1.ToSubBinding(binding, _hdr ? "w" : "a"), new AnimationCurve(mutatedKeyframesA.ToArray())); AnimationUtility.SetEditorCurve(_clip, AacInternals.ToSubBinding(binding, _hdr ? "w" : "a"), new AnimationCurve(mutatedKeyframesA.ToArray()));
} }
} }
} }
+78
View File
@@ -0,0 +1,78 @@
using System;
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
using Random = UnityEngine.Random;
// ReSharper disable once CheckNamespace
namespace AnimatorAsCode.V1
{
internal static class AacInternals
{
internal static AnimatorController NewAnimatorController(AacConfiguration component, string suffix)
{
var animatorController = new 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};
}
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fffa37ca11924062a8cf4a76d0f607ba
timeCreated: 1694285975