Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntryPointNotFoundException while in Unity Editor #22

Open
Carlfiii opened this issue Mar 18, 2023 · 2 comments
Open

EntryPointNotFoundException while in Unity Editor #22

Carlfiii opened this issue Mar 18, 2023 · 2 comments

Comments

@Carlfiii
Copy link

Carlfiii commented Mar 18, 2023

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)

@BenoitFreslon
Copy link
Owner

Try this

    public static void VibrateIOS(ImpactFeedbackStyle style)
    {
#if UNITY_IOS
        _impactOccurred(style.ToString());
#endif
    }

    public static void VibrateIOS(NotificationFeedbackStyle style)
    {
#if UNITY_IOS
        _notificationOccurred(style.ToString());
#endif
    }

    public static void VibrateIOS_SelectionChanged()
    
    {
#if UNITY_IOS
        _selectionChanged();
#endif
    }    ```

@dyrkabes
Copy link

dyrkabes commented Apr 2, 2023

Same error for me on Mac machine.

EntryPointNotFoundException: _impactOccurred
Vibration.VibrateIOS (ImpactFeedbackStyle style) (at Assets/Scripts/Vibration/Vibration.cs:85)

As I see, Vibration.cs already has those conditional ifs although it did not help:

    public static void VibrateIOS(ImpactFeedbackStyle style)
    {
#if UNITY_IOS
        _impactOccurred(style.ToString());
#endif
    }

I believe the issue is that unity editor is also considered UNITY_IOS. The solution is then to put #if !UNITY_EDITOR before the code invocation in the library. I went a bit further and added a Log when the vibration should happen in editor (just for testing) but it might be an overkill

#if UNITY_IOS
#if UNITY_EDITOR
        Debug.Log($"Impact with style {style} occured");
#else
        _impactOccurred(style.ToString());
#endif
#endif

Maybe it makes sense to create a wrapper around the Library that would encapsulate the logging part

static class MyVibration
{
    public static void Vibrate(ImpactFeedbackStyle style) // choose the name that fits you or just reuse the interface of the library
    {
#if UNITY_EDITOR
        Debug.Log($"Impact with style {style} occured");
#else
        Vibration.VibrateIOS(ImpactFeedbackStyle.Heavy);
        // Please note, Android is not handled, it's just an example
#endif
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants