(client)feat:dev菜单可用生成实体

This commit is contained in:
m0_75251201
2025-07-22 17:30:11 +08:00
parent a6dfbd7c68
commit 046ebe3cfe
4 changed files with 728 additions and 10 deletions

View File

@ -5,7 +5,7 @@ using UnityEngine;
namespace Managers
{
public class EntityManage:MonoBehaviour
public class EntityManage:Utils.MonoSingleton<EntityManage>
{
public Dictionary<string, List<EntityPrefab>> factionEntities = new();
@ -84,5 +84,10 @@ namespace Managers
Debug.LogError($"An error occurred while generating the entity: {ex.Message}");
}
}
protected override void OnStart()
{
factionEntities.Clear();
}
}
}

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Data;
using UnityEngine;
using UnityEngine.UI;
@ -47,6 +48,8 @@ namespace UI
{
var button=InstantiatePrefab(buttonTemplate, menuContent.transform);
button.Label = def.label;
var pawnDef = def;
button.AddListener(() => GenerateEntityCallback(pawnDef));
}
}
/// <summary>
@ -78,6 +81,10 @@ namespace UI
return instantiatedComponent;
}
void GenerateEntityCallback(PawnDef pawnDef)
{
Managers.EntityManage.Instance.GenerateEntity(pawnDef, new(0, 0));
}
}
}