How to manage different scenes for different platforms?

I have been wondering how to manage different scenes for different platforms.
I understand that a lot of stuff can be managed for graphics with quality presets, but for my VR game, I want to have 1 scene with 1 different part being just 1 changed game object.
Using Git branches is pretty much out of the question I think and using multiple scenes would work, but it might be annoying to copy over the objects each time.
I did get something to work with prefabs, but it felt more like a workaround.

Do people have experience with this to target different platforms?

I just have a master switchboard class that goes to the correct scene.

For instance I have a method in there called GotoMainMenu() and on iPhone / Android it will go to a mainmenu scene that has buttons on it. When it runs on my Android TV (or other console targets) it goes to another mainmenu scene that operates via controller.

I use git branches for platforms but I only change the tiniest barest minimum of files, usually just a single text file (kurtconfig.txt) that indicates the target branch, and I have my configuration program read that.

Otherwise I do ALL work in master.

Here’s the diff on that file from master (phone/tablet) to tv:

6758155--780139--Screen Shot 2021-01-23 at 4.17.58 PM.png

That file is read by:

using UnityEngine;
using System.Collections;

public class configure : UnitySingleton<configure>
{
    public bool TV;
    public bool PC;
    public bool WebGL;

    public bool CTRLR { get { return TV; }}
    public bool Monitor { get { return TV || PC || WebGL; } }

    public bool hasKB { get { return Application.isEditor || PC || WebGL; } }
    public bool hasTouch { get { return !TV && !PC && !WebGL; } }

    public bool CanUseKeyboardOrJoystick { get { return TV || hasKB; } }
    void Awake()
    {
        TV = false;
        PC = false;
        WebGL = false;

        TextAsset ta = Resources.Load<TextAsset>("kurtconfig");
        if (ta != null && ta)
        {
            if (ta.text != null && ta.text.Length >= 2)
            {
                if (ta.text.StartsWith( "tv"))
                {
                    TV = true;
                }
                if (ta.text.StartsWith( "pc"))
                {
                    PC = true;
                }
                if (ta.text.StartsWith( "web"))
                {
                    WebGL = true;
                }
            }
        }
    }
}

There are no other changes in the codebase between branches. All work is done in master and then merged to tv, pc, webgl branches as released.

I made a release of Jetpack a few days back, master, tv and pc, so my git branches look like:

Yes, I have quite a few remotes as backups. :slight_smile:

2 Likes

Is there a specific way how you port new features from one scene to another or do you just copy them over after it is done?

And I wonder how much having different scenes in the game without being used will change file sizes. Got any issues with that?

If there are common features I put them in another scene and load them additively on top of the correct platform scene.

For instance, these might be the two mainmenu scenes:

  • mainmenu_touch
  • mainmenu_tv

But both of them additively load and overlay:

  • mainmenu_last_score_display
  • mainmenu_attract_mode_animations

I try to never duplicate anything, especially UI.

1 Like