diff --git a/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/Aac.cs b/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/Aac.cs index 4ba4b57..b2394ef 100644 --- a/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/Aac.cs +++ b/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/Aac.cs @@ -553,7 +553,12 @@ namespace AnimatorAsCode.V1 var allSubAssets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(_configuration.AsPersistentContainerRequired())); foreach (var subAsset in allSubAssets) { - if (subAsset.name.StartsWith($"zAutogenerated__{_configuration.AssetKey}__") + if ( + ( + subAsset.name.StartsWith($"{AacInternals.AutoGeneratedPrefix}{_configuration.AssetKey}__") + || subAsset.name.StartsWith($"{AacInternals.AutoGeneratedLegacyPrefix}{_configuration.AssetKey}__") + ) + && (subAsset is AnimationClip || subAsset is BlendTree || subAsset is AvatarMask)) { AssetDatabase.RemoveObjectFromAsset(subAsset); diff --git a/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/AacInternals.cs b/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/AacInternals.cs index c4be818..535f488 100644 --- a/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/AacInternals.cs +++ b/Packages/dev.hai-vr.animator-as-code.v1/V1/Editor/AacInternals.cs @@ -11,10 +11,13 @@ namespace AnimatorAsCode.V1 { internal static class AacInternals { + internal const string AutoGeneratedPrefix = "zAutogenerated/"; + internal const string AutoGeneratedLegacyPrefix = "zAutogenerated__"; + 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.name = AutoGeneratedPrefix + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict animatorController.hideFlags = HideFlags.None; if (component.AsPersistentContainerRequired() != null) AssetDatabase.AddObjectToAsset(animatorController, component.AsPersistentContainerRequired()); return animatorController; @@ -27,7 +30,7 @@ namespace AnimatorAsCode.V1 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.name = AutoGeneratedPrefix + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict clip.hideFlags = HideFlags.None; if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer()); return clip; @@ -36,7 +39,7 @@ namespace AnimatorAsCode.V1 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.name = AutoGeneratedPrefix + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict clip.hideFlags = HideFlags.None; if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer()); return clip; @@ -45,7 +48,7 @@ namespace AnimatorAsCode.V1 internal static T DuplicateAssetIntoContainer(AacConfiguration component, T assetToDuplicate) where T : Object { var duplicated = (T)Object.Instantiate(assetToDuplicate); - duplicated.name = "zAutogenerated__" + component.AssetKey + "__" + assetToDuplicate.name + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict + duplicated.name = AutoGeneratedPrefix + component.AssetKey + "__" + assetToDuplicate.name + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict duplicated.hideFlags = HideFlags.None; if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(duplicated, component.AsRegularContainer()); return duplicated; @@ -54,7 +57,7 @@ namespace AnimatorAsCode.V1 internal static AvatarMask NewAvatarMask(AacConfiguration component, string fullLayerName) { var avatarMask = new AvatarMask(); - avatarMask.name = "zAutogenerated__" + component.AssetKey + "_" + fullLayerName + "__AvatarMask"; + avatarMask.name = AutoGeneratedPrefix + component.AssetKey + "_" + fullLayerName + "__AvatarMask"; avatarMask.hideFlags = HideFlags.None; if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(avatarMask, component.AsRegularContainer()); return avatarMask;