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

Don't work with Unity - NullReferenceException #36

Closed
Neogeekmo opened this issue May 22, 2020 · 4 comments
Closed

Don't work with Unity - NullReferenceException #36

Neogeekmo opened this issue May 22, 2020 · 4 comments

Comments

@Neogeekmo
Copy link

Neogeekmo commented May 22, 2020

I need to retrieve the path to my phone from the computer to copy/paste backup files to it.
After adding the nuget package to unity, it can't find my devices.
So I have this error:

NullReferenceException: Object reference not set to an instance of an object
MediaDevices.MediaDevice.GetDevices () (at <016781043aa441d5b0169b9d5116ee77>:0)
ManageSaves.CopySaveFromDevice () (at Assets/Scripts/ManageSaves.cs:65)
ManageSaves.Testing () (at Assets/Scripts/ManageSaves.cs:57)
MainMenu.Testing () (at Assets/Scripts/MainMenu.cs:69)
UnityEngine.Events.InvokableCall.Invoke () (at <23a7799da2e941b88c6db790c607d655>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <23a7799da2e941b88c6db790c607d655>:0)
UnityEngine.UI.Button.Press () (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:68)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:110)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)

A possible solution... that you know ?

@Bassman2
Copy link
Owner

According to the information in Wikipedia, Unity uses the Mono framework for scripting. MediaDevices does not support Mono because Mono has no COM support and MediaDevices is a wrapper for the Windows MTP COM interface.

@Neogeekmo
Copy link
Author

All right, thanks for your answer. I'll try to find another way.

@Bassman2
Copy link
Owner

According to my information, Mono can call methods in DLLs. I.e. if you pack the COM access into your own DLL and then call it from Unity, it should work.

@Neogeekmo
Copy link
Author

That's what I wanted to try to do but I'm still looking for another way to implement it directly in a unity script without having to code my dll .

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

2 participants