SubWorld与LookAtAnchor Config更新
This commit is contained in:
@@ -1,10 +1,30 @@
|
||||
using Convention;
|
||||
using Demo.Game.Attr;
|
||||
using Demo.Game.ConfigType;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
namespace ConfigType
|
||||
{
|
||||
public class LookAtAnchorConfig : UpdatementIntConfig
|
||||
{
|
||||
[Content] public bool IsEnableUpdateEveryTick = false;
|
||||
public override void Deserialize(BinaryReader reader)
|
||||
{
|
||||
IsEnableUpdateEveryTick = BinarySerializeUtility.ReadBool(reader);
|
||||
base.Deserialize(reader);
|
||||
}
|
||||
|
||||
public override void Serialize(BinaryWriter writer)
|
||||
{
|
||||
BinarySerializeUtility.WriteBool(writer, IsEnableUpdateEveryTick);
|
||||
base.Serialize(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Scriptable]
|
||||
public class LookAtAnchor : Updatement<int>
|
||||
{
|
||||
@@ -22,15 +42,19 @@ namespace Demo.Game
|
||||
return begin;
|
||||
}
|
||||
|
||||
[Content] public int LookAtObject;
|
||||
[Content] public bool IsEnableUpdateEveryTick = false;
|
||||
public int LookAtObjectCache;
|
||||
public bool IsEnableUpdateEveryTick
|
||||
{
|
||||
get => GetConfig<LookAtAnchorConfig>().IsEnableUpdateEveryTick;
|
||||
set => GetConfig<LookAtAnchorConfig>().IsEnableUpdateEveryTick = value;
|
||||
}
|
||||
|
||||
protected override void UpdateData(int data)
|
||||
{
|
||||
ScriptableObject target = GetRoot().FindWithIndex(data);
|
||||
if (data != LookAtObject)
|
||||
if (data != LookAtObjectCache)
|
||||
{
|
||||
LookAtObject = data;
|
||||
LookAtObjectCache = data;
|
||||
if (target != null)
|
||||
transform.LookAt(target.transform);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user