Last active
May 3, 2020 04:40
-
-
Save ruccho/0181d727270159d234cf8ed2cf6f4b76 to your computer and use it in GitHub Desktop.
Unityで再生ボタンを押すたびにプロジェクトのバージョンを上げるスクリプト。Editorフォルダに入れて使ってください。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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