Build Versions Scripting API

βœ… Assemblies


All the code in this asset is under assembly definitions. This helps with compile times for your code. If your code is also in an assembly definition you will need reference the assembly/assemblies to access the code for this asset. The assemblies are:

CarterGames.BuildVersions

CarterGames.BuildVersions.Editor

For accessing the runtime code of the asset.

For accessing the editor code of the asset.


🚩 Namespaces


All code for this asset is under the following namespace(s):

// Editor Logic
CarterGames.Assets.BuildVersions.Editor

// Runtime Logic
CarterGames.Assets.BuildVersions

πŸŽ—οΈ Scripting


πŸ“— Runtime


🟒 Build Information


Properties

BuildType

Int

Gets the β€œtype” the build is set as by you.

var buildInfo = AssetAccessor.GetAsset<BuildInformation>();
Debug.Log(buildInfo.BuildType);

BuildDate

String

Gets the date that the last build was made as a string.

var buildInfo = AssetAccessor.GetAsset<BuildInformation>();
Debug.Log(buildInfo.BuildDate);

BuildNumber

Int

Gets the current build number, this is the unique number not the player settings number.

var buildInfo = AssetAccessor.GetAsset<BuildInformation>();
Debug.Log(buildInfo.BuildNumber);

SystematicVersionNumber

String

Get the current version number, this is the number in the player settings.

var buildInfo = AssetAccessor.GetAsset<BuildInformation>();
Debug.Log(buildInfo.BuildNumber);

🟒 Asset Accessor


Methods

GetAsset<T>

BuildVersionsAsset<T>

Gets a scriptable object of the type requested. This only works with the build version assets.

public void ExampleMethod()
{
		var info = AssetAccessor.GetAsset<BuildInformation>();
}

πŸ“— Editor


🟒 Build Handler


ℹ️
Use BuildVersionsEditorUtil.GetClassName<T>() to get the class name for the handler dialogue data class type.

Methods

Register(HandlerDialogueData)

void

Registers a class into the handler system when a build is made.

BuildHandler.Register(new HandlerDialogueData(BuildVersionsEditorUtil.GetClassName<AndroidBundleCodeUpdater>(), true));

Get<T>()

HandlerDialogueData

Gets a handler data to use.


Clear()

void

Registers a class into the handler system when a build is made.


🟒 Handler Dialogue Data


ℹ️
A struct holding data for the build handler system.
ParamTypeDescription
IdStringThe id this handler is, this should be the class name to keep it unique.
ChoiceboolThe choice the user made in the dialogue window.

🟒 Custom Updaters


ℹ️
Any custom updaters should be in an editor folder in the folder structure or in a editor ifdef.

Interfaces

IBuildUpdater

Implement to make a build updater that will increment build numbers on build.

// Defines the order that the updater runs at...
// Above 0 is after the asset updaters, below is before...
int UpdateOrder { get; }

// Runs the logic in this method when the asset tries 
// to update the build number...
public void OnBuildVersionIncremented(BuildTarget buildTarget)

ISyncable

Implement to sync version numbers when requested (systematic only)…

// Runs the logic in this method when the asset tries 
// to sync version numbers...
public void OnVersionSync(string version)

IPreBuildDialogue

Implement to make a dialogue window appear before a build is made…

// Runs the logic in this method when the asset tries 
// to sync version numbers...
public void OnPreBuildDialogue(BuildTarget target)

Example

ℹ️
Below is an example of a custom updater to update the build number in a game analytics settings asset when the number is updated by the asset & when the user manually sync’s the systematic version number.
using GameAnalyticsSDK;
using UnityEditor;

public class GameAnalyticsUpdater : IBuildUpdater, ISyncable
{
    //
    //
    //  IBuildUpdater Implementation 
    //
    //
    public int UpdateOrder => 10;
        
    public void OnBuildVersionIncremented(BuildTarget buildTarget)
    {
        for (var i = 0; i < GameAnalytics.SettingsGA.Build.Count; i++)
        {
            GameAnalytics.SettingsGA.Build[i] = PlayerSettings.bundleVersion;
        }
    }

        
    //
    //
    //  ISyncable Implementation 
    //
    //
    public void OnVersionSync(string version)
    {
        for (var i = 0; i < GameAnalytics.SettingsGA.Build.Count; i++)
        {
            GameAnalytics.SettingsGA.Build[i] = version;
        }
    }
}