SubWorld与LookAtAnchor Config更新

This commit is contained in:
2025-12-19 17:33:20 +08:00
parent a155e37c0a
commit 6c66a5c515
2 changed files with 30 additions and 4 deletions

View File

@@ -46,6 +46,8 @@ namespace Demo.Game
protected override IEnumerator DoSomethingDuringApplyScript()
{
yield return base.DoSomethingDuringApplyScript();
if (string.IsNullOrEmpty(GetConfig<ConfigType.SubWorldConfig>().project))
yield break;
var ir = SceneManager.LoadSceneAsync(Editor.EditorController.SceneName, LoadSceneMode.Additive);
ir.completed += x =>
{

View File

@@ -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);
}