How to approach platform-dependent scene differences?

I was wondering how others approach differences inside scenes in different platforms, like different parameters for the components in some objects, or some components only appearing in some platforms, or whole objects, etc. Recently I made a pair of games for both mobile and VR, and the approach was to just have different scenes for each platform, something I never liked, any change has to be done in more than one scene and it can be a mess.

I’m now working on another mobile+VR project, but this time I thought about getting rid of the previous workflow and have only one scene, so I’ve been working on a tool to allow marking some objects as having different “versions” for different platforms (allowing also for other conditions in the future). The idea is that when you modify those objects and save the scene, the components’ parameters of those objects will be automagically saved and linked to the current platform, and restored when switching it (the initial idea is to automatically open the scenes, modify the marked objects, and save the scenes again when switching the platform).

However, I’m not yet sure if it will work without problems, or if it will be convenient/fast enough, or if there’s something like that already done, so I was thinking that maybe somebody has found a better approach.

Any thoughts?

1 Like

I treat it case by case.

If it’s a parameter or two then I make the script deal with it with #PLATFORM defines in the scripts to select which parameters to use

If it’s an object then I’ll often use a script that will disable or delete that object on Awake() if we’re not running on it’s required platform.

If it’s more complicated than that then I might consider loading resources based on a platform but usually the two above options are good enough and also don’t impede workflow which I consider to be the most important thing when designing any solution to a problem.

1 Like

Yeah, I have also used #if and a script to delete/disable objects at runtime, and also having different variables in the inspector for different platforms, for simple situations. I wish there was something more straightforward, or that worked fine for more complex ones.

Many years later… but I’m also thinking about this. I’m working on a VR game that should target low-end (Quest) and high-end (Index etc.).

It’d be great if there was some sort of “build tag” that I could use, or even just simply relying on the existing layer system and when building be able to select layers to be discarded in the build.

I’ve built custom build pipelines for previous Unity projects, but it becomes confusing to the team quickly, when people are used to just having to press Play or click Build and Run.

I’ve worked on big AAA studios where we had checkboxes for all entities, and you could just tick the platforms you wanted the entity to be on. The entities would automatically be stripped during the build.

The build process is more easily scripted now. You can write a function that runs on scenes during the build. In that function you can enable/disable objects or destroy them using tags, components or whatever you want.

or

Thanks @Antony-Blackett !

IProcessSceneWithReport.OnProcessScene looks interesting!