I am attempting to generate a build via BuildPipeline.BuildPlayer with the Android Internal Profiler enabled (so I can see the performance data in adb logcat).
This works if I enable the “Enable Internal Profiler” checkbox in the GUI first, but I would like to leave the setting disabled (so it’s saved that way in source control) and then only update the local copy via script. There is a hacky way to do this by editing the ProjectSettings.asset file directly and changing the value of AndroidProfiler from 0 to 1, but that’s not an option when the project is using binary data files (which I need to support).
I have tried the SetPropertyInt method that I’ve seen being used to enable iOS x64 support, but that doesn’t seem to be working for this setting. There’s nothing built directly into the API that I can find.
Anyone know the correct way to do this?
I’m using Unity 4.6.x series, specifically testing this with 4.6.5.
You could try to use custom editor scripting code for modifying that value:
using System.Collections;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEngine;
public class Test
{
[MenuItem("Tools/Set Android Internal Profiler")]
public static void SetAndroidInternalProfiler ()
{
var ps = Resources.FindObjectsOfTypeAll<PlayerSettings>();
var so = new SerializedObject(ps);
var sp = so.FindProperty("enableInternalProfiler");
sp.boolValue = true;
so.ApplyModifiedProperties();
}
}
I actually have no idea whether that works or not…
This code basically looks up any loaded object of type PlayerSettings (in which this setting is strored).
It when grabs the appropriate property and changes its value.
Not sure whether this actually does anything or not: trying to print the current value for this setting seems to be incorrect, so i am not sure whether this code actually does what you want.
i’m also trying to accomplish this either by setting it via code or passing a preprocessor value…neither of the properties you mention “enableInternalProfiler” nor “AndroidProfiler” exist in the PlayerSettings for 4.6…the value is in project settings which I dont seem to be able to get at during build time…also just passing a pre-processor define doesnt seem to enable it…anyone from Unity want to chime in on how to enable this during a build script (like for a build machine that is building a “profile” version)
so you’re setting a pre-pro define on the command line and then checking in your builder script and then setting the flag with property setter/getter? or are you using the script code and applying the change to the property?
i was looking for something like “DevelopmentBuild” or “ConnectWithProfiler”, which when passed as a build option, do the things I want it to…granted those are probably going to the “build settings” so i might have to pass my own flag on the command line, check it and enable the profiler via the snippet.
edit: i tried passing my own flag, that was easy enough, but trying to set the enableInternalProfiler does not work…i tried
if (PlayerSettings.enableInternalProfiler == false)
and that did not return false (was definitely off in the scene)…i then tried
and that yielded errors like
EditorOnlyPlayerSettings property enableInternalProfiler::enableInternalProfiler not inititalized.
and trying to set it similarly yielded
EditorOnlyPlayerSettings property enableInternalProfiler::enableInternalProfiler not inititalized. Please initialize it using corresponding PlayerSettings.InitializeProperty function!
i was trying to avoid applying any changes to the project that might be stuck after a build (by a build machine for example).
edit2: i did see the AndroidPlayer value in the ProjectSettings.asset file, in the PlayerSettings section, and tried setting it via the find & set property, and it did find it, did enable the profiler, and it did modify the projectsettings.asset file…so i guess as long as a build machine doesnt commit changes it’s “okay”, just not my ideal…thanks