Version: 2021.2
JSON 格式的编译清单
计划构建

ScriptableObject 格式的编译清单

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
{
    public static void PreExport(UnityEngine.CloudBuild.BuildManifestObject manifest)
    {
        PlayerSettings.bundleVersion = String.Format("1.0.{0}", manifest.GetValue("buildNumber", "unknown"));
    }
}

这是 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();
    }
}
JSON 格式的编译清单
计划构建
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961