Add AacFlEditClip.AnimatesObjectReference
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
// ReSharper disable once CheckNamespace
|
// ReSharper disable once CheckNamespace
|
||||||
namespace AnimatorAsCode.V1
|
namespace AnimatorAsCode.V1
|
||||||
@@ -232,6 +233,12 @@ namespace AnimatorAsCode.V1
|
|||||||
return new AacFlSettingCurveColor(Clip, new[] {binding}, true);
|
return new AacFlSettingCurveColor(Clip, new[] {binding}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AacFlSettingCurveObjectReference AnimatesObjectReference(Component anyComponent, string property)
|
||||||
|
{
|
||||||
|
var binding = Internal_BindingFromComponent(anyComponent, property);
|
||||||
|
return new AacFlSettingCurveObjectReference(Clip, new[] {binding});
|
||||||
|
}
|
||||||
|
|
||||||
public EditorCurveBinding BindingFromComponent(Component anyComponent, string propertyName)
|
public EditorCurveBinding BindingFromComponent(Component anyComponent, string propertyName)
|
||||||
{
|
{
|
||||||
return Internal_BindingFromComponent(anyComponent, propertyName);
|
return Internal_BindingFromComponent(anyComponent, propertyName);
|
||||||
@@ -306,6 +313,30 @@ namespace AnimatorAsCode.V1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AacFlSettingCurveObjectReference
|
||||||
|
{
|
||||||
|
private readonly AnimationClip _clip;
|
||||||
|
private readonly EditorCurveBinding[] _bindings;
|
||||||
|
|
||||||
|
public AacFlSettingCurveObjectReference(AnimationClip clip, EditorCurveBinding[] bindings)
|
||||||
|
{
|
||||||
|
_clip = clip;
|
||||||
|
_bindings = bindings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WithOneFrame(Object objectReference)
|
||||||
|
{
|
||||||
|
foreach (var binding in _bindings)
|
||||||
|
{
|
||||||
|
AnimationUtility.SetObjectReferenceCurve(_clip, binding, new[]
|
||||||
|
{
|
||||||
|
new ObjectReferenceKeyframe { time = 0f, value = objectReference },
|
||||||
|
new ObjectReferenceKeyframe { time = 1/60f, value = objectReference }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class AacFlSettingCurveColor
|
public class AacFlSettingCurveColor
|
||||||
{
|
{
|
||||||
private readonly AnimationClip _clip;
|
private readonly AnimationClip _clip;
|
||||||
|
|||||||
@@ -73,6 +73,12 @@ namespace AnimatorAsCode.V1
|
|||||||
|
|
||||||
internal static string ResolveRelativePath(Transform avatar, Transform item)
|
internal static string ResolveRelativePath(Transform avatar, Transform item)
|
||||||
{
|
{
|
||||||
|
if (avatar == item)
|
||||||
|
{
|
||||||
|
// TODO: Is this correct??
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
if (item.parent != avatar && item.parent != null)
|
if (item.parent != avatar && item.parent != null)
|
||||||
{
|
{
|
||||||
return ResolveRelativePath(avatar, item.parent) + "/" + item.name;
|
return ResolveRelativePath(avatar, item.parent) + "/" + item.name;
|
||||||
|
|||||||
Reference in New Issue
Block a user