27 lines
684 B
C#
27 lines
684 B
C#
using BrewMonster;
|
|
using NUnit.Framework;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public class NPCBuilder : MonoSingleton<NPCBuilder>
|
|
{
|
|
[SerializeField] List<GameObject> modelNPCList;
|
|
[SerializeField] Dictionary<string, GameObject> modleNPCDic;
|
|
|
|
private void Awake()
|
|
{
|
|
if (modelNPCList.Count == 0)
|
|
{
|
|
Debug.LogError("modelList empty");
|
|
}
|
|
|
|
modleNPCDic = modelNPCList.GroupBy(obj => obj.name)
|
|
.ToDictionary(g => g.Key, g => g.First());
|
|
}
|
|
public GameObject GetModelByName(string name)
|
|
{
|
|
return modleNPCDic.TryGetValue(name, out var model) ? model : null;
|
|
}
|
|
}
|