Use AacSimpleAssetContainerProvider
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
@@ -46,6 +46,9 @@ namespace AnimatorAsCode.V1
|
||||
public string AssetKey;
|
||||
/// An object that will provide default values. When in doubt, use `new AacDefaultsProvider(...)`
|
||||
public IAacDefaultsProvider DefaultsProvider;
|
||||
/// An object that will provide abstraction for asset container object.
|
||||
/// AssetContainer field value will be used if left null.
|
||||
public IAacAssetContainerProvider AssetContainerProvider;
|
||||
|
||||
private Dictionary<Type, object> _additionalData; // Nullable
|
||||
|
||||
@@ -74,14 +77,13 @@ namespace AnimatorAsCode.V1
|
||||
return false;
|
||||
}
|
||||
|
||||
internal Object AsPersistentContainerRequired()
|
||||
internal IAacAssetContainerProvider ContainerProvider
|
||||
{
|
||||
return ContainerMode != Container.Never ? AssetContainer : null;
|
||||
}
|
||||
|
||||
internal Object AsRegularContainer()
|
||||
{
|
||||
return ContainerMode == Container.Everything ? AssetContainer : null;
|
||||
get
|
||||
{
|
||||
AssetContainerProvider ??= new AacSimpleAssetContainerProvider(this);
|
||||
return AssetContainerProvider;
|
||||
}
|
||||
}
|
||||
|
||||
/// Values that define how created assets should be added to the AssetContainer.
|
||||
@@ -618,20 +620,7 @@ namespace AnimatorAsCode.V1
|
||||
/// Removes all assets from the asset container matching the specified asset key.
|
||||
public void ClearPreviousAssets()
|
||||
{
|
||||
var allSubAssets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(_configuration.AsPersistentContainerRequired()));
|
||||
foreach (var subAsset in allSubAssets)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
_configuration.ContainerProvider.ClearPreviousAssets();
|
||||
}
|
||||
|
||||
/// If you are not creating an animator, this returns an object from which you can obtain animator parameter objects. You should use this class if you are creating BlendTree assets without any animator controllers to back it. Otherwise, it is strongly recommended to obtain animator parameter objects directly from the layer objects instead of using NoAnimator(), as the use of NoAnimator() will not result in the registration of any parameters inside the animator controller.
|
||||
|
||||
Reference in New Issue
Block a user