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 Build, 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
{
#if UNITY_CLOUD_BUILD
public static void PreExport(UnityEngine.CloudBuild.BuildManifestObject manifest)
{
PlayerSettings.bundleVersion = string.Format("1.0.{0}", manifest.GetValue<int>("buildNumber"));
}
#endif
}
这是 BuildManifestObject
类的公有接口:
namespace UnityEngine.CloudBuild
{
public class BuildManifestObject : ScriptableObject
{
// 尝试获取清单值 - 如果找到键并且可以转换为类型 T,则返回 true,否则返回 false。
public bool TryGetValue<T>(string key, out T result);
//检索清单值,如果找不到给定的键,则抛出异常。
public T GetValue<T>(string key);
//设置给定键的值。
public void SetValue(string key, object value);
//从字典复制值。在保存字典值之前将对字典值调用 ToString()。
public void SetValues(Dictionary<string, object> sourceDict);
//删除所有键/值对。
public void ClearValues();
//返回代表当前 BuildManifestObject 的字典。
public Dictionary<string, object> ToDictionary();
//返回代表当前 BuildManifestObject 的 JSON 格式字符串
public string ToJson();
// 返回代表当前 BuildManifestObject 的 INI 格式字符串
public override string ToString();
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.