jp.masakura.unity.build.helper

0.8.0 • Public • Published

Unity Build Helper

A collection of useful helper classes for Unity builds.

Install your unity project

Install from npmjs

Add npmjs registry to Packages/manifest.json in your Unity project.

{
  "scopedRegistries": [
    {
      "name": "npmjs",
      "url": "https://registry.npmjs.com",
      "scopes": ["jp.masakura.unity"]
    }
  ],
  "dependencies": {
    // ...
  1. Open Package Manager Window with Your Unity project.
  2. Click +, select Add package by name...
  3. entry jp.masakura.unity.build.helper
  4. Click Add

Install from GitLab

  1. Open Package Manager Window with your Unity project.
  2. Click +, select Add package from git URL...
  3. entry https://gitlab.com/ignis-build/unity-build-helper.git?path=Packages/jp.masakura.unity.build.helper
  4. Click Add

Features

Temporary settings

Temporarily modify Unity build-time settings.

using (var settings = new TemporarySettings())
{
    // Property.
    settings.SetValue(() => PlayerSettings.usePlayerLog, false);

    // Getter method.
    settings.SetValue(() => PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.Android), "com.example.app1");

    // Modify symbol.
    settings.Symbol(() => PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Android),
        symbols.Add("DEBUG").Remove("LOGO"));

    BuildPlayer.BuildPipeline(/* ... */);
}
// When the Dispose() method is called,
// the setting values are reverted to their original values.

Signing settings

You can temporarily set code signing for Android and iOS.

// temporary siging settings for Android.
settings.Android().Signing(AndroidSigning.Manual(
    "path/to/app.keystore",
    "keystore password",
    "alias name",
    "alias password"
));

// temporary unsigned settings for Android.
settings.Android().Signing(AndroidSigning.Unsigned());
c
// The Signing Settings in PlayerSettings will be used as they are.
settings.Android().Signing(AndroidSigning.UsePlayerSettings());

// temporary auto signing settings for iOS.
settings.iOS().Signing(iOSSigning.Auto("apple developer team id"));

// temporary manual signing settings for iOS.
settings.iOS().Signing(iOSSigning.Manual(
    "apple developer team id",
    ProvisioningProfileType.Distribution,
    "provisioning profile uuid"
));

// The Signing Settings in PlayerSettings will be used as they are.
settings.iOS().Signing(iOSSigning.UsePlayerSettings());

It is also possible to handle the signing settings for both Android and iOS together.

var signing = new CodeSigning(
    AndroidSigning.Unsigned(),
    iOSSigning.Auto("apple developer team id")
);

// The signing settings for both Android and iOS will be changed.
settings.Signing(signing);

// The Signing Settings in PlayerSettings will be used as they are.
settings.Signing(CodeSigning.UsePlayerSettings());

Batch scope

After the process execution, the Editor will be closed if it's in batch mode.

[MenuItem("Batch/Task")]
public static RunTask()
{
    // Normal method.
    BatchScope.Run(() => { YourTask(); });
}

[MenuItem("Batch/Coroutine")]
public static RunCoroutine()
{
    // Coroutine.
    BatchScope.Run(YourCoroutine());
}

When running within -batchmode, -quit is not necessary.

$ /path/to/Unity -batchmode -executeMethod Batch.RunTask

Scene helper for BuildPipeline.BuildPlayer()

It manages the scenes specified for BuildPipeline.BuildPlayer().

var scenes = UnityScenes.All()
    .MoveToPrimary(By.Name("Debug")) // Set Debug scene as the primary scene.
    .OnlyEnabled(); // Enabled scene only.

BuildPipeline.BuildPlayer(
    scenes,
    // ...
);

xcodebuild

Run xcodebuild using coroutine.

var xcodeBuild = new XcodeBuild()
    .WithWorkingDirectory("/path/to/directory");
EditorCoroutineUtility.StartCoroutineOwnerless(
    xcodeBuild.Run(args => args.Add("-projectPath", "/path/to/project"))
);

It can also be used in combination with BatchScope.

BatchScope.Run(
    xcodeBuild.Run(args => args.Add("-projectPath", "/path/to/project"))
);

Xcode project

var project = new XcodeProject("/path/to/xcode/project");

EditorCoroutineUtility.StartCoroutineOwnerless(
    project
        .Archive("/path/to/project.xcarchive", args => args
            .Configuration("Release")
            .UnityScheme())
        .Export("/path/to/export/directory", "/path/to/ExportOptions.plist")
); 

Archive zip

Archive Xcode archive and Xcode export into zip.

var project = new XcodeProject("/path/to/xcode/project");

EditorCoroutineUtility.StartCoroutineOwnerless(
    project
        .Archive("/path/to/project.xcarchive", args => args /* ... */)
        .Zip("/path/to/project.xcarchive.zip")
); 

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i jp.masakura.unity.build.helper

Weekly Downloads

4

Version

0.8.0

License

MIT

Unpacked Size

90.8 kB

Total Files

153

Last publish

Collaborators

  • masakura