(client) feat:添加设置类,子弹添加敌我识别; chore:修改了右键菜单的初始化方式为独立创建,加载定义报错提供更多信息,动画加载出错也返回默认序列。
This commit is contained in:
63
Client/Assets/Scripts/Managers/RightMenuManager.cs
Normal file
63
Client/Assets/Scripts/Managers/RightMenuManager.cs
Normal file
@ -0,0 +1,63 @@
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user