Exemplo n.º 1
0
        public static void Export(string outputPath, Dictionary <string, string> args)
        {
            var scenes  = args["scenes"].GetValue <string[]>();      //导出的场景
            var develop = args["develop"].TryGetValue <bool>(false); //是否开发者模式

            HandleDevelop(develop);
            var profile = args["profile"].TryGetValue <bool>(false);//是否打开profile

            HandleProfile(profile);
            var configPath = args["configPath"];

            XDocument xDoc   = XDocument.Load(configPath);
            BuildFile config = XmlSerializerEx.Deserialize <BuildFile>(xDoc);

            PlayerSettings.applicationIdentifier = config.packageName;
            PlayerSettings.productName           = config.appName;
            PlayerSettings.bundleVersion         = config.versionCode;
            PlayerSettings.iOS.buildNumber       = config.versionCode;

            if (Application.platform != RuntimePlatform.Android)
            {
                EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);
            }

            BuildPipeline.BuildPlayer(scenes, outputPath, BuildTarget.Android, BuildOptions.None
                                      | BuildOptions.AcceptExternalModificationsToPlayer);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 加载
        /// </summary>
        /// <param name="buildFilePath"></param>
        /// <returns></returns>
        public static BuildFile Load(string buildFilePath)
        {
            BuildFile res       = new BuildFile();
            Type      fileType  = typeof(BuildFile);
            XDocument buildFile = XDocument.Load(buildFilePath);

            foreach (var property in fileType.GetProperties())
            {
                XElement ele = buildFile.Root.Element(property.Name);
                if (ele == null)
                {
                    continue;
                }

                object value = ele.ReadValueFromElement(property.PropertyType);
                property.SetValue(res, value, new object[0]);
            }
            return(res);
        }