Multiplatform dev iOS/Web/desktop, platform specific changes?

Hello,

I’m developing a game that was originally designed for desktops but would now be a perfect with for the new touch screen devices. While I’ve got pretty much everything rolling in Unity and working properly, I noticed that some of my assets must definitely be customized for different platforms.

For example in my tutorial I have text that refers to clicking with a mouse and images of the same thing. I’m thinking of changing those bits to refer to touch screen and fingers. This could wither be a simple swap of material during the run-time or might require repositioning the image, but in that case I would have to package the extra assets in all builds without ever using them in some.

Another important case would be my UI that needs to be radically different for mobile phones vs. desktops. Making a different scene with some different assets (background image etc.) solves the problem, but can I exclude certain scenes from certain platforms and vice versa? I wouldn’t want to make a duplicate Unity project for obvious reasons.

Any comments/thoughts would be greatly appreciated! I’ll be posting a pre-release version here on the forums when it’s done enough:)

tl;dr Is there a neat way to only include certain assets/objects/prefabs/scenes for one build target, but not the others?

Bumping this thread. I have a slightly different reason for needing this, but what I’d really like to do is have a different set of scenes per platform. That way I can keep the whole project under the same version control system.

My only alternative to having this feature is to manually change the scenes just before building for each platform. This is fraught with errors, and it seems that it would be a simple fix to allow one to change the scenes on a per platform basis.

Any other ideas of how to deal with this?

= Ed =

I have a simple component that merely hides the game object on unsupported platforms. It’s stupid, its simple, but best of all it works perfectly. Multiple scenes will work but that is the way you introduce bugs and inconsistencies.

//hide if not the right platform


#pragma strict
@script AddComponentMenu("Hide by platform")


var hideIfSlow:boolean;
var hideOnWindows:boolean;
var hideOnMac:boolean;
var hideOnIphone:boolean;
var hideOnAndroid:boolean;
var hideOnOuya:boolean;


function Awake()
{


    if (hideIfSlow)
    {
        gameObject.SetActiveRecursively(false);
    }


    if (hideOnWindows  Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor)
    {
        gameObject.SetActiveRecursively(false);
    }


    if (hideOnMac  Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor)
    {
        gameObject.SetActiveRecursively(false);
    }


    if (hideOnIphone  Application.platform == RuntimePlatform.IPhonePlayer)
    {
        gameObject.SetActiveRecursively(false);
    }


    if (hideOnAndroid  Application.platform == RuntimePlatform.Android)
    {
        gameObject.SetActiveRecursively(false);
    }


    //unfinished
    if (hideOnOuya  Application.platform == RuntimePlatform.Android)
    {
        gameObject.SetActiveRecursively(false);
    }
}

That sort of thing. Probably don’t need recursively if on 4.x

Thanks hippo. That is some nice code there that I may yet use. However, we actualy have whole scenes that are not appropriate on certain platforms for what we are doing. I guess we will have to live with manually selecting the scenes for building - at least for the time being.

Thanks again for the quick response and sweet code.

= Ed =