117 lines
3.4 KiB
C#
117 lines
3.4 KiB
C#
using Assets.Scripts.UI.Control;
|
|
using DG.Tweening;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class MainNav : MonoBehaviour
|
|
{
|
|
private GameObject exit;
|
|
private GameObject home;
|
|
float delayTime = 0;
|
|
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;
|
|
|
|
var device = this.transform.Find("Device");
|
|
UIManager.AddEvent(device.gameObject, EventTriggerType.PointerClick, x =>
|
|
{
|
|
//Debug.Log("click device");
|
|
UIManager.ShowDevicePanel();
|
|
});
|
|
|
|
home = this.transform.Find("Home").gameObject;
|
|
UIManager.AddEvent(home, EventTriggerType.PointerClick, x =>
|
|
{
|
|
UIManager.ShowHomePanel();
|
|
});
|
|
|
|
exit = this.transform.Find("Exit").gameObject;
|
|
exit.SetActive(false);
|
|
#if UNITY_ANDROID || UNITY_IOS
|
|
UIManager.AddEvent(transform.Find("Delay").gameObject, EventTriggerType.PointerClick, b =>
|
|
{
|
|
delayTime = 3;
|
|
transform.Find("Delay/Tooltips").gameObject.SetActive(true);
|
|
transform.Find("Delay/Tooltips").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
|
});
|
|
#endif
|
|
//transform.Find("Delay").GetComponent<PfUIButton>().showTooltip = true;
|
|
UIManager.AddEvent(exit, EventTriggerType.PointerClick, (e) =>
|
|
{
|
|
UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", ()=> {
|
|
Application.Quit();
|
|
},2);
|
|
});
|
|
|
|
UIManager.AddEvent(transform.Find("Setting").gameObject, EventTriggerType.PointerClick, x =>
|
|
{
|
|
UIManager.ShowSettingModal();
|
|
});
|
|
UIManager.AddEvent(transform.Find("Support").gameObject, EventTriggerType.PointerClick, x =>
|
|
{
|
|
UIManager.ShowFeedBackModal();
|
|
});
|
|
}
|
|
|
|
public void ShowRowerTab()
|
|
{
|
|
if (transform.Find("Device"))
|
|
{
|
|
transform.Find("Device").gameObject.SetActive(false);
|
|
}
|
|
if (transform.Find("Exit"))
|
|
{
|
|
transform.Find("Exit").gameObject.SetActive(true);
|
|
}
|
|
if (transform.Find("Home"))
|
|
{
|
|
transform.Find("Home").gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (delayTime < 0)
|
|
{
|
|
Debug.Log("小时");
|
|
delayTime = 0;
|
|
transform.Find("Delay/Tooltips").GetComponent<CanvasGroup>().DOFade(0, 0.5f).onComplete = ()=>
|
|
{
|
|
transform.Find("Delay/Tooltips").gameObject.SetActive(false);
|
|
};
|
|
}
|
|
else if(delayTime > 0)
|
|
{
|
|
Debug.Log(delayTime);
|
|
delayTime -= Time.deltaTime;
|
|
}
|
|
}
|
|
|
|
public void ShowExit()
|
|
{
|
|
if (exit)
|
|
{
|
|
exit.SetActive(true);
|
|
}
|
|
if (home)
|
|
{
|
|
home.SetActive(false);
|
|
}
|
|
}
|
|
}
|