Skip to content

Conversation

krisrok
Copy link

@krisrok krisrok commented Aug 8, 2025

Expects a editor script with in the format of:

UnityLauncherProToolsCustom.BuildCustom, e.g.:

using System.Diagnostics;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
public static class UnityLauncherProToolsCustom
{
    [MenuItem("Tools/Build custom")]
    public static void BuildCustom()
    {
        var settings = new BuildPlayerOptions();
        settings.scenes = GetScenes();
        settings.locationPathName = Path.GetFullPath(Path.Combine(Application.dataPath, "..", "..", "..", "Build", PlayerSettings.productName + ".exe"));
        settings.target = EditorUserBuildSettings.activeBuildTarget;
        var report = BuildPipeline.BuildPlayer(settings);
        if (report.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
            Process.Start(Path.GetDirectoryName(settings.locationPathName));
    }

    static string[] GetScenes()
    {
        return EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(scene => scene.path).ToArray();
    }
}

Expects a editor script with in the format of:

```cs
using System.Diagnostics;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
public static class UnityLauncherProToolsCustom
{
    [MenuItem("Tools/Build custom")]
    public static void BuildCustom()
    {
        var settings = new BuildPlayerOptions();
        settings.scenes = GetScenes();
        settings.locationPathName = Path.GetFullPath(Path.Combine(Application.dataPath, "..", "..", "..", "Build", PlayerSettings.productName + ".exe"));
        settings.target = EditorUserBuildSettings.activeBuildTarget;
        var report = BuildPipeline.BuildPlayer(settings);
        if (report.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
            Process.Start(Path.GetDirectoryName(settings.locationPathName));
    }

    static string[] GetScenes()
    {
        return EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(scene => scene.path).ToArray();
    }
}
```
@unitycoder
Copy link
Owner

thanks ill check!

question:
so i guess there is no easy way to check if that custom build script is available?
unless its in some fixed path Assets/Editor/UnityLauncherProToolsCustom.cs,
then could disable that menu item, if not available.

@unitycoder
Copy link
Owner

unitycoder commented Aug 24, 2025

i'm thinking that this could have a settings field, for your own custom script to use for Builds.
And if the field is empty or no checkbox enabled, then it uses the current builtin one.

  • although then you cannot have different script per project.. so probably cannot do that.. ok skip this comment.

like init script:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants