How to share the post to internet from game in unity3d? - c#

I want to share the score from my game to social network like FB, Twitter, dll,,
and i use Native Android Plugin.
In the tutorial they said we can share it with just using this function
AndroidSocialGate.StartShareIntent("Hello Share Intent", "This is my text to share");
when i use it, theres no error, but when i call it nothing happen too..
is there someone know where's the problem?
or is there any other way?

I had some problems with native android plugin.
Check weather android menifest merging is needed with other plugins.
Merging Adnroid Native Plugin 1
Merging Android Native Plugin 2
Use this links
Also Check in the logcat what the debug messages say for plugin if there is any error while you can get it there. Remember to use logcat for plugins as most errors unity wont be able to show.

Related

Programmatically loading native libraries in Xamarin

Our Xamarin app supports some device-specific hardware features for a specific Android device packing an RFID scanner. We don't like to clutter up our basic app with stuff related to this device, so we created a separate Xamarin library containing the logic for this device, which is built to be an Asset of the Droid project. During statup of the app, we check if we are on this specific device and if we are, we programmatically load the hardware specific Xamarin library using Assembly.Load(...) and activate it.
The problem we run into is that the manufacturer of the device provided us with some native android libraries (.so files) that must be used. Normally you would include those in the Droid project with build action AndroidNativeLibrary, but since we want to encapsulate all stuff related to this device in a separate project, we don't want to do this. We have tried the following:
To add them to the device specific Xamarin library with build action AndroidNativeLibrary, but then the app cannot find them. They are probably not saved to disk and therefore they cannot be found.
To add them to the device specific Xamarin library with build action Embedded Resource and save them to disk when the library is started, but none of the locations, where the app searches for native libraries it needs, is accessible. Therefore the app cannot find them and the library cannot work.
I am starting to think that Android has shielded this kind of behavior off, but I am still hoping for some of you to help me with a good trick. Thanks in advance.

Call Functions on Voice Commands In Android Unity

I am making a flashlight application in unity C#. The application is almost complete I just want to add this voice command feature in this like when I say "ON" the flashlight should turn on and when I say " OFF " the flashlight should turn off. The application is for Android devices. I saw several tutorials about calling functions on voice commands but that all were only for windows platform please help me if you know something about doing this in android thanks
I have not used any Speech Recognition tools but its not very difficult to implement if you can create a java plugin & use it to call native function. Anyways I have found few of the SDK:
You can check out the pocket sphinx demos for speech recognition.
https://github.com/cmusphinx/pocketsphinx
https://github.com/cmusphinx/pocketsphinx-android-demo
Here is a repo I found which uses AndroidSpeechRecognition.
https://github.com/gsssrao/UnityAndroidSpeechRecognition
Programmer has given a nice explaination of voice recognition implementation natively:
How to add Speech Recognition to Unity project?
Then there is WatsonSDK for unity but it seems to be via cloud but you can check this one out:
https://github.com/watson-developer-cloud/unity-sdk
And if you dont mind paying for this plugin called Android SpeakNow you can grab it from asset store:
https://assetstore.unity.com/packages/tools/integration/android-speaknow-16781
These are some cloud based packages from asset store, I really doubt you might need this one to implement but in any case this is for someone who may require them at some point of time:
https://assetstore.unity.com/packages/add-ons/machinelearning/google-cloud-speech-recognition-vr-ar-desktop-desktop-72625
https://assetstore.unity.com/packages/tools/integration/yandex-cloud-speech-recognition-vr-ar-mobile-desktop-75155
And finally DictationRecognizer; by default this one is available only for windows 10 as of Unity 2018.2. So this is out of question. My best bet would be cmusphinx or implementing natively which I believe would be more suitable for your needs. Check them out. Try to implement one or two and let us know if you were successful or not.
If anyone can add more links to SDK for voice recognition feel free to add. This would be really great.
If you just need only ON and OFF voice inputs you can use the following code
Speech to text in unity
If you need exact speech recognition then refer the following code
Speech recognition in unity

Turn on GPS by code in Unity

I'm creating an application that use Location services, and want to give the possibility to the user to get to Location services in his android device by a simple click in the application. How must i proceed ?
On 4.4 an earlier version there was a bug which let people enable GPS programmatically. So for Android 5 and later there is no way to do that.
In Unity accessing such features can only be done using Java Plug-in.
Here is the Java code which will show a pop-up that ask the user to choose if they want let you use the GPS or not.
startActivity(context, new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
I don't know if you know how to write Java Plug-in for Unity so here is the link where you can find a comprehensive guide.
Go to this link Here you'll find how to convert your project to library after build your file will be here "build/output/aar/..."

Unity iOS making saved image show in photos

I have an image saved from my game at Application.persistentDataPath + #"/p.png" I am trying to make this visible in iOS, I have managed it in android using the Android wrappers in Unity C# but I have no idea where to start with iOS.
Is it possible for me to pass the path to my Image to iOS so that it will show up in the Photos app? If I need to write my own plugin does anyone have any decent documentation on how it's done?
If I need to write my own plugin does anyone have any decent
documentation on how it's done?
That seems like the only way. Make a plugin that can read and write byte array to Picture folder on the iOS. You can also use already made one from here that cost $10. This plugins works with iOS, Android and Windows Phone 8 and I recommend you got with it.
The fact is that I can't write the whole process here. You first need to know how to write and read from the photo folder. Here is a link for that.
Now you need to know how to call a C# function fro Objective-C and vice versa. Many tutorials for this.
http://twnkls.com/2016/04/11/creating-native-plugins-for-unity3d/
http://alexanderwong.me/post/29861010648/call-objective-c-from-unity-call-unity-from
https://www.quora.com/How-do-you-call-native-iOS-functions-from-Unity
https://stackoverflow.com/a/30946257/3785314

Linking C++ header and lib file with Unity

So i am creating a simple game in unity where i want to use the tn gaming vest.
http://tngames.com/pages/Developers
I have downloaded the SDK from their homepage, this SDK is a C++ header and library file. What I dont know is how to approach from here on, using this for my unity project. Anyone know how to couple the files with my game so I can use the methods?
One problem is that i dont have Unity pro so i cannot use plugins as some people have suggested on some questions i found.
At least since Unity 5, it is possible for both Pro and Free users to create native plugins, and interface with the platform they are running on:
Unity - Manual: Native Plugins
The steps are different for each platform, but they usually involve creating some kind of library (for instance dynamic .so under Android and static .a under iOs, which are the platforms I'm dealing with right now) and import the symbol into C# (everything is summarily explained in the documentation).
The process has it's own quirks, but it definitely works if enough effort is put into it...
Hope it helps (and removes some confusion that might be triggered by the, now outdated, accepted answer)
Without Unity pro you can't use plugins and thus you can't use native library or external code.

Categories