You can build you own player from script, for example :
var target = BuildTarget.StandaloneWindows; var options = BuildOptions.AutoRunPlayer; PlayerSettings.runInBackground = true; PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled; BuildPipeline.BuildPlayer(EditorBuildSettings.scenes.Select(scene => scene.ToString()).ToArray(), CaptivateRunner.PathName + "runner.exe", target, options);
I was calling this from a editorwindow and the weird thing was that i always got a GUILayout error.
After trying to find all possible ways to prevent this from happening i finally figured it out.
use : EditorGUIUtility.ExitGUI(); after the buildplayer command to prevent this error!!!