Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. 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

Switching Project Ids with Scripting

Discussion in 'Unity Analytics' started by SimonOliver, May 17, 2016.

  1. SimonOliver

    SimonOliver

    Joined:
    Jul 16, 2007
    Posts:
    26
    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
     
  2. erika_d

    erika_d

    Unity Technologies

    Joined:
    Jan 20, 2016
    Posts:
    343
    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...f8=✓&status=0&category=analytics&view=hottest
     
  3. SimonOliver

    SimonOliver

    Joined:
    Jul 16, 2007
    Posts:
    26
    Ok, thanks for letting me know - will add this.
     
  4. Foriero

    Foriero

    Joined:
    Jan 24, 2012
    Posts:
    492
    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.
     
    erika_d likes this.
  5. erika_d

    erika_d

    Unity Technologies

    Joined:
    Jan 20, 2016
    Posts:
    343
    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.
     
  6. Foriero

    Foriero

    Joined:
    Jan 24, 2012
    Posts:
    492
    Hi, if I can change it from code in runtime then it is enough. Can you provide us link or sample code?

    Thanks, Marek.
     
  7. erika_d

    erika_d

    Unity Technologies

    Joined:
    Jan 20, 2016
    Posts:
    343
  8. kodekq

    kodekq

    Joined:
    Sep 27, 2014
    Posts:
    21
    Please write if there have been any changes since 2016?
     
  9. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    441
    I'm afraid we have not opted to make this a feature or development priority.
     
  10. kodekq

    kodekq

    Joined:
    Sep 27, 2014
    Posts:
    21
    Ok( Thanks for answer.
     
  11. jekill

    jekill

    Joined:
    Sep 17, 2015
    Posts:
    1
    I understand that this is quite difficult to do in runtime. But can it be done in build time?
     
  12. Foriero

    Foriero

    Joined:
    Jan 24, 2012
    Posts:
    492
    Yes please build time would be really helpful.
     
  13. TS-Trooper

    TS-Trooper

    Joined:
    Apr 30, 2019
    Posts:
    9
    Hi @kodekq , @Foriero , @jekill,
    About a year and some ago I was trying to achieve this as well.
    Back then I stumbled upon
    https://github.com/DragonBox/gists/blob/master/Assets/UnityUtils/Editor/UnityConnectUtils.cs

    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.
     
  14. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    186
    is there any update with Unity 2019.x ?
    how can we use Unity Analytics with multiple apps from the same project?
     
  15. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,654
    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?
     
  16. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    186
    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
     
  17. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,654
    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.
     
  18. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    186
    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...
     
  19. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,654
    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.
     
  20. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    186
    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
     
  21. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,654
    Were you able to test my suggestion? It would be a scriptable workaround in the meantime, if so.
     
  22. Foriero

    Foriero

    Joined:
    Jan 24, 2012
    Posts:
    492
    Same issue here. We export from one Unity Project 15 apps. I would definitely welcome some official solution. :)
     
unityunity