You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.2 KiB
48 lines
1.2 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Drawing.Text;
|
|
using UnityEngine;
|
|
|
|
public static class Vibration
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
public static AndroidJavaClass AndroidPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
|
public static AndroidJavaObject AndroidcurrentActivity = AndroidPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
|
public static AndroidJavaObject AndroidVibrator = AndroidcurrentActivity.Call<AndroidJavaObject>("getSystemService", "vibrator");
|
|
#endif
|
|
public static void Vibrate()
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
AndroidVibrator.Call("vibrate");
|
|
#else
|
|
Handheld.Vibrate();
|
|
#endif
|
|
}
|
|
|
|
public static void Vibrate(long milliseconds)
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
AndroidVibrator.Call("vibrate", milliseconds);
|
|
#else
|
|
Handheld.Vibrate();
|
|
#endif
|
|
}
|
|
public static void Vibrate(long[] pattern, int repeat)
|
|
{
|
|
|
|
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
AndroidVibrator.Call("vibrate", pattern, repeat);
|
|
#else
|
|
Handheld.Vibrate();
|
|
#endif
|
|
}
|
|
|
|
public static void Cancel()
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
AndroidVibrator.Call("cancel");
|
|
#endif
|
|
}
|
|
|
|
}
|