Tanoda
QRcode/Scripts/Utility.cs
Go to the documentation of this file.
1using System.Text.RegularExpressions;
2using UnityEngine;
3
4public class Utility
5{
6 public static bool CheckIsUrlFormat(string strValue)
7 {
8 return CheckIsFormat("(http://)?([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?", strValue);
9 }
10
11 public static bool CheckIsFormat(string strRegex, string strValue)
12 {
13 if (strValue != null && strValue.Trim() != string.Empty)
14 {
15 var regex = new Regex(strRegex);
16 return regex.IsMatch(strValue);
17 }
18
19 return false;
20 }
21
22
23 //Converter
24
25 public static Sprite Texture2DToSprite(Texture2D texture)
26 {
27 var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f),
28 100.0f);
29 return sprite;
30 }
31}
static bool CheckIsFormat(string strRegex, string strValue)
static Sprite Texture2DToSprite(Texture2D texture)
static bool CheckIsUrlFormat(string strValue)