BuildManifestObject
is a ScriptableObject you can use to access the values in the Build manifest via script, without needing to manually load the UnityCloudBuildManifest.json TextAsset.
It is an optional parameter to the pre-export invoked by Cloud BuildA continuous integration service for Unity projects that automates the process of creating builds on Unity’s servers. More info
See in Glossary, if the
UnityCloudBuildManifest.json TextAsset has not been written. For more information, see Manifest as JSON.
The following example C# code demonstrates a pre-export method that updates the bundleVersion
in PlayerSettings
based on the buildNumber
provided in the manifest. For more information on pre-export methods, see Pre- and Post-export methods.
using UnityEngine;
using UnityEditor;
using System;
public class CloudBuildHelper : MonoBehaviour
{
public static void PreExport(UnityEngine.CloudBuild.BuildManifestObject manifest)
{
PlayerSettings.bundleVersion = String.Format("1.0.{0}", manifest.GetValue("buildNumber", "unknown"));
}
}
This is the public interface for the BuildManifestObject
class:
namespace UnityEngine.CloudBuild
{
public class BuildManifestObject : ScriptableObject
{
// Try to get a manifest value - returns true if key was found and could be cast to type T, otherwise returns false.
public bool TryGetValue<T>(string key, out T result);
// Retrieve a manifest value or throw an exception if the given key isn't found.
public T GetValue<T>(string key);
// Set the value for a given key.
public void SetValue(string key, object value);
// Copy values from a dictionary. ToString() will be called on dictionary values before being stored.
public void SetValues(Dictionary<string, object> sourceDict);
// Remove all key/value pairs.
public void ClearValues();
// Return a dictionary that represents the current BuildManifestObject.
public Dictionary<string, object> ToDictionary();
// Return a JSON formatted string that represents the current BuildManifestObject
public string ToJson();
// Return an INI formatted string that represents the current BuildManifestObject
public override string ToString();
}
}