Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by emthele · Jan 21, 2017 at 06:45 AM · androidbuildwindowscrossplatform

Crossplatform Windows and Android: How to share same codebase?

Hello everyone,

we're developing a GUI in Unity which shall be deployed on Windows and Android. Currently there's only 1 scene. We need to have the same scripts for both versions, including input control and so on. We're changing the behaviour on input or serial port communication via defines at the moment.

The problem is the different layout. We need a different project - or at least scene - for the Android version compared to Windows version. It's only one developer (me), so there's no team for testing stuff forth and back. I would work on Android version for let's say 2 weeks and then go back to Windows version. All improvements and changes should apply to the other version with very small effort.

Is there any possibilty to do that quickly? My idea by now is to have just 2 different scenes for the layouts and then use the "Advanced Builder" asset: https://www.assetstore.unity3d.com/en/#!/content/13624 for compilation. I have to deploy the compiled "game" on Android each time for testing anyway, as the performance and the bluetooth communication play the main role, not the touch input.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by emthele · Feb 24, 2017 at 09:50 AM

Hi there,

firstly, I'm (again) a bit disappointed that Unity seems to ignore their own forum completely and never provide answers to these commonly asked questions. Anyway, I wanted to update for anyone who might be interested.

What happened in the last months was that we were working on the standalone version alone, so no cross platform switching. As it became important recently, our solution will probably be to use the genius technique from this blog: http://blog.deozaan.com/2014/09/22/fast-platform-switching-in-unity-made-easier/

With the difference that we won't keep all our assets as a junction, but our codebase. This basically even avoids the synching process and just shares the exact codebase in two different projects.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by blaineL · Feb 27, 2017 at 02:33 PM

Hi @emthele,

You should be able to use the same scene on both Android and Windows. Of course switching between the builds allows you to see the layout in the Game setting with out compiling. It's important that you make prefabs of everything. That way any changes you make are automatically updated across scenes/platforms.

As for the scripting side, 'defines' are the way to go. The easiest is the create defines that call your separate communication classes or functions. You might also want to look at some of the tools out there that can handle input for you (you can also define your own input). If you have time, check out Rewired Input Manager. If you can have your input to work with their system, it greatly simplifies things - especially if you want to go to iOS, Apple TV, etc... in the future.

PS: I had another question for you on 'Quaternion from IMU sensor to GameObject Orientation problem', but I couldn't respond because it was closed. Mind if I ask you an additional question?

  • Blaine

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by gabriellp21 · Feb 28, 2017 at 07:46 AM

Something that i had in mind is to make different UI versions as prefab and load them depending on platform you building. But it's not enough, it will required some adapter architeture to abstract the input of the platform in question to the base game functions. I made some tests and just was needed some scripts to hack canvas aligments and some components fit to their relative position.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image blaineL · Feb 28, 2017 at 06:10 PM 0
Share

Nothing is ever perfect ;) When starting out I found 'Easier UI' to help with UI alignments.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using a PC Oriented code to make an Android Build. 1 Answer

Distribute terrain in zones 3 Answers

Error building APK 2 Answers

Question about Network.Destroy 0 Answers

How Add Files In A .apk Android Build 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges