Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. We are looking for your feedback about Templates! Tell us about your experiences by taking our survey.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted How to manage different scenes for different platforms?

Discussion in 'Editor & General Support' started by DevDunk, Jan 23, 2021.

  1. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    9
    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?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    12,083
    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
    :

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

    That file is read by:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class configure : UnitySingleton<configure>
    5. {
    6.     public bool TV;
    7.     public bool PC;
    8.     public bool WebGL;
    9.  
    10.     public bool CTRLR { get { return TV; }}
    11.     public bool Monitor { get { return TV || PC || WebGL; } }
    12.  
    13.     public bool hasKB { get { return Application.isEditor || PC || WebGL; } }
    14.     public bool hasTouch { get { return !TV && !PC && !WebGL; } }
    15.  
    16.     public bool CanUseKeyboardOrJoystick { get { return TV || hasKB; } }
    17.     void Awake()
    18.     {
    19.         TV = false;
    20.         PC = false;
    21.         WebGL = false;
    22.  
    23.         TextAsset ta = Resources.Load<TextAsset>("kurtconfig");
    24.         if (ta != null && ta)
    25.         {
    26.             if (ta.text != null && ta.text.Length >= 2)
    27.             {
    28.                 if (ta.text.StartsWith( "tv"))
    29.                 {
    30.                     TV = true;
    31.                 }
    32.                 if (ta.text.StartsWith( "pc"))
    33.                 {
    34.                     PC = true;
    35.                 }
    36.                 if (ta.text.StartsWith( "web"))
    37.                 {
    38.                     WebGL = true;
    39.                 }
    40.             }
    41.         }
    42.     }
    43. }
    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:

    Screen Shot 2021-01-23 at 4.22.10 PM.png

    Yes, I have quite a few remotes as backups. :)
     
    DevDunk and Marc-Saubion like this.
  3. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    9
    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?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    12,083
    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.
     
    DevDunk likes this.
unityunity