Git Product home page Git Product logo

vibration's Introduction

Vibration

Native free plugin for Unity for iOS and Android. Use custom vibrations on mobile.

If you like this free plugin, that's be cool if you can buy me a coffee ๐Ÿ˜€โ˜•๏ธ Send tips to https://paypal.me/UnityVibrationPlugin

Installation

The minimal checked Unity Version is 2019.3.* LTS

Open Package Manager and "Add package from git url..." using next string:

  • https://github.com/BenoitFreslon/Vibration.git

You also can edit Packages/manifest.json manually, just add:

  • "com.benoitfreslon.vibration": "https://github.com/BenoitFreslon/Vibration.git",

Or you can simply copy and paste the entire Vibration folder to your Unity3D Assets folder.

Use

Initialization

Initialize the plugin with this line before using vibrations:

Vibration.Init();

Vibrations

iOS and Android

Default vibration

Use Vibration.Vibrate(); for a classic default ~400ms vibration

Pop vibration

Pop vibration: weak boom (For iOS: only available with the haptic engine. iPhone 6s minimum or Android)

Vibration.VibratePop();

Peek Vibration

Peek vibration: strong boom (For iOS: only available on iOS with the haptic engine. iPhone 6s minimum or Android)

Vibration.VibratePeek();

Nope Vibration

Nope vibration: series of three weak booms (For iOS: only available with the haptic engine. iPhone 6s minimum or Android)

Vibration.VibrateNope();


Android Only

Custom duration in milliseconds

Vibration.Vibrate(500);

Pattern

long [] pattern = { 0, 1000, 1000, 1000, 1000 };
Vibration.Vibrate ( pattern, -1 );

Cancel

Vibration.Cancel();


IOS only

vibration using haptic engine

Vibration.VibrateIOS(ImpactFeedbackStyle.Light);

Vibration.VibrateIOS(ImpactFeedbackStyle.Medium);

Vibration.VibrateIOS(ImpactFeedbackStyle.Heavy);

Vibration.VibrateIOS(ImpactFeedbackStyle.Rigid);

Vibration.VibrateIOS(ImpactFeedbackStyle.Soft);

Vibration.VibrateIOS(NotificationFeedbackStyle.Error);

Vibration.VibrateIOS(NotificationFeedbackStyle.Success);

Vibration.VibrateIOS(NotificationFeedbackStyle.Warning);

Vibration.VibrateIOS_SelectionChanged();

vibration's People

Contributors

aminsojoudi avatar benoitfreslon avatar oivoodoo avatar sh42913 avatar vhnunes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vibration's Issues

ReadMe

Nice Plugin! Maybe you add a description to the pattern vibration that the 1,3,5 ... value the break between the vibrations is.

Normal vibration not working on iOS 13.2.2

First of all, thanks for a great plugin!

I recently upgraded to iOS 13.2.2 and now the normal "main" vibration is not working for some reason. Pop and the other haptics are working, but the classic default doesn't do anything. Any idea of what might cause this?

iOS Pop/Peek/Nope

Documentation change:
It's only available with the haptic engine; which is iPhone 6s/6s Plus

peek or pop?

iOS:
ios peek is weak,pop is strong

  • (void) vibratePeek {
    AudioServicesPlaySystemSoundWithCompletion(1519, NULL); // Actuate Peek feedback (weak boom)
    }
  • (void) vibratePop {
    AudioServicesPlaySystemSoundWithCompletion(1520, NULL); // Actuate Pop feedback (strong boom)
    }

but,in the readme.md:

Pop vibration
Pop vibration: weak boom (For iOS: only available with the haptic engine. iPhone 6s minimum or Android)

Vibration.VibratePop();

Peek Vibration
Peek vibration: strong boom (For iOS: only available on iOS with the haptic engine. iPhone 6s minimum or Android)

Vibration.VibratePeek();

Little unclarity

Summary for method VibratePeek() says "Small peek vibration", but the readme.md says "Peek vibration: strong boom". Strong or small? I'm confused.

Errors

Hi!

When i try to build i get this errors:
Screen Shot 2019-04-16 at 17 03 47

Soften Vibration Power

Thanks for the package!

I love using VibratePop(), it's really smooth. But, is it possible to further soften the power? It's somewhat strong compared to vibration of iOS toggles. I checked the iOS plugin code and couldn't see anything that I can adjust.

I highly value any your reply.

VibrateNope is two instead of three on Android

