Search code examples
androidunity-game-enginesurfaceview

Porting Android SurfaceView Game to Unity Engine on Android


I have a published 2D puzzle game (require drawing 400 small images in each frame) on Android developed using SurfaceView. Due to performance issues on some tablets and phones, I am forced to look at other alternatives. It looks like Unity is the best option. Before I do this, I have several questions.

  1. Can unity provide faster and consistent performance on most of Android devices? (like drawing 400 items every frame)

  2. Can I mix Android Layouts and activities with Unity Activity. (What I mean here is can I just replace the game play part with unity keeping the existing implementation of the game using android layouts/fragments/activities)

  3. Can I call google play in-app purchases from Unity Game canvas?


Solution

  • 1.If the images are very small then it might be able to. Use the the Image or RawImage component to display each image. If performance is still bad, you can use GPU instancing which has been made more easier to use in Unity lately.

    2.You can write a Java plugin and load it from Unity or you can even write your Activity in Java with layouts and then control your Unity program from it. See this post for more information on that.

    Even though it is possible, don't do it. Only write a Java code when you have to otherwise, you will end up with a game that works on Android only. The point of using Unity is to make a Game that works on most devices. Port all your code to C#. That's what I would do.

    3.Yes, you can use google play in-app purchases in Unity with the Prime31 plugin or you can use Unity IAP that's easy to use and requires no plugin at-all.