-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathButtonProDemo.cs
More file actions
39 lines (34 loc) · 885 Bytes
/
ButtonProDemo.cs
File metadata and controls
39 lines (34 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonProDemo : MonoBehaviour
{
public static ButtonProDemo Instance;//测试代码,单例不要这么写
public GameObject doubleObj;
public GameObject longPressObj;
public AudioSource audioSound;
private void Awake()
{
Instance = this;
}
public void OnLongPressButtonClick()
{
Debug.Log("触发长按事件");
longPressObj.SetActive(true);
}
public void OnDoubleButtonClick()
{
Debug.Log("触发双击事件");
doubleObj.SetActive(true);
}
public void ResetObjState()
{
doubleObj.SetActive(false);
longPressObj.SetActive(false);
}
public void PlaySound()
{
AudioClip audioClip = Resources.Load<AudioClip>("ButtonClick");
audioSound.PlayOneShot(audioClip);
}
}