Files
aibis-dream/Assets/Scripts/UI/DialogUI/Bubbles/BubbleFactory.cs
T
dingyuntian 0168b03234 1.4优化
1. 新建梦境专用场景
2. 增加单行对话框,梦境中全程使用该对话框
3. 增加已选择选项标记功能

TODO
1. 增加梦境选择框
2. 为选项增加已选择表现
2026-01-02 23:19:06 +08:00

46 lines
1.4 KiB
C#

using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using UnityEngine;
namespace AibisDream
{
public class BubbleFactory
{
private readonly SimpleObjectPool<Bubble> _pool;
private readonly GameObject _bubblePrefab;
private readonly Transform _bubbleRoot;
private readonly BubbleGroup _bubbleGroup;
public BubbleFactory(Transform bubbleRoot)
{
_bubbleRoot = bubbleRoot;
_bubblePrefab = ResourceKit.LoadAssetSync<GameObject>(ConstRef.BubblePrefab);
_pool = new SimpleObjectPool<Bubble>(InstantiateBubble);
}
public BubbleFactory(BubbleGroup bubbleGroup)
{
_bubbleGroup = bubbleGroup;
_bubbleRoot = bubbleGroup.transform;
_bubblePrefab = ResourceKit.LoadAssetSync<GameObject>(ConstRef.BubblePrefab);
_pool = new SimpleObjectPool<Bubble>(InstantiateBubble);
}
public Bubble Create(BubbleSlotData data)
{
var bubble = _pool.Allocate();
bubble.OnDisposed += o => _pool.Recycle(o);
bubble.LoadConfig(data);
bubble.Hide();
return bubble;
}
private Bubble InstantiateBubble()
{
return Object.Instantiate(_bubblePrefab, _bubbleRoot).GetComponent<Bubble>();
}
}
}