_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Scene_main/main_game.cs
2024-11-27 16:14:34 +08:00

59 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class main_game :Base
{
[Header("canvas动态生成的父节点")]
public Canvas canvas;
[Header("按钮与显示面板一一对应")]
public Button BTN1;
public Button BTN2;
public Button BTN3;
public Button BTN4;
[Header("按钮与显示面板一一对应")]
public GameObject panel1;
public GameObject panel2;
public GameObject panel3;
public GameObject panel4;
public virtual void Start()
{
BTN1.onClick.AddListener(()=> {
asyncOnShopBTN(BTN1, panel1);
});
BTN2.onClick.AddListener(() => {
asyncOnShopBTN(BTN2, panel2);
});
BTN3.onClick.AddListener(() => {
asyncOnShopBTN(BTN3, panel3);
});
BTN4.onClick.AddListener(() => {
asyncOnShopBTN(BTN4, panel4);
});
}
public async void asyncOnShopBTN(Button BTN,GameObject _panel)
{
await ButtonClickAnimationAsync(BTN.gameObject);
BTN.transform.GetComponent<main_RedDot>().HideRedDot();
if (_panel == null)
{
addEventPopUp("未开放", 3f);
return;
}
// 实例化 Panel 并设置缩放为 0.5
/*GameObject newPanel =*/ GameObject.Instantiate(_panel, canvas.transform);
/* newPanel.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);*/
}
}