Search Unity

Custom Build Script with enabled profiling

Discussion in 'Scripting' started by RARgames, Mar 22, 2018.

  1. RARgames

    RARgames

    Joined:
    Aug 25, 2017
    Posts:
    39
    I'm making custom build script for my game. (for easier testing on android device)

    What I want to achieve?
    - Same effect as going to build settings, checking development build and autoconnect profiler.
    Than clicking build and run. My game builds and when I switch from Editor to Android Player in console/profiler I can see logs from my phone and profiler running.

    I tried changing:
    Code (CSharp):
    1. EditorUserBuildSettings.development = true;
    2. EditorUserBuildSettings.connectProfiler = true;
    and than:
    Code (CSharp):
    1. BuildPipeline.BuildPlayer(buildPlayerOptions);
    with other custom options, but it does not work as I want.
    I cannot see mobile profiler and logs and when I switch from editor to android player it automatically goes back to editor.
    What am I missing?
     
    indiana_toms likes this.
  2. RARgames

    RARgames

    Joined:
    Aug 25, 2017
    Posts:
    39
    The answer is:
    Code (CSharp):
    1. BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
    2. buildPlayerOptions.options = BuildOptions.AutoRunPlayer | BuildOptions.Development | BuildOptions.ConnectWithProfiler | BuildOptions.AllowDebugging;
    3. BuildPipeline.BuildPlayer(buildPlayerOptions);
    This has to be included in script, it was hard for me to find in docs.
     
  3. mithun_movai

    mithun_movai

    Joined:
    Aug 16, 2019
    Posts:
    1
    @RARgames

    Awesome dude, thanks. Can you tell me how to connect once I run the build? I opened the profiler in the Editor but nothing is happening when I run the build. Thank you
     
    ArsenGamedev likes this.
  4. tgrotte

    tgrotte

    Joined:
    Apr 17, 2019
    Posts:
    25
    I think the point is to run from the built player- not in the Editor. When launching the application after building with these options the Profiler should automatically connect.