This commit is contained in:
tangbin
2025-06-22 15:21:25 +08:00
parent 89d395440a
commit 1cb6dc502f
22 changed files with 2241 additions and 7346 deletions

View File

@@ -0,0 +1,33 @@
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
public static class UtilityClass
{
public static bool IsPosValidFormat(string value)
{
// 使用正则表达式判断格式是否为 x,y正整数
string pattern = @"^\d+,\d+$";
return Regex.IsMatch(value, pattern);
}
public static bool IsNumValidFormat(string value)
{
// 使用正则表达式判断是否为正整数
string pattern = @"^\d+$";
return Regex.IsMatch(value, pattern);
}
public static Vector2Int GetVector2Pos(string value)
{
if (IsPosValidFormat(value))
{
string[] parts = value.Split(',');
int x = int.Parse(parts[0]);
int y = int.Parse(parts[1]);
return new Vector2Int(x, y);
}
return Vector2Int.zero;
}
}
#endif