Skip to content

Instantly share code, notes, and snippets.

munkbusiness / Vibration.cs
Last active November 24, 2023 00:42
Vibration for Unity3d with Android native Call that supports both the new vibrationEffectClass and the old simple vibrate, with fallback to Handlheld.Vibrate().
using UnityEngine;
using System.Collections;
public class Vibration : MonoBehaviour {
public static AndroidJavaClass unityPlayer;
public static AndroidJavaObject vibrator;
public static AndroidJavaObject currentActivity;
public static AndroidJavaClass vibrationEffectClass;
public static int defaultAmplitude;
munkbusiness / EnumerableExtensions
Created March 20, 2018 10:45
Generic type array shuffling based on @fincha solutions
using System.Collections.Generic;
using UnityEngine;
public static class EnumerableExtensions {
public static T[] ShuffleArray<T>(this T[] a) {
// Loops through array
for (int i = a.Length - 1; i > 0; i--) {
// Randomize a number between 0 and i (so that the range decreases each time)
int rnd = UnityEngine.Random.Range(0, i);