赞
踩
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- //using UnityEngine.Events;
- //using UnityEngine.EventSystems;
- using UnityEngine.UI;
- using UnityEngine.Events;
- using UnityEngine.EventSystems;
-
- public class menu_start : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler
- {
-
-
- public AudioClip audioClip;
-
- private AudioSource audioPlayer;
-
- public Texture2D texture_enter;
- public Texture2D texture_exit;
- private RawImage rawImage;
- // Start is called before the first frame update
- void Start()
- {
- audioPlayer = GetComponent<AudioSource>();
- rawImage = GetComponent<RawImage>();
- }
-
- // Update is called once per frame
- void Update()
- {
-
-
- }
-
- void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData) {
- Debug.Log("EventTriggerTest OnPointerEnter");
- playAudio();
- rawImage.texture = texture_enter;
-
- }
- void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
- {
- Debug.Log("EventTriggerTest OnPointerExit");
- //playAudio();
- rawImage.texture = texture_exit;
-
- }
-
- void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
- {
- Debug.Log("EventTriggerTest OnPointerDown");
-
- if (gameObject.tag == "menu_play")
- {
- Debug.Log("EventTriggerTest menu_play");
- StartCoroutine(toMain());
-
- }
- else if (gameObject.tag == "menu_introduce")
- {
- Debug.Log("EventTriggerTest menu_introduce");
- StartCoroutine(toIntroduce());
-
-
- }
- else if (gameObject.tag == "menu_quit") {
- Debug.Log("EventTriggerTest menu_quit");
- StartCoroutine(quit());
- }
-
- playAudio();
- }
-
- void playAudio() {
- audioPlayer.clip = audioClip;
- audioPlayer.Play();
- }
-
- IEnumerator quit()
- {
-
- yield return new WaitForSeconds(1.0f);
-
- Application.Quit();
- }
-
- IEnumerator toMain()
- {
-
- yield return new WaitForSeconds(1.0f);
-
- Application.LoadLevel("SceneMain");
- }
- IEnumerator toIntroduce()
- {
-
- yield return new WaitForSeconds(1.0f);
-
- Application.LoadLevel("SceneIntroduce");
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。