Skip to content

Instantly share code, notes, and snippets.

View Watcher3056's full-sized avatar
🤨
Tired of "generic" game developers? Contact me!

Vladylsav Watcher3056

🤨
Tired of "generic" game developers? Contact me!
View GitHub Profile
@Watcher3056
Watcher3056 / Vibration.cs
Created September 9, 2021 18:05 — forked from aVolpe/Vibration.cs
Vibration for Unity3d with Android native Call, with fallback to Handlheld.Vibrate()
using UnityEngine;
using System.Collections;
public static class Vibration
{
#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");