Co-authored-by: zzdxxz <2079238449@qq.com> Co-committed-by: zzdxxz <2079238449@qq.com>
63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using Prefab;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
namespace Managers
|
|
{
|
|
public class RightMenuManager:Utils.MonoSingleton<RightMenuManager>
|
|
{
|
|
[SerializeField]
|
|
private GameObject _canvas;
|
|
|
|
[SerializeField]
|
|
private RightMenuPrefab _rightMenuPrefab;
|
|
|
|
public GameObject Canvas
|
|
{
|
|
get
|
|
{
|
|
if (_canvas == null)
|
|
{
|
|
_canvas = GameObject.Find("Canvas"); // 根据你的实际场景修改查找条件
|
|
if (_canvas == null)
|
|
{
|
|
Debug.LogError("RightMenu Canvas not found in scene!");
|
|
}
|
|
}
|
|
return _canvas;
|
|
}
|
|
}
|
|
|
|
public RightMenuPrefab RightMenuPrefab
|
|
{
|
|
get
|
|
{
|
|
if (_rightMenuPrefab == null)
|
|
{
|
|
_rightMenuPrefab = Resources.Load<RightMenuPrefab>("Prefab/RightMenu");
|
|
if (_rightMenuPrefab == null)
|
|
{
|
|
Debug.LogError("RightMenuPrefab not found in Resources!");
|
|
}
|
|
}
|
|
return _rightMenuPrefab;
|
|
}
|
|
}
|
|
|
|
public static void GenerateRightMenu(List<(string name, UnityAction callback)> buttons,Vector3 position)
|
|
{
|
|
var rightMenuObj = Instantiate(RightMenuManager.Instance.RightMenuPrefab.gameObject,
|
|
RightMenuManager.Instance.Canvas.transform);
|
|
var rightMenu=rightMenuObj.GetComponent<RightMenuPrefab>();
|
|
rightMenu.Init(buttons);
|
|
rightMenu.transform.position = position;
|
|
rightMenu.Show();
|
|
}
|
|
|
|
protected override void OnStart()
|
|
{
|
|
|
|
}
|
|
}
|
|
} |