npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jp.masakura.unity.build.helper

v0.9.0

Published

A collection of useful helper classes for Unity builds.

Downloads

11

Readme

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

Switch BuildTarget

using UnityEditor;
using Ignis.Unity.Building.Platforms.Extensions;

// ...

BuildTarget.Android.Switch();

In batch mode, switching is not possible due to Unity Editor restrictions. Trying to switch from Android to iOS will throw an exception. However, it does not throw an exception when there is no switch, such as from Android to Android.

Executes arbitrary code after switching the BuildTarget.

BuildTarget.Android.Switch()
    .WithCallback(context => {
        Debug.Log(context.Success);
        
        // ...
        
        context.ExitEditorIfBatchMode(0);
    });

The callback is invoked even when the switch did not occur, such as from Android to Android or due to some reason that the switch could not be made. context.Succeeded only returns false when the EditorUserBuildSettings.SwitchActiveBuildTargetAsync() method calls false.

When handling the code after the switch within batch scope.

BuildTarget.Android.Switch()
    .WithCallback(context => context.InBatchScope(() => {
        BuildPipeline.BuildPlayer(
            // ...
        )
    }));

When running the coroutine in batch scope.

BuildTarget.Android.Switch()
    .WithCallback(context => context.InBatchScope(
        Coroutine()
    }));

IEnumerator Coroutine()
{
    // ...

    yield break;
}

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