推进同化RScript
This commit is contained in:
@@ -5,55 +5,40 @@ using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public class LookAtAnchor : Updatement<string>
|
||||
public class LookAtAnchor : Updatement<ScriptableObject>
|
||||
{
|
||||
public static LookAtAnchor Make()
|
||||
{
|
||||
return new GameObject().AddComponent<LookAtAnchor>();
|
||||
}
|
||||
|
||||
protected override string Lerp(string begin, string end, float t)
|
||||
protected override ScriptableObject Lerp(ScriptableObject begin, ScriptableObject end, float t)
|
||||
{
|
||||
return begin;
|
||||
}
|
||||
|
||||
[Content, SerializeField] private string Cache;
|
||||
[Content] public ScriptableObject LookAtObject;
|
||||
[Content] public bool IsEnableUpdateEveryTick = false;
|
||||
|
||||
protected override void UpdateData(string data)
|
||||
protected override void UpdateData(ScriptableObject data)
|
||||
{
|
||||
if (Cache != data)
|
||||
if (data != LookAtObject)
|
||||
{
|
||||
LookAtObject = FindWithPath(data, false);
|
||||
Cache = data;
|
||||
Foo();
|
||||
LookAtObject = data;
|
||||
transform.LookAt(LookAtObject.transform);
|
||||
}
|
||||
if (IsEnableUpdateEveryTick)
|
||||
{
|
||||
Foo();
|
||||
}
|
||||
|
||||
void Foo()
|
||||
else if (IsEnableUpdateEveryTick)
|
||||
{
|
||||
if (LookAtObject != null)
|
||||
transform.LookAt(LookAtObject.transform);
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
Cache = null;
|
||||
yield return base.UnloadScript();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在指定时刻切换面向的物体,并尝试一次更新
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="target">对象相对路径,不存在时将解除锁定</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Add(string time, string target)
|
||||
public void Add(float time, ScriptableObject target)
|
||||
{
|
||||
ManualAddEntry(time, target, default);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user