Switching Project Ids with Scripting

Hi,

We’ve got a single Unity project that outputs a number of different applications (different bundle ids), but currently it seems that there’s no easy way of modifying cloudProjectId (its set as read only). We need to modify this at build time to switch project ids for analytics etc, otherwise the various builds can’t be automated.

What is the best way to do this? I’ve tried using reflection but get "
EditorOnlyPlayerSettings property cloudProjectId::cloudProjectId not inititalized. Please initialize it using corresponding PlayerSettings.InitializeProperty function!"

Thanks,
Simon

Hi @SimonOliver ,

Unfortunately, we don’t currently have a way to change project id’s via code. Can I ask that you add this as a suggestion (or vote on the idea if it already exists) on our feedback page? I’ve seen this feature request before, but it’s good to have it’s popularity documented on the feedback page, since this is what we look at when trying to decide what new features to implement. Here’s the link to the page: https://feedback.unity3d.com/forums/unity/suggestions?utf8=✓&status=0&category=analytics&view=hottest

Ok, thanks for letting me know - will add this.

Hi Erica, we need this feature as well. we have eight apps that we are producing from one unity project. Simple API like SwithProject(id) would be really helpful.

1 Like

Hi @Foriero ,

Thanks for that information and use case! I will make note of that, and I would suggest creating an idea for it on the feedback page linked above. Right now the only one I see is for changing it at runtime, which is a bit different from build time which is what I believe you’re describing. Having your use case documented there would be very useful.

Hi, if I can change it from code in runtime then it is enough. Can you provide us link or sample code?

Thanks, Marek.

Hi @Foriero ,

We don’t currently offer changing project id at runtime, it is a request that has been posted on the feedback site: https://feedback.unity3d.com/suggestions/change-cloud-project-id-at-runtime Sorry if I wasn’t clear about that.

Please write if there have been any changes since 2016?

I’m afraid we have not opted to make this a feature or development priority.

Ok( Thanks for answer.

I understand that this is quite difficult to do in runtime. But can it be done in build time?

Yes please build time would be really helpful.

Hi @kodekq , @Foriero , @jekill ,
About a year and some ago I was trying to achieve this as well.
Back then I stumbled upon

It has been working quite nicely.
Until recently. Somehow it does not always do the switch correctly. For us this is a problem, because we build the project in batchmode.
When I have Unity open and I use it though it works nice.
I thought you might like it as well.

Also, if you happen to find a fix for the switch not always switching correctly (at least in batchmode) please let me know how I’d be able to fix it.

is there any update with Unity 2019.x ?
how can we use Unity Analytics with multiple apps from the same project?

Sorry there is no API that I’m familiar with. Can you elaborate? The Analytics dashboard is associated with the ProjectID. Multiple projectIDs would have multiple Dashboards. If you are considering multiple apps with one projectID, what is your plan to keep them separate? Would these be separate apps on the Google developer dashboard, each with their own revenue stream?

we have a big (even opensource) project ( https://www.antura.org ) from which we build 7 different apps, with their own bundle id and store presence (for example one teaches arabics, another teaches english, another french… we have some particular editions for foundations etc)

in our case we don’t have IAP nor complex things… we are using the Unity Cloud Builder for everything (with custom cunfigs) but we would really like to separate the Unity Analytics changing the project id at build time… we could do it manually (unlinking and relinking another project)…
we have used Google Analytics forst, then Firebase, then Facebook Analytics… but now we would like to use Unity for everything… but we have this obstacle with the Unity Analytics ids!

thank you

Given a single ProjectID, how would you keep the apps separate in your reporting? Number of users per day, etc. All 7 apps would share the same Analytics data and would show as one app in the Dashboard. Perhaps that doesn’t matter to you, but I wanted to point it out.

we want to CHANGE ProjectID at build time… so to assign each “edition” of our game its own analytics and stuff.
we have one Unity Repository for 7 independent App editions…

1 Like

Ah, clearly. I see what you mean. Sorry I don’t have a definitive answer for you. One approach I might suggest would be to start with a new project, and take a snapshot of the file structure in the project after Saving. Then change the ProjectID link in the Services window, then go back and see which files may have changed. Not entirely elegant and no API, but you may be able to edit the files during your build process. You may have to first generate 7 ProjectID’s this way, so each has their own Dashboard.

2 Likes

thank you.
we are going to create a Unity Project for every published edition on the Store… and manually relink the correct one when building an edition.
if you plan to allow to “switch” easily, maybe by preBuildProcess, the UnityId, even better!!!
thank you