Skip to content

Commit a314676

Browse files
Erik Bylundkirre-bylund
authored andcommitted
Help users correctly use the game version setting
1 parent e942b16 commit a314676

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Runtime/Editor/ProjectSettings.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if UNITY_EDITOR
22
using System.Collections.Generic;
3+
using System.Text.RegularExpressions;
34
using UnityEditor;
45
using UnityEngine;
56
using UnityEngine.UIElements;
@@ -104,6 +105,13 @@ private void DrawGameSettings()
104105
}
105106
EditorGUILayout.Space();
106107

108+
if (!IsSemverString(m_CustomSettings.FindProperty("game_version").stringValue))
109+
{
110+
EditorGUILayout.HelpBox(
111+
"Game version needs to follow a numeric Semantic Versioning pattern: X.Y.Z.B with the sections denoting MAJOR.MINOR.PATCH.BUILD and the last two being optional. Read more at https://docs.lootlocker.com/the-basics/core-concepts/glossary#game-version",
112+
MessageType.Warning, false);
113+
}
114+
107115
EditorGUI.BeginChangeCheck();
108116
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("currentDebugLevel"));
109117

@@ -123,6 +131,12 @@ private void DrawGameSettings()
123131
EditorGUILayout.Space();
124132
}
125133

134+
private static bool IsSemverString(string str)
135+
{
136+
return Regex.IsMatch(str,
137+
@"^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:\.(0|[1-9]\d*))?$");
138+
}
139+
126140
[SettingsProvider]
127141
public static SettingsProvider CreateProvider()
128142
{

0 commit comments

Comments
 (0)