Skip to content

Instantly share code, notes, and snippets.

munkbusiness / EnumerableExtensions
Created Mar 20, 2018
Generic type array shuffling based on @fincha solutions
View EnumerableExtensions
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);
munkbusiness / Vibration.cs
Last active May 20, 2021
Vibration for Unity3d with Android native Call that supports both the new vibrationEffectClass and the old simple vibrate, with fallback to Handlheld.Vibrate().
View Vibration.cs
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;