方块拼图
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -7,6 +8,8 @@ using System.Threading.Tasks;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
using System.Globalization;
|
||||
using UnityEditor;
|
||||
|
||||
namespace AibisDream.Utility
|
||||
{
|
||||
@@ -189,8 +192,21 @@ namespace AibisDream.Utility
|
||||
return;
|
||||
}
|
||||
|
||||
List<Transform> children = new List<Transform>();
|
||||
foreach (Transform child in self)
|
||||
{
|
||||
children.Add(child);
|
||||
}
|
||||
|
||||
foreach (var child in children)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!EditorApplication.isPlaying)
|
||||
{
|
||||
Object.DestroyImmediate(child.gameObject);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
Object.Destroy(child.gameObject);
|
||||
}
|
||||
}
|
||||
@@ -243,5 +259,47 @@ namespace AibisDream.Utility
|
||||
{
|
||||
return Regex.Replace(str.Replace("<br>", "\n"), "[<|{].*?[>|}]", string.Empty);
|
||||
}
|
||||
|
||||
public static int[,] DeserializeIntArray(string str)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(str))
|
||||
{
|
||||
return new int[0, 0];
|
||||
}
|
||||
|
||||
var array = str.Trim().Split(';');
|
||||
var result = new int[array.Length, array[0].Split(',').Length];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
var row = array[i].Split(',');
|
||||
for (int j = 0; j < row.Length; j++)
|
||||
{
|
||||
result[i, j] = int.Parse(row[j], NumberStyles.Integer, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string SerializeIntArray(int[,] array)
|
||||
{
|
||||
var result = new StringBuilder();
|
||||
for (int i = 0; i < array.GetLength(0); i++)
|
||||
{
|
||||
for (int j = 0; j < array.GetLength(1); j++)
|
||||
{
|
||||
result.Append(array[i, j]);
|
||||
if (j < array.GetLength(1) - 1)
|
||||
{
|
||||
result.Append(',');
|
||||
}
|
||||
}
|
||||
|
||||
if (i < array.GetLength(0) - 1)
|
||||
{
|
||||
result.Append(';');
|
||||
}
|
||||
}
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user