Skip to content

Instantly share code, notes, and snippets.

@tapuo
Created December 11, 2012 12:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tapuo/4258278 to your computer and use it in GitHub Desktop.
Save tapuo/4258278 to your computer and use it in GitHub Desktop.
vibration for unity android
import UnityEngine
class Vibration(MonoBehaviour):
private viblator as AndroidJavaObject
def Start():
unityPlayer as AndroidJavaClass = AndroidJavaClass("com.unity3d.player.UnityPlayer")
currentActivity as AndroidJavaObject = unityPlayer.GetStatic[of AndroidJavaObject]("currentActivity")
viblator = currentActivity.Call[of AndroidJavaObject]("getSystemService","vibrator")
def _Dummy():
Handheld.Vibrate()
def Vibator(time as long):
viblator.Call("vibrate", time)
@aVolpe
Copy link

aVolpe commented Oct 16, 2014

Thanks for the gist, here is the c# version https://gist.github.com/aVolpe/707c8cf46b1bb8dfb363

@embraiz
Copy link

embraiz commented Mar 24, 2017

Thanks for this, saved some precious time for me. You deserve a cookie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment