Add AacFlBase.DuplicateAsset
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.Animations;
|
using UnityEditor.Animations;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
// ReSharper disable once CheckNamespace
|
// ReSharper disable once CheckNamespace
|
||||||
namespace AnimatorAsCode.V1
|
namespace AnimatorAsCode.V1
|
||||||
@@ -339,6 +340,12 @@ namespace AnimatorAsCode.V1
|
|||||||
.WithUnit(unit, keyframes => keyframes.Constant(0, 0f).Constant(numberOf, 0f)));
|
.WithUnit(unit, keyframes => keyframes.Constant(0, 0f).Constant(numberOf, 0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Duplicate a new asset into the container and return it. For example, use this to create modified material variants. This asset will be removed the same way as other generated assets.
|
||||||
|
public T DuplicateAsset<T>(T assetToDuplicate) where T : Object
|
||||||
|
{
|
||||||
|
return AacInternals.DuplicateAssetIntoContainer(_configuration, assetToDuplicate);
|
||||||
|
}
|
||||||
|
|
||||||
// For backwards compatibility, generates an animation with 2 keyframes that are at a distance of 1 / 60 of 1 frame,
|
// For backwards compatibility, generates an animation with 2 keyframes that are at a distance of 1 / 60 of 1 frame,
|
||||||
// that is 1 / 3600 seconds.
|
// that is 1 / 3600 seconds.
|
||||||
// This was due to DummyClipLasting returning a clip with unit conversion applied twice,
|
// This was due to DummyClipLasting returning a clip with unit conversion applied twice,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Reflection;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.Animations;
|
using UnityEditor.Animations;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
// ReSharper disable once CheckNamespace
|
// ReSharper disable once CheckNamespace
|
||||||
@@ -41,6 +42,15 @@ namespace AnimatorAsCode.V1
|
|||||||
return clip;
|
return clip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static T DuplicateAssetIntoContainer<T>(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.hideFlags = HideFlags.None;
|
||||||
|
AssetDatabase.AddObjectToAsset(duplicated, component.AssetContainer);
|
||||||
|
return duplicated;
|
||||||
|
}
|
||||||
|
|
||||||
internal static EditorCurveBinding Binding(AacConfiguration component, Type type, Transform transform, string propertyName)
|
internal static EditorCurveBinding Binding(AacConfiguration component, Type type, Transform transform, string propertyName)
|
||||||
{
|
{
|
||||||
return new EditorCurveBinding
|
return new EditorCurveBinding
|
||||||
|
|||||||
Reference in New Issue
Block a user