Change the zAutogenerated asset prefix to directory-like:

- Change the zAutogenerated__ prefix to zAutogenerated/
- This allows the zAutogenerated/ assets to display in a dedicated menu in the animation editor when the animator is selected.
- For legacy compatibility, the old prefix is still matched for the invocation of ClearPreviousAssets() in addition to the new.
This commit is contained in:
Haï~
2024-02-04 04:23:10 +01:00
parent 89f176a6d2
commit 689080e032
2 changed files with 14 additions and 6 deletions
@@ -553,7 +553,12 @@ namespace AnimatorAsCode.V1
var allSubAssets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(_configuration.AsPersistentContainerRequired())); var allSubAssets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(_configuration.AsPersistentContainerRequired()));
foreach (var subAsset in allSubAssets) 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)) && (subAsset is AnimationClip || subAsset is BlendTree || subAsset is AvatarMask))
{ {
AssetDatabase.RemoveObjectFromAsset(subAsset); AssetDatabase.RemoveObjectFromAsset(subAsset);
@@ -11,10 +11,13 @@ namespace AnimatorAsCode.V1
{ {
internal static class AacInternals internal static class AacInternals
{ {
internal const string AutoGeneratedPrefix = "zAutogenerated/";
internal const string AutoGeneratedLegacyPrefix = "zAutogenerated__";
internal static AnimatorController NewAnimatorController(AacConfiguration component, string suffix) internal static AnimatorController NewAnimatorController(AacConfiguration component, string suffix)
{ {
var animatorController = new AnimatorController(); 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; animatorController.hideFlags = HideFlags.None;
if (component.AsPersistentContainerRequired() != null) AssetDatabase.AddObjectToAsset(animatorController, component.AsPersistentContainerRequired()); if (component.AsPersistentContainerRequired() != null) AssetDatabase.AddObjectToAsset(animatorController, component.AsPersistentContainerRequired());
return animatorController; return animatorController;
@@ -27,7 +30,7 @@ namespace AnimatorAsCode.V1
internal static AnimationClip RegisterClip(AacConfiguration component, string suffix, AnimationClip clip) 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; clip.hideFlags = HideFlags.None;
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer()); if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer());
return clip; return clip;
@@ -36,7 +39,7 @@ namespace AnimatorAsCode.V1
internal static BlendTree NewBlendTreeAsRaw(AacConfiguration component, string suffix) internal static BlendTree NewBlendTreeAsRaw(AacConfiguration component, string suffix)
{ {
var clip = new BlendTree(); 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; clip.hideFlags = HideFlags.None;
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer()); if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer());
return clip; return clip;
@@ -45,7 +48,7 @@ namespace AnimatorAsCode.V1
internal static T DuplicateAssetIntoContainer<T>(AacConfiguration component, T assetToDuplicate) where T : Object internal static T DuplicateAssetIntoContainer<T>(AacConfiguration component, T assetToDuplicate) where T : Object
{ {
var duplicated = (T)Object.Instantiate(assetToDuplicate); 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; duplicated.hideFlags = HideFlags.None;
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(duplicated, component.AsRegularContainer()); if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(duplicated, component.AsRegularContainer());
return duplicated; return duplicated;
@@ -54,7 +57,7 @@ namespace AnimatorAsCode.V1
internal static AvatarMask NewAvatarMask(AacConfiguration component, string fullLayerName) internal static AvatarMask NewAvatarMask(AacConfiguration component, string fullLayerName)
{ {
var avatarMask = new AvatarMask(); var avatarMask = new AvatarMask();
avatarMask.name = "zAutogenerated__" + component.AssetKey + "_" + fullLayerName + "__AvatarMask"; avatarMask.name = AutoGeneratedPrefix + component.AssetKey + "_" + fullLayerName + "__AvatarMask";
avatarMask.hideFlags = HideFlags.None; avatarMask.hideFlags = HideFlags.None;
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(avatarMask, component.AsRegularContainer()); if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(avatarMask, component.AsRegularContainer());
return avatarMask; return avatarMask;