Why is PlayerSettings.cloudProjectId read only? I can easily set PlayerSettings.productName, PlayerSettings.bundleIdentifier etc, but not cloudProjectId. Before 5.1 integrated analytics you could easily change it when building app now it seems to be impossible. Is there any other way to do it?
Hi @ortin ,
How are you attempting to change the PlayerSettings.cloudProjectId? In 5.1 you should be able to change it by going to Edit â Project Settings â Player, then in the Inspector window you should be able to edit the id.
From code.
Something like this:
private static void BuildIPhone() {
PlayerSettings.productName = "@{productName}@";
PlayerSettings.bundleIdentifier = "@{bundleIdentifier}@";
//PlayerSettings.cloudProjectId = "@{cloudProjectId}@";
BuildPipeline.BuildPlayer(new[] { "@{SCENES_LIST}@" }, "@{BUILD_PATH}@", BuildTarget.iOS, BuildOptions.SymlinkLibraries);
}
Hi @ortin ,
As of 5.1 the best way to change the cloudProjectId is through the Inspector window.
What are you trying to accomplish by changing the cloudProjectId, or what is the circumstance where you want to change it?
I have multi-game project inside one unity project (itâs heavily based on common code/resources). So during build build-script separates this games (deletes everything except of common based and game_name based) and then builds using method I showed in the previous post.
Another usage for it is to have different ids for test and release builds.
Anyway for now I resorted to replacing cloudProjectId: xxx in ProjectSettings.asset, but having real property looks less âhackishâ for me.
I too generate different apps from a single project - think for example a version of the app being Free2Play and one being a Paid App.
Hence, there is a need to access âPlayerSettings.cloudProjectIdâ from Script to set it accordingly to the version of the app, either when the app boots or to put the information in a custom build script.
Ortin, could you post a snippet how you replace the id in the ProjectSettings.asset?
-act
Just posting another request for this ability and the ability to turn off Unity Analytics altogether if necessary (possibly with a blank cloudProjectId).
@ortin , @actraiser3 , @sirrus ,
These are great suggestions and it appears as if there is a demand for them. You can vote for them to be added as features here, http://feedback.unity3d.com/forums/unity/suggestions?utf8=â&status=0&category=analytics&view=hottest
I use text serialization and Gradle for build script so I just replace "cloudProjectId: " with âcloudProjectId: xxxxâ using ant.replace.
Probably the same can be done inside of Unity by just using pure c# to replace string in file.
Here is a very valid use case:
We build our app for different environments like DEV, QA, STG, PROD and we want all those environment builds have different cloud project id for analytics purposes.
We use PreExport method on cloud build to be able to process some differences on the app according to selected environment and we also want to be able to modify cloud project id inside PreExport method without modifying the ProjectSettings.asset fileâs text via IO operations.
Please let me know if you implement an API for altering (link/unlink) cloud project id in UnityEditor namespace in the future.
Hi @Xtro , while we donât support changing the Cloud Project ID for different build targets, on iOS and Android you can change the Bundle ID for different build targets, and then use the Bundle ID for segmentation in the Unity Analytics dashboard. I know itâs not exactly what you are looking for, but it might work for your use case. Hope that helps.
Cloud Build dashboard (Signing Creds for Build Target):
Unity Analytics dashboard (Segment Builder):

How about performance reporting tool?
That is a good point / question. The Performance Reporting service does not currently support filtering by Bundle ID. Feel free to add a feature request at https://feedback.unity3d.com/
Here is a quick snippet allowing to edit the ProjectSettings.asset file in a build script.
const string projectSettingsPath = "ProjectSettings/ProjectSettings.asset";
var projectSettingsString = File.ReadAllText(projectSettingsPath);
var match = new Regex(@"cloudProjectId: \s*([^\s]+)").Match(projectSettingsString);
if (match.Success)
{
string cloudProjectId = match.Groups[1].Value;
string desiredCloudProjectId = useId1 ? "xxx-xxxxxxx-xxxx-xxxx" : "yyyy-yyyyyyy-yyyyy-yyyy";
projectSettingsString = projectSettingsString.Replace(cloudProjectId, desiredCloudProjectId);
File.WriteAllText(projectSettingsPath, projectSettingsString);
CloudProjectSettings.RefreshAccessToken(null);
}
else
{
Debug.Log("cloudProjectId could not be found");
}
Could you add any necessary Using statements too? Otherwise, thanks!
Could we get an official API for this? Instead of text search and replace hacks?
We have 3 versions of our game. Global, China, Beta. We want each to have its own set of Analytics, Diagnostics, etc. This is surely enough of a common use case in âreal gamesâ that publish globally - at the very least the Global/China build separation. I suspect that must be fairly common.
Every plugin we have in the project thus far - Google Play Games SDK, Facebook SDK, Flurry, Photon, Adjust, Iron Source - plays nicely and allows us to configure the project ID equivalent at build time. Would be great if Unity could catch up too.
Unity Feedback site was deleted 2 years ago along with all the feedback that was posted (including the one linked above) and there is no replacement except forum posts, so here we are.
There currently is not an API for this, I donât believe there are any immediate plans. We are moving to the deltaDNA API over the next year, I will bring this up for that effort.
Is there any more details on the move to deltaDNA ? Which of Unitys existing services will shift there?
Just Analytics https://unity.com/products/deltadna
