2021-04-14 15:02:33 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
public class MainNav : MonoBehaviour
|
|
|
|
|
|
{
|
2021-04-19 18:16:56 +08:00
|
|
|
|
private GameObject exit;
|
|
|
|
|
|
private GameObject home;
|
2021-04-14 15:02:33 +08:00
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
|
|
|
|
|
|
|
|
|
|
|
var rect = ((RectTransform)this.transform).rect;
|
|
|
|
|
|
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
|
|
|
|
|
this.GetComponent<Image>().material = material;
|
|
|
|
|
|
|
2021-04-19 18:16:56 +08:00
|
|
|
|
var device = this.transform.Find("Device");
|
|
|
|
|
|
UIManager.AddEvent(device.gameObject, EventTriggerType.PointerClick, x =>
|
2021-04-14 15:02:33 +08:00
|
|
|
|
{
|
2021-04-19 18:16:56 +08:00
|
|
|
|
Debug.Log("click device");
|
2021-04-14 15:02:33 +08:00
|
|
|
|
UIManager.ShowDevicePanel();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2021-04-19 18:16:56 +08:00
|
|
|
|
home = this.transform.Find("Home").gameObject;
|
|
|
|
|
|
UIManager.AddEvent(home, EventTriggerType.PointerClick, x =>
|
2021-04-14 15:02:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowHomePanel();
|
|
|
|
|
|
});
|
2021-04-19 18:16:56 +08:00
|
|
|
|
|
|
|
|
|
|
exit = this.transform.Find("Exit").gameObject;
|
|
|
|
|
|
exit.SetActive(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIManager.AddEvent(exit, EventTriggerType.PointerClick, (e) =>
|
|
|
|
|
|
{
|
2021-04-21 11:25:52 +08:00
|
|
|
|
UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", ()=> {
|
|
|
|
|
|
Application.Quit();
|
|
|
|
|
|
});
|
2021-04-19 18:16:56 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
UIManager.AddEvent(transform.Find("Setting").gameObject, EventTriggerType.PointerClick, x =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowSettingModal();
|
|
|
|
|
|
});
|
2021-04-14 15:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-04-19 18:16:56 +08:00
|
|
|
|
|
|
|
|
|
|
public void ShowExit()
|
|
|
|
|
|
{
|
|
|
|
|
|
exit.SetActive(true);
|
|
|
|
|
|
home.SetActive(false);
|
|
|
|
|
|
}
|
2021-04-14 15:02:33 +08:00
|
|
|
|
}
|