feat: 核心功能实现
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace OCES.Haptic
|
||||
{
|
||||
public class HapticInvoker : MonoBehaviour
|
||||
{
|
||||
public InputField inputField;
|
||||
public Button button;
|
||||
|
||||
uint m_hapticId;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
this.inputField.onSubmit.AddListener(GetCurrentHapticId);
|
||||
this.inputField.onEndEdit.AddListener(GetCurrentHapticId);
|
||||
this.button.onClick.AddListener(InvokeHaptic);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
this.inputField.onSubmit.RemoveListener(GetCurrentHapticId);
|
||||
this.inputField.onEndEdit.RemoveListener(GetCurrentHapticId);
|
||||
this.button.onClick.RemoveListener(InvokeHaptic);
|
||||
}
|
||||
|
||||
void GetCurrentHapticId(string value)
|
||||
{
|
||||
if(string.IsNullOrEmpty(value)) return;
|
||||
|
||||
this.m_hapticId = uint.Parse(value);
|
||||
}
|
||||
|
||||
void InvokeHaptic()
|
||||
{
|
||||
HapticSystem.Instance.Play(this.m_hapticId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user