问题
If I wrote a game in LibGdx and wanted a shared (reusable in the future) part, then I'd write a library in Java and install it to a local Maven / Gradle repository. End of story.
What if I'm using Unity?
- Do I have to code in C#?
- Do I have to use VisualStudio / Unity IDE / ... to develop the code?
- How to make it shared among my projects?
回答1:
Unity provides a way to export unitypackages that can help to distribute assets between projects and an assets server that works almost equals to maven repository (you can see unity store to have an idea).
You will need Unity IDE to pack as unitypacks but it is not restricted to language or external code editors (You code where you find more confortable and using C# or US doesn't matter but to inport/export packages you will need UnityEditor).
This packages are not restricted for code assets it packs any kind of asset supported by unity (also DLLs and plugins).
ps: just to remember that unity doesn't provide a java language support is just C# and UnityScript today, this last one frequently associated to JavaScript or mistaken for Java.
回答2:
This document from Unity might help:
http://docs.unity3d.com/Manual/Plugins.html
http://docs.unity3d.com/Manual/UsingDLL.html
http://docs.unity3d.com/Manual/NativePlugins.html
来源:https://stackoverflow.com/questions/31596022/how-to-develop-shared-code-for-a-unity-project