Code cleanup, no functional changes.

This commit is contained in:
Haï~
2024-08-15 10:47:48 +02:00
parent 00e20cda51
commit 207ffffb65
@@ -19,7 +19,7 @@ namespace AnimatorAsCode.V1
internal static AnimatorController NewAnimatorController(AacConfiguration component, string suffix)
{
var animatorController = new AnimatorController();
animatorController.name = AutoGeneratedPrefix + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
animatorController.name = Internal_GenerateAnimationName(component, suffix); // FIXME animation name conflict
animatorController.hideFlags = HideFlags.None;
if (component.AsPersistentContainerRequired() != null) AssetDatabase.AddObjectToAsset(animatorController, component.AsPersistentContainerRequired());
return animatorController;
@@ -32,7 +32,7 @@ namespace AnimatorAsCode.V1
internal static AnimationClip RegisterClip(AacConfiguration component, string suffix, AnimationClip clip)
{
clip.name = AutoGeneratedPrefix + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
clip.name = Internal_GenerateAnimationName(component, suffix);
clip.hideFlags = HideFlags.None;
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer());
return clip;
@@ -41,7 +41,7 @@ namespace AnimatorAsCode.V1
internal static BlendTree NewBlendTreeAsRaw(AacConfiguration component, string suffix)
{
var clip = new BlendTree();
clip.name = AutoGeneratedPrefix + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
clip.name = Internal_GenerateAnimationName(component, suffix);
clip.hideFlags = HideFlags.None;
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer());
return clip;
@@ -50,12 +50,17 @@ namespace AnimatorAsCode.V1
internal static T DuplicateAssetIntoContainer<T>(AacConfiguration component, T assetToDuplicate) where T : Object
{
var duplicated = (T)Object.Instantiate(assetToDuplicate);
duplicated.name = AutoGeneratedPrefix + component.AssetKey + "__" + assetToDuplicate.name + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
duplicated.name = Internal_GenerateAnimationName(component, assetToDuplicate.name);
duplicated.hideFlags = HideFlags.None;
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(duplicated, component.AsRegularContainer());
return duplicated;
}
private static string Internal_GenerateAnimationName(AacConfiguration component, string middle)
{
return AutoGeneratedPrefix + component.AssetKey + "__" + middle + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
}
internal static AvatarMask NewAvatarMask(AacConfiguration component, string fullLayerName)
{
var avatarMask = new AvatarMask();
@@ -140,16 +145,18 @@ namespace AnimatorAsCode.V1
private static void UndoDisable<T>(T state)
{
typeof(T)
.GetProperty("pushUndo", BindingFlags.Instance | BindingFlags.NonPublic)
.SetValue(state, false);
GetPushUndoProperty<T>().SetValue(state, false);
}
private static void UndoEnable<T>(T state)
{
typeof(T)
.GetProperty("pushUndo", BindingFlags.Instance | BindingFlags.NonPublic)
.SetValue(state, true);
GetPushUndoProperty<T>().SetValue(state, true);
}
private static PropertyInfo GetPushUndoProperty<T>()
{
return typeof(T)
.GetProperty("pushUndo", BindingFlags.Instance | BindingFlags.NonPublic);
}
}
}