Using Android Studio with Unity - c#

I would like to build an app that uses augmented reality. To be honest, i prefer Android Studio, but i realized, that Unity3D with Vuforia might be the best choice for me. Im intrested in the best solution, to build my app in Android Studio, but clicking on a button (this will be my main usecase), i open the augmented reality project, i built in Unity. What would be the best solution?
UPDATE
Here is what i found:
First way:
I make my project in Unity, and exporting the project (add the module name to dependencies:
dependencies{
compile project(':UnityClasses')
}
Then importing it into Android Studio. Then i could talk between modules like this:
How-to-call-method-and-return-its-value-with-unityplayer-unitysendmessage
If im correct here, in this way i can send data to Unity module within Android Studio by the 3rd parameter of UnitySendMessageExtension, and i can send data back by the Callstatic method.
Second way:
Use Unity as a Subview
Third way
Integrating Unity into Android Studio
Can anyone help me, who tried these above, to tell me what the best way is?

Unity is a full development solution, so you really do not need to mix up with android studio.
And additionally, Unity is fully compatible with whatever you need because it is C# based so in addition to Unity specific support, anything that works for C# will work for Unity as well.
and here is a link to the Unity firebase SDK:
https://firebase.google.com/docs/unity/setup?gclid=EAIaIQobChMI56nk0-Cb2QIVAilpCh2GOw6zEAAYASAAEgIPZfD_BwE
The only real difference is if you don't like to program 50% visually 50% C# in Unity VS programming in javandroid (that's what I call whatever is going on in android studio ^-^').
Plus Unity exports to everything while android studio is exclusive to android devices, so developing for Unity has greater benefit.
EDIT:
You can call Android OS features written in java or c++, from C# by using the Native Plugins functionality:
https://docs.unity3d.com/Manual/AndroidJARPlugins.html
https://docs.unity3d.com/Manual/NativePlugins.html
as well as extending the main activity with your own activities
https://docs.unity3d.com/Manual/AndroidUnityPlayerActivity.html
All these features are there for when you want to do more than just games, like architectural visualization or whatever other app that requires 3D manipulations like AR.

Related

Changing project's Unity version of existing game

I have a game where I have access to it's complete code via dnspy and I can make plugins and mods for it with no issues.
The game is written in assembly csharp and
the dll. (which I never had to touch) in c++.
It uses unity 2015 and runs on 3.5 framework.
Also, I can extract .assets from the game such as backgrounds or literally anything else and run re-textures using an unity bundle via a modloader.
I want to implement some features from Nvidia packages that are not available with unity 2015.
Would it be possible to port this project to unity 2020 or 2021 without too many issues?
Thanks

Can't create C# Holographic project in Visual Studio 2019

I'm trying to start developing for the Hololens 2.
Instead of using Unity to create a 3D app, my intention is to create a "desktop app" with C#.
After installing the Windows Mixed Reality App Templates from the Microsoft Marketplace, I tried to create a C# project but VS gets stuck in the progress bar while creating the project and after several minutes displays the following message:
This issue is somewhat approached in this MS page: Creating a holographic DirectX project, in which it says:
If your holographic C# project didn't start from the Windows Holographic app template, you'll need to copy the ms.fxcompile.targets file from a Windows Mixed Reality C# template project and import it in your.csproj file to compile HLSL files that you add to your project.
It is clearly a known issue by Microsoft, but that's all there is to it.
Even with VS completely stuck, it does create the files for the project, and all the files mentioned above are present but i does not open properly.
What should I do to make the C# project work? Have anyone else faced this?
PS.: The C++ project template works fine.
Thanks.
When you say you want to create a "desktop app with C#", are you referring to a 2D app or a volumetric app?
2D apps are a breeze, you just create a regular UWP C# project [Blank (App Universal Windows)] and then build and deploy it for ARM64 to your HoloLens 2 and it will just work. No special templates required. Regular UWP apps that run on the desktop also run on the HoloLens. You can do a few things to optimize them for HoloLens and/or Windows Mixed Reality but you don't require any special templates.
See these links for more info:
Designing for Mixed Reality and
Building 2D Apps
If on the other hand you are trying to create a volumetric 3D experience in C# that involves DirectX there is a template in the Windows Mixed Reality templates that leverages SharpDX, look for the "Holographic DirectX11 App (Universal Windows)" the template without the "(C++/WinRT)" trailing text. It is a C# option that leverages the opensource SharpDX wrappers. There is mention of that option near the end of this "Creating a UWP project" section of the
Creating a holographic DirectX project page.

Is there any way to use xaml/c# in android studio

I am creating android apps in Xamarin.forms now. But the apk size of Xamarin apps is more than 90 Mb. So I am planning to switch to the android studio as it is specially designed for android apps. But I have very little knowledge about Java and Kotlin.
I am very familiar with C# because I am coding in Xamarin. Is there any way to use C# instead of java in Android Studio?
Any help would be appreciated.
Actually we can't. Android Studio supports only Java and Kotlin and we can build apps using C++ but not with any other Languages.
But instead you can reduce your Xamarin App size from 90 MB to less than 15 MB.
Make sure that you set in Release Configuration
You can reduce it by,
Linking all you app's SDK and User Assemblies
Using Code Shrinker (either ProGuard or r8)
Enabling Multi-Dex to improve performance.
Bundle assemblies into native code to improve performance.
AOT Compilation you can try this, but it didn't work for me, this reduces the startup time.
Disable Debugging\
Linking all you app's SDK and User Assemblies will actually reduce your app size upto 70% to 85% depending upon your coding and assets that you have.
If you do good in C# then Java could be a bit easy as both looks similar and most of the functions and method are same (If you build apps in Xamarin.droid).
Even I too switched from Visual Studio 2019 making apps using Xamarin to Android Studio using Java. At starting as usual feels somewhat difficult but then it will be very familiar. It just takes 1 or 2 weeks to get the basics done with Java if you know C#. This is from my Experience.

Monodevelop android error

so i downloaded monodevelop...and it installed xamarin studio 5.0.1...the gtkc# is working well...i made an app and run it...everything went well...when i tried to make an android app with c# thru new solution it said the "MainActivity.cs" couldn't be found.I let the default location in documents/projects and named the solution hello.I also have installed the android development add-in from add-in manager.I can't figure out what's the problem...also i had installed the android tools from eclipse.
I think it has something to do with the licensing, as XamarinStudio + Android / iOS is not a free product. I believe that the "re-branded-as-XamarinStudio" MonoDevelop available from the MonoDevelop website is simply missing the stuff needed to create these types of projects.
While I'd be interested in knowing why MonoDevelop has released a crippled (read broken) version of XamarinStudio, one can simply get the fully-functional "XamarinStudio" from the XamarinStudio website, and it will be able to create these project types without this issue (so long as you have a trial, or full license).
It will still be able to create other types of C# projects, just as MonoDevelop used to, as this whole thing is part of the process of moving away from the MonoDevelop name, and having a single product "XamarinStudio".

Converting a WIndows Store MonoGame app to Android

I'm very new to Xamarin. I have a few published Windows Store apps and want to convert them to Android. I'm attempting to use Xamarin for this. I'm just using the free version of Xamarin. Here's where I am so far:
I am trying two apps - one was build with Monogame and one is just build on the WinRT framework.
I have managed to get them both into Xamarin studio, basically by hacking the csproj files.
I'm getting build errors because it's missing references. There does appear to be some equivalent Mono / .Net4 libraries, but things like Storage seem to be missing.
So, my question is: am I going about this the right way and, if so, am I missing a step ("convert dependencies" or something)?
If I'm not going about this the right way then how should I be doing this (I found very few online resources on this subject)?
EDIT:
The following are some specific errors that I'm getting from the Xamarin App:
And my references:
EDIT:
After some further research, the only dependency I can't explain as missing is Microsoft.Xna.*. The others all have different implementations on Android / iOS.
You will be able to use much of your existing code with Xamarin.
However, the errors you are getting with those specific libraries are because they do not exist for Xamarin in iOS and Android. So whatever functionality you had you will need to rework using libraries that are available.
For example, instead of using Windows.Storage you would use Android.OS.Storage.
See their documentation for details:
http://androidapi.xamarin.com/index.aspx?link=N%3AAndroid.OS.Storage
Edit
For XNA all of that should port fine if you use MonoGame:
https://github.com/mono/MonoGame/wiki
I'm not sure why it's not bundled in Xamarin, but that will hook you up.
Edit
This is taken from Xamarin documentation found here: http://developer.xamarin.com/guides/cross-platform/cocos2d_xna/cocos2dxna_tutorial/
After creating the project, you need to add the various Cocos2D-XNA dependencies to the solution. Add the following projects from the location where you downloaded the Cocos2D-XNA and MonoGame source:
box2d.iOS – 2D physics library. We’ll use this in later tutorials.
cocos2d.iOS – Cocos2D-XNA for iOS.
Lidgren.Network.iOS – Networking library used by MonoGame.
MonoGame.Framework.iOS – MonoGame for iOS.
This video may answer your question. You will most likely need to replace the reference with a PCL equivalent if one exists.
http://developer.xamarin.com/videos/cross-platform/any/

Categories

Resources