In VibrateNope your android pattern is { 0, 50, 50, 50 }, which is two vibratios instead of three. Android patterns are like { repeats, vibration_length, delay, vibration_length, delay, ... }.

EntryPointNotFoundException while in Unity Editor

Trying to call Vibration.VibrateIOS(ImpactFeedbackStyle.Medium) while inside the Unity Editor returns an error. It works fine once built to the device though. I'm running this on a Windows 10 computer, so perhaps I'm missing some native IOS stuff. Might just deny it if I'm in the Unity Editor, but wanted to post this just in case.

The line that's causing the error:
`
#if UNITY_IOS

public static void VibrateIOS(ImpactFeedbackStyle style)
{
    _impactOccurred(style.ToString());
}

public static void VibrateIOS(NotificationFeedbackStyle style)
{
    _notificationOccurred(style.ToString());
}

public static void VibrateIOS_SelectionChanged()
{
    _selectionChanged();
}    

#endif
`

Error:
_EntryPointNotFoundException: impactOccurred assembly: type: member:(null)
Vibration.VibrateIOS (ImpactFeedbackStyle style) (at Assets/Vibration/Vibration.cs:84)
SingletonMaster.VibrateInput () (at Assets/Scripts/Singletons/SingletonMaster.cs:133)
SingletonMaster.Vibrate (VibrationType t) (at Assets/Scripts/Singletons/SingletonMaster.cs:109)
MainMenu.Vibrate (VibrationType t) (at Assets/Scripts/Management/MainMenu.cs:162)
MainMenu.ToggleMenu (System.Int32 index) (at Assets/Scripts/Management/MainMenu.cs:118)
UnityEngine.Events.InvokableCall1[T1].Invoke (T1 args0) (at <7b2a272e51214e2f91bbc4fb4f28eff8>:0) UnityEngine.Events.CachedInvokableCall1[T].Invoke (System.Object[] args) (at <7b2a272e51214e2f91bbc4fb4f28eff8>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <7b2a272e51214e2f91bbc4fb4f28eff8>:0)
UnityEngine.UI.Button.Press () (at Library/PackageCache/[email protected]/Runtime/UI/Core/Button.cs:70)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/[email protected]/Runtime/UI/Core/Button.cs:114)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/[email protected]/Runtime/EventSystem/ExecuteEvents.cs:57)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/[email protected]/Runtime/EventSystem/ExecuteEvents.cs:272)
UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/[email protected]/Runtime/EventSystem/EventSystem.cs:501)

iOS build error Symbol: __VibrateNope

Hi!
First, thank you for your work!
I'm experiencing a problem when trying to build for iOS:

12720: โ–ธ โŒ;  Undefined symbols for architecture armv7
12721: โ–ธ > Symbol: __VibrateNope
12722: โ–ธ > Referenced from: _Vibration__VibrateNope_mF571C84C03060C5EA2270E855DE9D7A0BA1832C5 in Assembly-CSharp1.o
12723: โ–ธ โŒ;  ld: symbol(s) not found for architecture armv7
12724: โ–ธ โŒ;  clang: error: linker command failed with exit code 1 (use -v to see invocation)

Everything works well with Android.

Any idea why I got this error? Am I missing something?

Undefined symbol

Undefined symbol: __VibratePeek
Undefined symbol: __VibratePop
Undefined symbol: __VibrateNope
Undefined symbol: __Vibrate
Undefined symbol: __HasVibrator

Newly upgraded - Unity 2021.2.3f1 (Intel version from Unity hub)
Code worked in Unity 2019.x

xCode screenshot:
image

Vibration.cs getting error

On android i getting this error.

Assets\Scripts\Vibration.cs(63,43): error CS0103: The name 'contextClass' does not exist in the current context

put variables into the vibration pattern

Hey, im very new to coding and have no idea how to put some floats into the long[] pattern. For instance, I would like to put the Input.acceleration.z there. Could you pls help me out?

Where is the Unity package file?

There are no releases or packages published. Am I missing something?
Is it possible we can import the package via package manager and GitHub URL?

Does not compile for WEBGL builds.

Does not compile for WEBGL builds.
line 174 should probably be removed

//Handheld.Vibrate ()

and
line 222 needs an ifdef, probably this:

if (Application.isMobilePlatform)
            {
#if UNITY_ANDROID || UNITY_IOS
                Handheld.Vibrate();
#endif
            }

This is the error for reference
Vibration.cs(222,17): error CS0103: The name 'Handheld' does not exist in the current context

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.