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

Xamarin C# Support #33040

Closed
8 tasks
FeralBytes opened this issue Oct 24, 2019 · 41 comments
Closed
8 tasks

Xamarin C# Support #33040

FeralBytes opened this issue Oct 24, 2019 · 41 comments

Comments

@FeralBytes
Copy link
Contributor

FeralBytes commented Oct 24, 2019

I wanted to open an issue specific to tracking the status of using Xamarin with Godot. Because I have no idea how to do it, or if it is even possible yet?
I imagine this already works for Windows users, but given that many of us are Linux users; to include many Godot core developers; I wanted to know how we use it too.

Things needed to close this issue:

  • Working example project of a Linux user compiling a C# project for Godot with Xamarin support for Android.
  • Document the process for Linux users to create a C# Godot Xamarin project on Android.
  • Working example project of a Linux user compiling a C# project for Godot with Xamarin support for iOS.
  • Document the process for Linux users to create a C# Godot Xamarin project on Android.
  • Document the process for Windows users to create a C# Godot Xamarin project on Android.
  • Document the process for Windows users to create a C# Godot Xamarin project on iOS.
  • Document the process for OSX users to create a C# Godot Xamarin project on Android.
  • Document the process for OSX users to create a C# Godot Xamarin project on iOS.

Applies to Godot current master, and 3.2a2.

Thank you to all of the developers for your time and for making Godot such an awesome engine. I do realize that solving these issues is non-trivial, but if they are solved I wanted to know how? If they are not solved, I would like to know what are the possibilities for ways to solve it, and how can the community help?

@Calinou Calinou changed the title Xarmin C# Support Xamarin C# Support Oct 24, 2019
@aaronfranke
Copy link
Member

See #20267 (comment) for a response from the founder of Mono and Xamarin.

Any development tools we implement have to be multiplatform, since Godot is multiplatform, and it's Microsoft's business decision to not release Xamarin development tools for Linux. Stated indirectly:

I've been trying to write a reply here which won't get me fired for an hour so far. I don't want to be seen as making company policy, or revealing company secrets.

This is all a discussion of high-level management policy. There's no insurmountable technical barriers to any of the feasible ways to close this issue.

But anyway, thanks for opening this issue, we had nothing to track it before, even if it's looking quite hopeless to do in the near future.

@FeralBytes
Copy link
Contributor Author

@aaronfranke Thank you for the research, now that I think about it, I remember following you down this same rabbit hole (Only to learn that Evil Empires rarely change their minds about their enemies). Well now I am going to look for a workaround. I tried wine, but failed to get visual studio to install, now trying to get a virtual machine to install everything, but seems godot may not run in a virtual machine. So may be a dead end for Linux Developers?

@ricardoalcantara
Copy link
Contributor

@FeralBytes I don't understand what you're tying to achieve, Why do you want Xamarin support and why do you need Visual Studio on linux? I've been working with .NET and Godot for a while on linux and I don't have those problems. VSCode works like a charm on Linux for .NET and Godot uses mono for C#.

@FeralBytes
Copy link
Contributor Author

@ricardoalcantara I want to develop Android apps on Linux using C# which requires Xamarin for Android support.

using Android;

But I can not because Microsoft has purposefully blocked the use of Xamarin on Linux, you have to use it on Windows.

@ricardoalcantara
Copy link
Contributor

@FeralBytes You don't need Xamarin to make an Android App on Linux with Godot, have you read the documentation? Godot's C# implementation for Android uses Mono. #29359

@FeralBytes
Copy link
Contributor Author

@ricardoalcantara How can I use android specific features, for instance I want to turn wifi on and off, not event considering Android 10 which has a special requirement for such operations. Or Say I want to create a service on Android? Or utilize Bluetooth? Can I do these without Xamarin? If we can thoose should be published somewheres for the community to use. It is definitely possible to code around and basicly re-implement Xamarain's features but we really should not have too.

@ricardoalcantara
Copy link
Contributor

ricardoalcantara commented Oct 28, 2019

You can do it but you have to do it natively with java, you have to create an android module and setup an interface using Godot APIs and after that you can call it with C#, you can even use android specific dependencies like admob or firebase, actually this is how we do that. http://docs.godotengine.org/en/latest/tutorials/plugins/android/android_plugin.html

[Edit]
An example of plugin I recently saw someone posting o facebook.
https://github.com/mrcrb/godot-plugin-firebase

@FeralBytes
Copy link
Contributor Author

@ricardoalcantara Yes I know I could write Java, as that is what I did when I wrote the new permissions for Godot, but I want something easier. That required a large amount of setup, and maintanence. C# is integrated, having access to Xamarin would complete the package with out the need of recompiling the entire engine every time.

