TL;DR: My game should be different on PC and phone, can i manage these different version without just making multiple unity projects ?
Hello,
I am creating a game but i want some features to be different depending on the platform, i want it to be avaible from mobile but also from PC. But i have some differences:
- UI: on PC, the inventory and the shop should be always visible, on phone i want two buttons to open them, with of course lot of other differences in elements size, position…
- Ads: i want the phone version of my game to have a banner ad on the bottom on the screen
- Gameplay mechanics: i want on the phone version to have multiple event that randomly spawn, which grants bonuses (currency, boosters…) to the player after he watch an ad, i can only display ads on mobile so the events should only be avaible on mobile.
- Real currency: i want a real currency shop, but i think it’s coded differently on computer and mobile.
What’s the best option for me now ?
- Create the base game, then clone the folder and the repository so i have one for PC, one for mobile, and then implement the platform related features separately.
- Same as above, but instead of different git repositories, git subrepositories.
- Multiple git branches.
- Something else ??
The problem with the two first methods is that if i want to implement a new feature that is not platform related, i need to code it on a project and then copy it into another, is there a better way for doing this ?
Thanks !
>Solution :
Yes, you should be able to manage different versions of your game for PC and mobile platforms within the same Unity project. You can use #if UNITY_EDITOR, #if UNITY_STANDALONE, #if UNITY_ANDROID, #if UNITY_IOS, etc., to conditionally compile code for different platforms. Have a look at Platform Dependent Compilation in the Unity documentation.