Enemy Logik erstellt Weitere Kommentare: Ich werde herausfinden, wer Coroutinen erfunden hat und diese Person auf dieselbe Art knechten, wie ich es in den letzten 5 Stunden wurde. WaitForSeconds(5) aber alles 4000 Mal in 3 Sekunden durchlaufen, mein Arsch.
This commit is contained in:
48
Assets/Scripts/Button Functions/Vibrator.cs
Normal file
48
Assets/Scripts/Button Functions/Vibrator.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class Vibrator
|
||||
{
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
public static AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
public static AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
public static AndroidJavaObject vibrator = currentActivity.Call<AndroidJavaObject>("getSystemService", "vibrator");
|
||||
|
||||
#else
|
||||
public static AndroidJavaClass unityPlayer;
|
||||
public static AndroidJavaObject currentActivity;
|
||||
public static AndroidJavaObject vibrator;
|
||||
|
||||
#endif
|
||||
|
||||
public static void Vibrate(long milliseconds = 250)
|
||||
{
|
||||
if (IsAndroid())
|
||||
{
|
||||
vibrator.Call("vibrate", milliseconds);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
Handheld.Vibrate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Cancel()
|
||||
{
|
||||
if (IsAndroid())
|
||||
{
|
||||
vibrator.Call("cancel");
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsAndroid()
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user