Use AacSimpleAssetContainerProvider
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@@ -46,6 +46,9 @@ namespace AnimatorAsCode.V1
|
|||||||
public string AssetKey;
|
public string AssetKey;
|
||||||
/// An object that will provide default values. When in doubt, use `new AacDefaultsProvider(...)`
|
/// An object that will provide default values. When in doubt, use `new AacDefaultsProvider(...)`
|
||||||
public IAacDefaultsProvider DefaultsProvider;
|
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
|
private Dictionary<Type, object> _additionalData; // Nullable
|
||||||
|
|
||||||
@@ -74,14 +77,13 @@ namespace AnimatorAsCode.V1
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Object AsPersistentContainerRequired()
|
internal IAacAssetContainerProvider ContainerProvider
|
||||||
{
|
{
|
||||||
return ContainerMode != Container.Never ? AssetContainer : null;
|
get
|
||||||
}
|
{
|
||||||
|
AssetContainerProvider ??= new AacSimpleAssetContainerProvider(this);
|
||||||
internal Object AsRegularContainer()
|
return AssetContainerProvider;
|
||||||
{
|
}
|
||||||
return ContainerMode == Container.Everything ? AssetContainer : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Values that define how created assets should be added to the AssetContainer.
|
/// 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.
|
/// Removes all assets from the asset container matching the specified asset key.
|
||||||
public void ClearPreviousAssets()
|
public void ClearPreviousAssets()
|
||||||
{
|
{
|
||||||
var allSubAssets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(_configuration.AsPersistentContainerRequired()));
|
_configuration.ContainerProvider.ClearPreviousAssets();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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.
|
/// 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.
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace AnimatorAsCode.V1
|
|||||||
var animatorController = new AnimatorController();
|
var animatorController = new AnimatorController();
|
||||||
animatorController.name = Internal_GenerateAnimationName(component, suffix); // FIXME animation name conflict
|
animatorController.name = Internal_GenerateAnimationName(component, suffix); // FIXME animation name conflict
|
||||||
animatorController.hideFlags = HideFlags.None;
|
animatorController.hideFlags = HideFlags.None;
|
||||||
if (component.AsPersistentContainerRequired() != null) AssetDatabase.AddObjectToAsset(animatorController, component.AsPersistentContainerRequired());
|
component.ContainerProvider.SaveAsPersistenceRequired(animatorController);
|
||||||
return animatorController;
|
return animatorController;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ namespace AnimatorAsCode.V1
|
|||||||
{
|
{
|
||||||
clip.name = Internal_GenerateAnimationName(component, suffix);
|
clip.name = Internal_GenerateAnimationName(component, suffix);
|
||||||
clip.hideFlags = HideFlags.None;
|
clip.hideFlags = HideFlags.None;
|
||||||
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer());
|
component.ContainerProvider.SaveAsRegular(clip);
|
||||||
return clip;
|
return clip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ namespace AnimatorAsCode.V1
|
|||||||
var clip = new BlendTree();
|
var clip = new BlendTree();
|
||||||
clip.name = Internal_GenerateAnimationName(component, suffix);
|
clip.name = Internal_GenerateAnimationName(component, suffix);
|
||||||
clip.hideFlags = HideFlags.None;
|
clip.hideFlags = HideFlags.None;
|
||||||
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer());
|
component.ContainerProvider.SaveAsRegular(clip);
|
||||||
return clip;
|
return clip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ namespace AnimatorAsCode.V1
|
|||||||
var duplicated = (T)Object.Instantiate(assetToDuplicate);
|
var duplicated = (T)Object.Instantiate(assetToDuplicate);
|
||||||
duplicated.name = Internal_GenerateAnimationName(component, assetToDuplicate.name);
|
duplicated.name = Internal_GenerateAnimationName(component, assetToDuplicate.name);
|
||||||
duplicated.hideFlags = HideFlags.None;
|
duplicated.hideFlags = HideFlags.None;
|
||||||
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(duplicated, component.AsRegularContainer());
|
component.ContainerProvider.SaveAsRegular(duplicated);
|
||||||
return duplicated;
|
return duplicated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ namespace AnimatorAsCode.V1
|
|||||||
var avatarMask = new AvatarMask();
|
var avatarMask = new AvatarMask();
|
||||||
avatarMask.name = AutoGeneratedPrefix + 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());
|
component.ContainerProvider.SaveAsRegular(avatarMask);
|
||||||
return avatarMask;
|
return avatarMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user