Skip to content

Instantly share code, notes, and snippets.

@ruccho
Last active May 3, 2020 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruccho/0181d727270159d234cf8ed2cf6f4b76 to your computer and use it in GitHub Desktop.
Save ruccho/0181d727270159d234cf8ed2cf6f4b76 to your computer and use it in GitHub Desktop.
Unityで再生ボタンを押すたびにプロジェクトのバージョンを上げるスクリプト。Editorフォルダに入れて使ってください。
using UnityEditor;
using System.Linq;
namespace Ruccho.Utilities
{
public class AutoVersion
{
[InitializeOnLoadMethod]
private static void RegisterEditorIncrementEvent()
{
EditorApplication.playModeStateChanged += (x) =>
{
if (x == PlayModeStateChange.ExitingEditMode)
{
string currentVersion = PlayerSettings.bundleVersion;
string[] digits = currentVersion.Split('.');
string last = digits[digits.Length - 1];
int lastParsed;
string added;
if (int.TryParse(last, out lastParsed))
{
lastParsed++;
added = string.Join(".", digits.Take(digits.Length - 1));
}
else
{
lastParsed = 0;
added = currentVersion;
}
added += "." + lastParsed.ToString();
PlayerSettings.bundleVersion = added;
}
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment