예제 #1
0
 /// <summary>
 /// Releases the feedback generators, usually you'll want to call this at OnDisable(); or anytime you know you won't need
 /// vibrations anymore.
 /// </summary>
 public static void iOSReleaseHaptics()
 {
     if (!MMNVPlatform.iOS())
     {
         return;
     }
     MMNViOS_ReleaseFeedbackGenerators();
 }
예제 #2
0
 /// <summary>
 /// Call this method to initialize the haptics. If you forget to do it, Nice Vibrations will do it for you the first time you
 /// call iOSTriggerHaptics. It's better if you do it though.
 /// </summary>
 public static void iOSInitializeHaptics()
 {
     if (!MMNVPlatform.iOS())
     {
         return;
     }
     MMNViOS_InstantiateFeedbackGenerators();
     iOSHapticsInitialized = true;
 }
예제 #3
0
 /// <summary>
 /// Returns true if the current platform is iOS, false otherwise
 /// </summary>
 /// <returns><c>true</c>, if O was ied, <c>false</c> otherwise.</returns>
 public static bool iOS()
 {
     return(MMNVPlatform.iOS());
 }
예제 #4
0
        /// <summary>
        /// iOS only : triggers a haptic feedback of the specified type
        /// </summary>
        /// <param name="type">Type.</param>
        public static void iOSTriggerHaptics(HapticTypes type, bool defaultToRegularVibrate = false)
        {
            if (!MMNVPlatform.iOS())
            {
                return;
            }

            if (!iOSHapticsInitialized)
            {
                iOSInitializeHaptics();
            }

            // this will trigger a standard vibration on all the iOS devices that don't support haptic feedback

            if (iOSHapticsSupported())
            {
                switch (type)
                {
                case HapticTypes.Selection:
                    MMNViOS_SelectionHaptic();
                    break;

                case HapticTypes.Success:
                    MMNViOS_SuccessHaptic();
                    break;

                case HapticTypes.Warning:
                    MMNViOS_WarningHaptic();
                    break;

                case HapticTypes.Failure:
                    MMNViOS_FailureHaptic();
                    break;

                case HapticTypes.LightImpact:
                    MMNViOS_LightImpactHaptic();
                    break;

                case HapticTypes.MediumImpact:
                    MMNViOS_MediumImpactHaptic();
                    break;

                case HapticTypes.HeavyImpact:
                    MMNViOS_HeavyImpactHaptic();
                    break;

                case HapticTypes.RigidImpact:
                    MMNViOS_RigidImpactHaptic();
                    break;

                case HapticTypes.SoftImpact:
                    MMNViOS_SoftImpactHaptic();
                    break;
                }
            }
            else if (defaultToRegularVibrate)
            {
                #if UNITY_IOS
                Handheld.Vibrate();
                #endif
            }
        }