推动Config新增

This commit is contained in:
2025-12-16 17:54:51 +08:00
parent 39a051eacf
commit 60df9a93aa
21 changed files with 427 additions and 117 deletions

View File

@@ -1,8 +1,10 @@
using Convention;
using Demo.Game.Attr;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
namespace Demo.Game
@@ -11,15 +13,31 @@ namespace Demo.Game
{
public class PrefabRootObjectConfig : ScriptLoadableConfig
{
private readonly Dictionary<string, List<string>> LoadedGameObjectNames = new();
public Dictionary<string, string[]> LoadedGameObjectNames = new();
public override void Deserialize(BinaryReader reader)
{
int count = BinarySerializeUtility.ReadInt(reader);
for (; count > 0;count--)
{
var temp = BinarySerializeUtility.DeserializeStringArray(reader);
var key = temp[0];
var value = temp[1..];
LoadedGameObjectNames.Add(key, value);
}
base.Deserialize(reader);
}
public override void Serialize(BinaryWriter writer)
{
BinarySerializeUtility.WriteInt(writer, LoadedGameObjectNames.Count);
foreach (var (key,value) in LoadedGameObjectNames)
{
string[] temp = new string[value.Length + 1];
temp[0] = key;
Array.Copy(value, 0, temp, 1, value.Length);
BinarySerializeUtility.SerializeArray(writer, value.ToArray());
}
base.Serialize(writer);
}
}