@ricardoalcantara
Copy link
Contributor

ricardoalcantara commented Oct 28, 2019

@FeralBytes They choose not to use Xamarin, there is no Xamarin available to be used.

[Edit]
It's a long time I don't read about Xamarin but AFAIK it's another runtime like Mono, so that's why Microsoft guys wanted to build a binary for Godot, but I read someone (so don't take my word as totally true) that they didn't want to be locked with Xamarin vendors implementation so they decided to go for Mono open source project. Still Microsoft sponsored it. You can read more about it here https://godotengine.org/article/csharp-android-support

@FeralBytes
Copy link
Contributor Author

Actually Xamarin is still a part of the C# ecosystem. But as stated by the microsoft emplyees, they could get it working for Linux, but they are not going to. So yes there is no Xamarin for Mono, but their is Xamarin for Visual Studio. Not to be confused with Code (Visual Studio Code). You can see the difference between thoose products here.

@ricardoalcantara
Copy link
Contributor

ricardoalcantara commented Oct 28, 2019

I know those products, I know Xamarin since before Microsoft purchased it, I know Visual studio since the first one and VSCode too, I know the difference, I know .NET Core (which runs on linux natively), .NET framework and .NET Standards, I know Mono project, I know the moves Microsoft made to make .NET Core, .NET Framework and Mono to have the same code base, I don't have doubts I am trying to solve yours, maybe you don't know Godot enough... and I also know that there is no Xamarin for Godot. What else do you need?

@FeralBytes
Copy link
Contributor Author

FeralBytes commented Oct 28, 2019

What else do you need?

Xamarin for Godot. Not trying to be rude, but that is the title, technically it isn't, but it is an issue opened for the Godot Engine with a title of Xamarin C# Support. Additionally my first post does ask pretty clearly what I would like.

I don't have doubts I am trying to solve yours,

This is a confusing statement.

maybe you don't know Godot enough...

It seems like you are just trying to insult me now. So I think I will stop having this conversation with you.

@ricardoalcantara
Copy link
Contributor

ricardoalcantara commented Oct 28, 2019

Xamarin for Godot

Now I understand, you want to request a feature. This what I asked at the first place. For me your issue is not clear, you opened it as Xamarin was implemented and requesting sample projects. For this issue you better open it here https://github.com/godotengine/godot-proposals

#33040 (comment)

@FeralBytes I don't understand what you're tying to achieve,

It seems like you are just trying to insult me now. So I think I will stop having this conversation with you.

Not at all.

@aaronfranke
Copy link
Member

aaronfranke commented Oct 28, 2019

In case there is still any confusion as to why it would be desired to have Xamarin available with Godot, let me just copy paste this bit from Miguel de Icaza's comment:

But most importantly, because then your C# users could call and consume any native APIs from Android without having to use some sort of module, they can access the entire Android API from C# when they so desire.

Edit:

[Edit]
It's a long time I don't read about Xamarin but AFAIK it's another runtime like Mono

Xamarin is built on top of Mono.

@FeralBytes
Copy link
Contributor Author

For me until C# has Xamarin, this new Java plug-in system is the way forward for me. It makes Java plug-ins much faster to create and modify then ever before.

@BenMcLean
Copy link

BenMcLean commented Nov 10, 2019

To work around not having Xarmarin, would it be possible to make a generic Java plugin that does everything that's needed?

I absolutely need to read and write external storage from C# for my project to remake Wolfenstein 3-D for the Oculus Quest. And I really do mean external storage, not the app's private storage and not resources bundled into the APK.

@BenMcLean
Copy link

Any development tools we implement have to be multiplatform, since Godot is multiplatform, and it's Microsoft's business decision to not release Xamarin development tools for Linux.

Godot's Android build templates already won't build on Windows, only on Linux. So Godot isn't really multi-platform: it's really Linux-first.

@ricardoalcantara
Copy link
Contributor

@BenMcLean

To work around not having Xarmarin, would it be possible to make a generic Java plugin that does everything that's needed?

Yes, you can do it in Java and interface with Godot using C# or GDScript (there's other ways too).

Godot's Android build templates already won't build on Windows, only on Linux. So Godot isn't really multi-platform: it's really Linux-first.

I achieve to build Android template on windows and Linux. It just not straightforward, but obliviously it's easier on Linux, windows has many issues that you have to workaround =/. But I agree it's Linux first, because they use Linux and they love FOSS, but the community maintain the other OS compatible as well. Even the Vulkan branch that's been developed on Linux Ubuntu, has other contributors committing to adjust for Windows and MacOS.

Anyway tell us more about your issue building on windows and if it is a bug you can even open an issue for that, providing more information about Version, OS, Logs and soon on. Saying it doesn't build isn't very helpful.

@BenMcLean
Copy link

Anyway tell us more about your issue building on windows and if it is a bug you can even open an issue for that, providing more information about Version, OS, Logs and soon on. Saying it doesn't build isn't very helpful.

Oh, I'm sorry, I forgot to mention that the problem there is with Mono. AFAIK, Mono doesn't build on Windows, only on Linux. You can build the regular Android build templates without C# support on Windows, but not the Godot Mono Android build templates.

I know C#, Java and a little C++. But I'm completely lost on how to make this Java plugin. I know how to ask for the permission to read external storage I need in a Java Android app, but not how to make it into a plugin for Godot and make that accessible from C#. I'm not sure how to even start researching that.

@BenMcLean
Copy link

BenMcLean commented Nov 11, 2019

Isn't being able to make calls to the Android API inherently part of what "Android support" means? I mean Godot couldn't even run on Android without being able to make Android API calls. However it is doing that should be exposed by default. I'm really confused as to why this would need a plugin when all the plugin's going to do is expose the API that should already be exposed.

@FeralBytes
Copy link
Contributor Author

@BenMcLean because in short Godot is really a Native C & C++ application, it has just enough Java integrated into it, to talk to Android for only exactly what it needs, this is done as a API between the Native C++ Godot Engine and a Java Program that supports that API, carrying out the required functions for the Engine. The same thing would have to be created in C# for Android... but my argument is that it already exists, it is called Xamarin and to use that in C# you just call using Android but that is not supported for Godot or Linux thanks to Microsoft blocking. We could re-implement the solution in C# and that may be the way forward since Microsoft refuses to lift the ban. But I don't have time for that so I will just use Java as a stop gap.

@BenMcLean
Copy link

BenMcLean commented Nov 11, 2019

After reading this, it looks like I would need some major hand-holding from someone who's done it before to make and debug any Godot Java plugin if it was ever going to happen, and I don't think anyone's going to want to take the time for that. Let me know if anyone's interested to help me out.

I think that, if I'm on my own, then I can get my app running in Unity faster than I could figure this out.

@BenMcLean
Copy link

If anyone else comes along and wants to know how to get access to external files on Android, here's how it's done on the Java side.

@neikeq
Copy link
Contributor

neikeq commented Nov 11, 2019

I can't say for certain what will be of this, but just a clarification: The reason this is not done right now is not because of any block by Microsoft. Xamarin Android, albeit not officially supported, can be made to work on Linux and, as Miguel commented, they can produce packages for Godot to use.

@neikeq
Copy link
Contributor

neikeq commented Nov 11, 2019

I'm not experienced with Xamarin Android, but I would be happy to make this happen. The reason it hasn't happened yet is simply because I have several higher priority tasks.
If anyone with enough knowledge of Godot and Xamarin Android wants to move this forward, I would recommend opening a GIP with detailed information. That would certainly help because, as I said, I'm not experienced with it.

@BenMcLean
Copy link

BenMcLean commented Nov 12, 2019

All I actually needed for my project was to request external file permissions so that the popup for it would appear, and "SomeBody3D" on Discord pointed out that this got merged 20 days ago. That exposes what I needed!

Having Xamarin would be nice for other people trying to achieve other things, but to be able to access external file storage, you just need to:

  1. Mark READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE in the Godot export options so that it will be in the manifest and...

  2. Run the Godot.OS.RequestPermisisons() method to get the user's permission before actually accessing the external file storage.

I still need to figure out how to query that the permission was granted so that my program won't try to dig into the files too early, before it actually has permission, (because program execution does not halt to wait for the permission) but this is definitely progress and shows I probably won't need to make a Java plugin for this after all.

Trying to make a plugin just for that would have been crazy!

@knuxbbs
Copy link

knuxbbs commented Feb 11, 2020

Recently I could build a Xamarin.Android application in my Linux machine, as described is this issue.

@FeralBytes
Copy link
Contributor Author

@knuxbbs I will have to try this out soon. Thanks!

@timothyparez
Copy link

Wondering if this could help: https://dev.azure.com/xamarin/public/_build/results?buildId=31493&view=results
The artifacts contain .deb packages to install Xamarin.Android on Ubuntu.

@neikeq
Copy link
Contributor

neikeq commented Dec 6, 2020

We will have to wait for .NET 6 to figure out what to do about this. It will not only be about the benefits of Xamarin.Android (like the Java/Android bindings) but also whether the way Godot does it right now is still viable with .NET 6.

@aaronfranke aaronfranke added this to the 4.1 milestone Dec 6, 2020
@ScepticDope
Copy link

@neikeq https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-1/

"We’re integrating the Android, iOS, and macOS capabilities that are part of Xamarin into .NET 6"

@neikeq
Copy link
Contributor

neikeq commented Mar 3, 2021

See godotengine/godot-proposals#2333 for possible (not yet decided) future changes that have some relation with this.

@aabmets
Copy link

aabmets commented May 24, 2021

@neikeq https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-1/

"We’re integrating the Android, iOS, and macOS capabilities that are part of Xamarin into .NET 6"

So... would it not make more sense to replace the Mono implementation of C# with .NET 6 in Godot?

@aaronfranke
Copy link
Member

aaronfranke commented May 24, 2021

@aspenforest .NET 6 is not out yet. For when it is out, read the proposal linked directly above your comment for plans.

Unfortunately, the Godot developers do not own any time machines. 😛

@BenMcLean
Copy link

BenMcLean commented May 24, 2021

Unfortunately, the Godot developers do not own any time machines.

Speaking of things the Godot developers sadly do not have, they also do not have a grant from Microsoft to continue major C# development of the Godot engine, correct?

I am sort of looking into my crystal ball to see the future by knowledge of what happened in the past. In the past, it required a large grant from Microsoft to make Godot Mono happen in the first place and since I think it would likely be a project similar in size to get away from Mono onto .NET 6, it is unlikely that Godot .NET 6 will happen unless there's a new grant for that. Or am I wrong?

Please support Godot, Microsoft! Godot Mono was great and the grant that made it possible was money well spent IMO!

@Pakrohk
Copy link

Pakrohk commented Aug 9, 2021

I have read this issue in its entirety but I still do not understand what this request wants !
https://godotengine.org/asset-library/asset/824
https://drmoriarty.github.io/nativelib/
https://youtube.com/playlist?list=PLQl2eWiUO8_K1BcuBjRRq5_z5xqkLosRu
https://youtu.be/oE-Wgy9o9q4
If xamarin is to be supported in C#, direct connectivity to the android api in GdScript and GdNative is also required.

@FeralBytes
Copy link
Contributor Author

@ALipAkrohk I built a checklist of items? If the primary stakeholders of the engine wish to close this issue they always can. In the end I wrote my own Kotlin plugins for Android and will write something for iOS if I ever ship on iPhone. C# simply is not feasible at this time and that is why the issue highlights, the new issues with .NET6 just highlights it, same as no funding from Microsoft. At this point I don't intend to touch C#, because it is still broke, unless someone can point me at things that can check off the items above.

@Pakrohk

This comment has been minimized.

@BenMcLean
Copy link

If Godot Mono was to be discontinued without a clear upgrade path to more C# development on Godot, then I'd be switching game engines for my next project to something that does C#. I might be doing that anyway, but this would make it for sure. When coding games, I want to be able to use the same real programming tools I get to use in my job writing business software: not have to completely switch languages.

@Pakrohk
Copy link

Pakrohk commented Sep 3, 2021

If Godot Mono was to be discontinued without a clear upgrade path to more C# development on Godot, then I'd be switching game engines for my next project to something that does C#. I might be doing that anyway, but this would make it for sure. When coding games, I want to be able to use the same real programming tools I get to use in my job writing business software: not have to completely switch languages.

There are two options in your content.
1 - GDscript is a very complete language and as you know it can even be used to produce software.
2 - The alternative languages I mentioned are practically better and more complete than C# in software development
I criticized the development of C# in Godot (there are many reasons, from the language development method to ...) but my main criticism was that there should be no features in the mono version but not in the official version.
There is nothing wrong with having a mono version, after all, the choice is free for the users of a free society, but not until there is a contradiction.

@YuriSizov
Copy link
Contributor

I have to remind you, that this issues section is not a discussion forum. It's a place to report and track bugs and issues in the engine. To discuss the future of C# in Godot you can, appropriately, use the aforementioned proposal godotengine/godot-proposals#2333.

In fact, this issue itself has been previously redirected to the proposal repository by @neikeq:

If anyone with enough knowledge of Godot and Xamarin Android wants to move this forward, I would recommend opening a GIP with detailed information. That would certainly help because, as I said, I'm not experienced with it.

So if Xamarin support is required for some mobile development use cases, please open a formal proposal for the missing features. As it stands, Godot Mono fully supports mobile platforms, even if you have to write platform-specific code for some platform-specific functionality in another language.

@aaronfranke aaronfranke removed this from the 4.1 milestone Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests