版本:Unity 6 (6000.0)
语言中文(简体)
  • C#

PlayerSettings.iOS.buildNumber

建议修改

成功!

感谢您帮助我们提高 Unity 文档的质量。尽管我们无法接受所有提交,但我们会阅读用户建议的每项修改,并在适用时进行更新。

关闭

提交失败

由于某些原因,您建议的修改无法提交。请在几分钟后<a>重试</a>。感谢您抽出时间帮助我们提高 Unity 文档的质量。

关闭

取消

切换到手册
public static string buildNumber;

描述

bundle 的内部版本号

它存储在已构建应用程序的 info.plist 文件中的“CFBundleVersion”字段中。

using UnityEngine;
using UnityEditor;

public class BuildNumberExample { // This example will create a Menu Item called "Increase Minor Build Number" under "Examples" submenu which when pressed will get the current "Build" property and increase the Minor version by 1 // Assuming the "Build" property follows the format Major.Minor.Patch (for example 2.0.5 will be increased to 2.1.0), [MenuItem("Examples/Increase Minor Build Number")] public static void IncreaseMinorBuildNumber() { // Get the current build number value string currentBuildNumberString = PlayerSettings.iOS.buildNumber;

// Separate the build number string to Major, Minor and Patch numbers string[] separatedBuildNumbers = currentBuildNumberString.Split('.');

// Parse the Major and Minor version numbers to integer values int majorVersionNumber = int.Parse(separatedBuildNumbers[0]); int minorVersionNumber = int.Parse(separatedBuildNumbers[1]);

// Increment the Minor version number minorVersionNumber++; // Update the buildNumber property with the new values: // - keep the old Major version number; // - update Minor version number; // - replace Patch version number with 0, since Minor version was updated. PlayerSettings.iOS.buildNumber = string.Format("{0}.{1}.{2}", majorVersionNumber, minorVersionNumber, 0); } }