Esempio n. 1
0
        public BuildManifest()
        {
            BuildManifestType obj;

            this.buildParamDict = LoadBuildParamDict(out obj);
            this.Obj            = obj;

#if UNITY_EDITOR
            {
                // もしエディタで、かつファイルが存在しなかったら、jsonを吐き出す。
                var targetPath = AppManifestStoreSettings.BUILDMANIFEST_PATH;
                if (!System.IO.File.Exists(targetPath))
                {
                    var jsonStr = JsonUtility.ToJson(new BuildManifestType());
                    jsonStr = AppManifestStoreSettings.Prettify(jsonStr);
                    using (var sw = new System.IO.StreamWriter(targetPath))
                    {
                        sw.WriteLine(jsonStr);
                    }
                }
                UnityEditor.AssetDatabase.Refresh();
            }
#endif

            // set parameter from application.
            buildParamDict["unityVersion"] = Application.unityVersion;

#if UNITY_CLOUD_BUILD
            {
                // overwrite by cloud build parameter if exist.
                var cloudBuildManifestStr = Resources.Load <TextAsset>("UnityCloudBuildManifest.json").text;
                var cloudBuildManifest    = JsonUtility.FromJson <CloudBuildManifest>(cloudBuildManifestStr);

                var cloudBuildManifestDict = cloudBuildManifest.GetType()
                                             .GetFields(BindingFlags.Instance | BindingFlags.Public).ToArray()
                                             .ToDictionary(prop => prop.Name, prop => (string)prop.GetValue(cloudBuildManifest));

                // overwrite.
                foreach (var cloudBuildManifestDictItem in cloudBuildManifestDict)
                {
                    var key = cloudBuildManifestDictItem.Key;
                    var val = cloudBuildManifestDictItem.Value;
                    buildParamDict[key] = val;
                }
            }
#endif
        }
Esempio n. 2
0
        public static void UpdateBuildManifest(Func <BuildManifestType, BuildManifestType> update)
        {
            var current = LoadBuildManifest();

            var updated = update(current);

            // overwrite resource file.
            var targetPath = AppManifestStoreSettings.BUILDMANIFEST_PATH;
            var jsonStr    = JsonUtility.ToJson(updated);

            jsonStr = AppManifestStoreSettings.Prettify(jsonStr);

            using (var sw = new System.IO.StreamWriter(targetPath)) {
                sw.WriteLine(jsonStr);
            }

            UnityEditor.AssetDatabase.Refresh();
        }