Changed AssetContainer type to Object, add ContainerMode
This commit is contained in:
@@ -25,8 +25,8 @@ namespace AnimatorAsCode.V1
|
||||
// public VRCAvatarDescriptor AvatarDescriptor;
|
||||
public Transform AnimatorRoot;
|
||||
public Transform DefaultValueRoot;
|
||||
public AnimatorController AssetContainer;
|
||||
public Object GenericAssetContainer;
|
||||
public Object AssetContainer;
|
||||
public Container ContainerMode;
|
||||
public string AssetKey;
|
||||
public IAacDefaultsProvider DefaultsProvider;
|
||||
|
||||
@@ -52,18 +52,21 @@ namespace AnimatorAsCode.V1
|
||||
return false;
|
||||
}
|
||||
|
||||
internal Object GetPersistentAssetContainer()
|
||||
internal Object AsPersistentContainerRequired()
|
||||
{
|
||||
var container = AssetContainer != null ? AssetContainer : GenericAssetContainer;
|
||||
if (container != null && EditorUtility.IsPersistent(container)) return container;
|
||||
return null;
|
||||
return ContainerMode != Container.Never ? AssetContainer : null;
|
||||
}
|
||||
|
||||
internal Object GetAssetContainer()
|
||||
internal Object AsRegularContainer()
|
||||
{
|
||||
var container = AssetContainer != null ? AssetContainer : GenericAssetContainer;
|
||||
if (container != null) return container;
|
||||
return null;
|
||||
return ContainerMode == Container.Everything ? AssetContainer : null;
|
||||
}
|
||||
|
||||
public enum Container
|
||||
{
|
||||
Everything,
|
||||
OnlyWhenPersistenceRequired,
|
||||
Never
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,7 +432,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.GetPersistentAssetContainer()));
|
||||
var allSubAssets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(_configuration.AsPersistentContainerRequired()));
|
||||
foreach (var subAsset in allSubAssets)
|
||||
{
|
||||
if (subAsset.name.StartsWith($"zAutogenerated__{_configuration.AssetKey}__")
|
||||
|
||||
@@ -56,6 +56,15 @@ namespace AnimatorAsCode.V1
|
||||
return this;
|
||||
}
|
||||
|
||||
public AacFlClip Toggling(GameObject gameObject, bool value)
|
||||
{
|
||||
var binding = AacInternals.Binding(_component, typeof(GameObject), gameObject.transform, "m_IsActive");
|
||||
|
||||
AacInternals.SetCurve(Clip, binding, AacInternals.OneFrame(value ? 1f : 0f));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AacFlClip BlendShape(SkinnedMeshRenderer renderer, string blendShapeName, float value)
|
||||
{
|
||||
var binding = AacInternals.Binding(_component, typeof(SkinnedMeshRenderer), renderer.transform, $"blendShape.{blendShapeName}");
|
||||
@@ -157,15 +166,6 @@ namespace AnimatorAsCode.V1
|
||||
return this;
|
||||
}
|
||||
|
||||
public AacFlClip Toggling(GameObject gameObject, bool value)
|
||||
{
|
||||
var binding = AacInternals.Binding(_component, typeof(GameObject), gameObject.transform, "m_IsActive");
|
||||
|
||||
AacInternals.SetCurve(Clip, binding, AacInternals.OneFrame(value ? 1f : 0f));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AacFlClip TogglingComponent(Component[] componentsWithNulls, bool value)
|
||||
{
|
||||
var defensiveComponents = componentsWithNulls.Where(o => o != null); // Allow users to remove an item in the middle of the array
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace AnimatorAsCode.V1
|
||||
var animatorController = new AnimatorController();
|
||||
animatorController.name = "zAutogenerated__" + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
|
||||
animatorController.hideFlags = HideFlags.None;
|
||||
if (component.GetPersistentAssetContainer() != null) AssetDatabase.AddObjectToAsset(animatorController, component.GetPersistentAssetContainer());
|
||||
if (component.AsPersistentContainerRequired() != null) AssetDatabase.AddObjectToAsset(animatorController, component.AsPersistentContainerRequired());
|
||||
return animatorController;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace AnimatorAsCode.V1
|
||||
{
|
||||
clip.name = "zAutogenerated__" + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
|
||||
clip.hideFlags = HideFlags.None;
|
||||
if (component.GetAssetContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.GetAssetContainer());
|
||||
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer());
|
||||
return clip;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace AnimatorAsCode.V1
|
||||
var clip = new BlendTree();
|
||||
clip.name = "zAutogenerated__" + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
|
||||
clip.hideFlags = HideFlags.None;
|
||||
if (component.GetAssetContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.GetAssetContainer());
|
||||
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(clip, component.AsRegularContainer());
|
||||
return clip;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace AnimatorAsCode.V1
|
||||
var duplicated = (T)Object.Instantiate(assetToDuplicate);
|
||||
duplicated.name = "zAutogenerated__" + component.AssetKey + "__" + assetToDuplicate.name + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
|
||||
duplicated.hideFlags = HideFlags.None;
|
||||
if (component.GetAssetContainer() != null) AssetDatabase.AddObjectToAsset(duplicated, component.GetAssetContainer());
|
||||
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(duplicated, component.AsRegularContainer());
|
||||
return duplicated;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace AnimatorAsCode.V1
|
||||
var avatarMask = new AvatarMask();
|
||||
avatarMask.name = "zAutogenerated__" + component.AssetKey + "_" + fullLayerName + "__AvatarMask";
|
||||
avatarMask.hideFlags = HideFlags.None;
|
||||
if (component.GetAssetContainer() != null) AssetDatabase.AddObjectToAsset(avatarMask, component.GetAssetContainer());
|
||||
if (component.AsRegularContainer() != null) AssetDatabase.AddObjectToAsset(avatarMask, component.AsRegularContainer());
|
||||
return avatarMask;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user