54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
|
using DG.Tweening;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UIElements;
|
|||
|
|
|||
|
public class Manager : MonoBehaviour
|
|||
|
{
|
|||
|
public static Manager instance;
|
|||
|
public Canvas _Canvas;
|
|||
|
public List<GameObject> panelsPrefab = new List<GameObject>();
|
|||
|
|
|||
|
// ʹ<><CAB9>Dictionary<72><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>壬<EFBFBD><E5A3AC>ΪԤ<CEAA><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪʵ<CEAA><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
private Dictionary<int, GameObject> panels = new Dictionary<int, GameObject>();
|
|||
|
|
|||
|
void Awake()
|
|||
|
{
|
|||
|
instance = this;
|
|||
|
}
|
|||
|
|
|||
|
public GameObject ShowPanel(int index)
|
|||
|
{
|
|||
|
if (index < 0 || index >= panelsPrefab.Count)
|
|||
|
{
|
|||
|
Debug.LogError("ShowPanel: Index <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ");
|
|||
|
return null;
|
|||
|
}
|
|||
|
if (panels.ContainsKey(index))
|
|||
|
{
|
|||
|
ShowPanel(panels[index]);
|
|||
|
return panels[index];
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ShowPanel(panels[index]);
|
|||
|
return GameObject.Instantiate(panelsPrefab[index], _Canvas.transform);
|
|||
|
}
|
|||
|
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public virtual void ShowPanel(GameObject _panel)
|
|||
|
{
|
|||
|
_panel.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
|
|||
|
_panel.transform.DOScale(1f, 0.5f);
|
|||
|
}
|
|||
|
|
|||
|
public virtual void hidePanel(GameObject _panel)
|
|||
|
{
|
|||
|
_panel.SetActive(false);
|
|||
|
}
|
|||
|
}
|